1.1 --- a/libfsserver/include/fsserver/pipe_paging.h Fri Aug 06 19:24:56 2021 +0200
1.2 +++ b/libfsserver/include/fsserver/pipe_paging.h Fri Aug 06 19:26:54 2021 +0200
1.3 @@ -59,6 +59,10 @@
1.4
1.5 /* Common functionality. */
1.6
1.7 + virtual PageMapper *_add_region();
1.8 +
1.9 + virtual PageMapper *_next_region();
1.10 +
1.11 virtual void discard_region(unsigned int i);
1.12
1.13 public:
1.14 @@ -75,6 +79,8 @@
1.15
1.16 virtual PageMapper *current_region();
1.17
1.18 + virtual PageMapper *current_region(bool writing);
1.19 +
1.20 virtual PageMapper *next_region();
1.21
1.22 /* Access management. */
2.1 --- a/libfsserver/lib/pipes/pipe_opener_resource.cc Fri Aug 06 19:24:56 2021 +0200
2.2 +++ b/libfsserver/lib/pipes/pipe_opener_resource.cc Fri Aug 06 19:26:54 2021 +0200
2.3 @@ -84,14 +84,6 @@
2.4 {
2.5 PipePager *pager = new PipePager(paging, writing);
2.6
2.7 - /* Initialise the first region. */
2.8 -
2.9 - offset_t populated_size, region_size;
2.10 - long err = pager->next_region(&populated_size, ®ion_size);
2.11 -
2.12 - if (err)
2.13 - return err;
2.14 -
2.15 return ResourceServer(pager).start_thread(endpoint);
2.16 }
2.17
3.1 --- a/libfsserver/lib/pipes/pipe_pager.cc Fri Aug 06 19:24:56 2021 +0200
3.2 +++ b/libfsserver/lib/pipes/pipe_pager.cc Fri Aug 06 19:26:54 2021 +0200
3.3 @@ -35,6 +35,11 @@
3.4 /* Initialise the size of the paged region. */
3.5
3.6 _size = _paging->region_size();
3.7 +
3.8 + /* Obtain any initial page mapper, this having been set up in the paging
3.9 + coordinator. */
3.10 +
3.11 + _mapper = _paging->current_region(_writing);
3.12 }
3.13
3.14 int PipePager::expected_items()
4.1 --- a/libfsserver/lib/pipes/pipe_paging.cc Fri Aug 06 19:24:56 2021 +0200
4.2 +++ b/libfsserver/lib/pipes/pipe_paging.cc Fri Aug 06 19:26:54 2021 +0200
4.3 @@ -41,6 +41,11 @@
4.4
4.5 for (unsigned int i = 0; i < 2; i++)
4.6 _regions[i] = NULL;
4.7 +
4.8 + /* Initialise a region accessible by reader and writer. */
4.9 +
4.10 + _add_region();
4.11 + _next_region();
4.12 }
4.13
4.14 /* Return whether one or more endpoints have detached. */
4.15 @@ -94,7 +99,7 @@
4.16
4.17 /* Add a region to the sequence. */
4.18
4.19 -PageMapper *PipePaging::add_region()
4.20 +PageMapper *PipePaging::_add_region()
4.21 {
4.22 /* If the writer already accesses a different region to the reader, no new
4.23 region is added. */
4.24 @@ -117,6 +122,15 @@
4.25
4.26 _regions[_writing] = mapper;
4.27
4.28 + /* Return the next region's mapper. */
4.29 +
4.30 + return mapper;
4.31 +}
4.32 +
4.33 +PageMapper *PipePaging::add_region()
4.34 +{
4.35 + PageMapper *mapper = _add_region();
4.36 +
4.37 /* Let the writer notify the reader. */
4.38
4.39 notify_others(PipePaging::WRITER, NOTIFY_CONTENT_AVAILABLE);
4.40 @@ -133,12 +147,19 @@
4.41 return _regions[_reading];
4.42 }
4.43
4.44 +/* Return the current region for reading or writing. */
4.45 +
4.46 +PageMapper *PipePaging::current_region(bool writing)
4.47 +{
4.48 + return _regions[writing ? _writing : _reading];
4.49 +}
4.50 +
4.51 /* Return the next region for the reader if the writer is using a different one.
4.52 Otherwise, return NULL. */
4.53
4.54 -PageMapper *PipePaging::next_region()
4.55 +PageMapper *PipePaging::_next_region()
4.56 {
4.57 - /* If the reader already accesses the same region to the writer, no next
4.58 + /* If the reader already accesses the same region as the writer, no next
4.59 region can be obtained. */
4.60
4.61 if (_reading == _writing)
4.62 @@ -152,13 +173,20 @@
4.63
4.64 _reading = 1 - _reading;
4.65
4.66 - /* Let the reader notify the writer. */
4.67 -
4.68 - notify_others(PipePaging::READER, NOTIFY_SPACE_AVAILABLE);
4.69 -
4.70 /* Return the next region's mapper. */
4.71
4.72 return _regions[_reading];
4.73 }
4.74
4.75 +PageMapper *PipePaging::next_region()
4.76 +{
4.77 + PageMapper *mapper = _next_region();
4.78 +
4.79 + /* Let the reader notify the writer. */
4.80 +
4.81 + notify_others(PipePaging::READER, NOTIFY_SPACE_AVAILABLE);
4.82 +
4.83 + return mapper;
4.84 +}
4.85 +
4.86 // vim: tabstop=4 expandtab shiftwidth=4