1.1 --- a/files/pipe_paging.cc Thu Mar 25 01:42:50 2021 +0100
1.2 +++ b/files/pipe_paging.cc Fri Mar 26 00:03:30 2021 +0100
1.3 @@ -5,6 +5,30 @@
1.4 {
1.5 }
1.6
1.7 +/* Detach one endpoint. */
1.8 +
1.9 +void PipePaging::detach()
1.10 +{
1.11 + if (!_endpoints)
1.12 + return;
1.13 + else
1.14 + _endpoints--;
1.15 +
1.16 + if (_endpoints)
1.17 + return;
1.18 +
1.19 + /* Discard all regions from the pipe. */
1.20 +
1.21 + while (!_regions.empty())
1.22 + {
1.23 + PageMapper *mapper = _regions.front();
1.24 +
1.25 + _regions.pop_front();
1.26 + mapper->detach();
1.27 + delete mapper;
1.28 + }
1.29 +}
1.30 +
1.31 /* Add a region to the sequence. */
1.32
1.33 void PipePaging::add_region(PageMapper *mapper)
1.34 @@ -31,7 +55,16 @@
1.35 if (_accessors.size() > _regions.size())
1.36 _accessors.pop_front();
1.37
1.38 + /* Detach and discard the current page mapper. */
1.39 +
1.40 + PageMapper *mapper = _regions.front();
1.41 +
1.42 _regions.pop_front();
1.43 + mapper->detach();
1.44 + delete mapper;
1.45 +
1.46 + /* Return the next region. */
1.47 +
1.48 return _regions.front();
1.49 }
1.50 else
2.1 --- a/files/pipe_paging.h Thu Mar 25 01:42:50 2021 +0100
2.2 +++ b/files/pipe_paging.h Fri Mar 26 00:03:30 2021 +0100
2.3 @@ -23,9 +23,23 @@
2.4
2.5 offset_t _size;
2.6
2.7 + /* Endpoint status. */
2.8 +
2.9 + unsigned int _endpoints = 2;
2.10 +
2.11 public:
2.12 explicit PipePaging(offset_t size);
2.13
2.14 + virtual void detach();
2.15 +
2.16 + virtual PagesConserving *pages()
2.17 + { return &_pages; }
2.18 +
2.19 + virtual offset_t region_size()
2.20 + { return _size; }
2.21 +
2.22 + /* Region management. */
2.23 +
2.24 virtual void add_region(PageMapper *mapper);
2.25
2.26 virtual PageMapper *first_region();
2.27 @@ -33,12 +47,6 @@
2.28 virtual PageMapper *next_region();
2.29
2.30 virtual PipeAccessor *accessor();
2.31 -
2.32 - virtual PagesConserving *pages()
2.33 - { return &_pages; }
2.34 -
2.35 - virtual offset_t region_size()
2.36 - { return _size; }
2.37 };
2.38
2.39 // vim: tabstop=4 expandtab shiftwidth=4
3.1 --- a/pipe_pager.cc Thu Mar 25 01:42:50 2021 +0100
3.2 +++ b/pipe_pager.cc Fri Mar 26 00:03:30 2021 +0100
3.3 @@ -26,6 +26,14 @@
3.4
3.5
3.6
3.7 +/* Close the pager, releasing the paging coordinator for the pipe. This will
3.8 + release all active page mappers. */
3.9 +
3.10 +void PipePager::close()
3.11 +{
3.12 + _paging->detach();
3.13 +}
3.14 +
3.15 /* Support paging. */
3.16
3.17 long PipePager::map(unsigned long offset, l4_addr_t hot_spot, flags_t flags, l4_snd_fpage_t *region)
3.18 @@ -74,11 +82,6 @@
3.19 if (mapper == NULL)
3.20 return -L4_EIO;
3.21
3.22 - /* Detach and discard the current page mapper. */
3.23 -
3.24 - _mapper->detach();
3.25 - delete _mapper;
3.26 -
3.27 _mapper = mapper;
3.28 }
3.29
4.1 --- a/pipe_pager.h Thu Mar 25 01:42:50 2021 +0100
4.2 +++ b/pipe_pager.h Fri Mar 26 00:03:30 2021 +0100
4.3 @@ -22,6 +22,8 @@
4.4 public:
4.5 explicit PipePager(PipePaging *paging, bool writer);
4.6
4.7 + virtual void close();
4.8 +
4.9 /* Server details. */
4.10
4.11 int expected_items();