1.1 --- a/libfsserver/lib/pipes/pipe_paging.cc Sat Sep 11 01:32:34 2021 +0200
1.2 +++ b/libfsserver/lib/pipes/pipe_paging.cc Sat Sep 11 19:44:57 2021 +0200
1.3 @@ -46,39 +46,8 @@
1.4 _next_region();
1.5 }
1.6
1.7 -/* Return whether one or more endpoints have detached. */
1.8 -
1.9 -int PipePaging::closed()
1.10 -{
1.11 - return _active_endpoints < 2;
1.12 -}
1.13 -
1.14 -void PipePaging::discard_region(unsigned int i)
1.15 +PipePaging::~PipePaging()
1.16 {
1.17 - PageMapper *mapper = _regions[i];
1.18 -
1.19 - if (mapper != NULL)
1.20 - {
1.21 - mapper->detach();
1.22 - _regions[i] = NULL;
1.23 - delete mapper;
1.24 - }
1.25 -}
1.26 -
1.27 -/* Detach one endpoint. */
1.28 -
1.29 -void PipePaging::detach()
1.30 -{
1.31 - if (!_active_endpoints)
1.32 - return;
1.33 - else
1.34 - _active_endpoints--;
1.35 -
1.36 - /* Return if the other endpoint is attached. */
1.37 -
1.38 - if (_active_endpoints)
1.39 - return;
1.40 -
1.41 /* Discard all regions from the pipe. */
1.42
1.43 for (unsigned int i = 0; i < 2; i++)
1.44 @@ -95,6 +64,37 @@
1.45 delete _memory;
1.46 }
1.47
1.48 +/* Return whether one or more endpoints have detached. */
1.49 +
1.50 +int PipePaging::closed()
1.51 +{
1.52 + return _active_endpoints < 2;
1.53 +}
1.54 +
1.55 +/* Detach one endpoint, returning the number still active. */
1.56 +
1.57 +unsigned int PipePaging::detach()
1.58 +{
1.59 + if (_active_endpoints)
1.60 + _active_endpoints--;
1.61 +
1.62 + return _active_endpoints;
1.63 +}
1.64 +
1.65 +/* Discard a region. */
1.66 +
1.67 +void PipePaging::discard_region(unsigned int i)
1.68 +{
1.69 + PageMapper *mapper = _regions[i];
1.70 +
1.71 + if (mapper != NULL)
1.72 + {
1.73 + mapper->detach();
1.74 + _regions[i] = NULL;
1.75 + delete mapper;
1.76 + }
1.77 +}
1.78 +
1.79 /* Add a region to the sequence. */
1.80
1.81 PageMapper *PipePaging::_add_region()