1.1 --- a/pipes/pipe_pager.cc Sat Mar 27 01:42:25 2021 +0100
1.2 +++ b/pipes/pipe_pager.cc Sat Mar 27 22:12:12 2021 +0100
1.3 @@ -1,6 +1,8 @@
1.4 #include "pipe_pager.h"
1.5 #include "pipe_object_server.h"
1.6
1.7 +
1.8 +
1.9 /* Initialise a pager for a pipe with a shared page mapper for moderating
1.10 access to loaded pages. At first, no mapper will be configured: this must be
1.11 done by requesting a region. */
1.12 @@ -71,26 +73,12 @@
1.13
1.14 long PipePager::next_region_for_reader(offset_t *populated_size, offset_t *size)
1.15 {
1.16 - /* Obtain the next region if a current region is defined. */
1.17 -
1.18 - if (_mapper != NULL)
1.19 - {
1.20 - PageMapper *mapper = _paging->next_region();
1.21 -
1.22 - /* Return an error if no next region currently exists. */
1.23 + PageMapper *mapper = _paging->next_region();
1.24
1.25 - if (mapper == NULL)
1.26 - return -L4_EIO;
1.27 -
1.28 - _mapper = mapper;
1.29 - }
1.30 + if (mapper == NULL)
1.31 + return -L4_EIO;
1.32
1.33 - /* Obtain the first region if no mapper is defined. */
1.34 -
1.35 - else
1.36 - _mapper = _paging->first_region();
1.37 -
1.38 - /* Return the details of the now-current region. */
1.39 + _mapper = mapper;
1.40
1.41 return current_region(populated_size, size);
1.42 }
1.43 @@ -102,28 +90,16 @@
1.44 if (_mapper != NULL)
1.45 _mapper->set_data_size(*populated_size);
1.46
1.47 - /* A guaranteed amount of memory is reserved for the pipe. */
1.48 -
1.49 - PagesConserving *pages = _paging->pages();
1.50 + /* Obtain the page mapper for the region. */
1.51
1.52 - if (!pages->increase(_size))
1.53 - return -L4_ENOMEM;
1.54 -
1.55 - /* Set the page mapper for the region. */
1.56 + PageMapper *mapper = _paging->add_region();
1.57
1.58 - _mapper = new PageMapper(_paging->accessor(), pages);
1.59 - _mapper->attach();
1.60 -
1.61 - /* Record the mapper as the latest region in the accessor. */
1.62 -
1.63 - _paging->add_region(_mapper);
1.64 + if (mapper == NULL)
1.65 + return -L4_EIO;
1.66
1.67 - /* Set the region size to the allocated amount. */
1.68 + _mapper = mapper;
1.69
1.70 - *size = _size;
1.71 - *populated_size = 0;
1.72 -
1.73 - return L4_EOK;
1.74 + return current_region(populated_size, size);
1.75 }
1.76
1.77 // vim: tabstop=4 expandtab shiftwidth=4