1.1 --- a/libfsserver/include/fsserver/pipe_paging.h Tue May 18 00:55:20 2021 +0200
1.2 +++ b/libfsserver/include/fsserver/pipe_paging.h Tue May 18 23:58:19 2021 +0200
1.3 @@ -58,6 +58,10 @@
1.4
1.5 l4_cap_idx_t _irqs[2];
1.6
1.7 + /* Common functionality. */
1.8 +
1.9 + virtual void discard_region(unsigned int i);
1.10 +
1.11 public:
1.12 explicit PipePaging(Memory *memory, offset_t size);
1.13
2.1 --- a/libfsserver/lib/pipes/pipe_paging.cc Tue May 18 00:55:20 2021 +0200
2.2 +++ b/libfsserver/lib/pipes/pipe_paging.cc Tue May 18 23:58:19 2021 +0200
2.3 @@ -95,6 +95,18 @@
2.4 return _endpoints < 2;
2.5 }
2.6
2.7 +void PipePaging::discard_region(unsigned int i)
2.8 +{
2.9 + PageMapper *mapper = _regions[i];
2.10 +
2.11 + if (mapper != NULL)
2.12 + {
2.13 + mapper->detach();
2.14 + _regions[i] = NULL;
2.15 + delete mapper;
2.16 + }
2.17 +}
2.18 +
2.19 /* Detach one endpoint. */
2.20
2.21 void PipePaging::detach()
2.22 @@ -112,16 +124,7 @@
2.23 /* Discard all regions from the pipe. */
2.24
2.25 for (unsigned int i = 0; i < 2; i++)
2.26 - {
2.27 - PageMapper *mapper = _regions[i];
2.28 -
2.29 - if (mapper != NULL)
2.30 - {
2.31 - mapper->detach();
2.32 - _regions[i] = NULL;
2.33 - delete mapper;
2.34 - }
2.35 - }
2.36 + discard_region(i);
2.37
2.38 /* Release IRQs. */
2.39
2.40 @@ -195,14 +198,7 @@
2.41
2.42 /* Detach and discard the current page mapper. */
2.43
2.44 - PageMapper *mapper = _regions[_reading];
2.45 -
2.46 - if (mapper != NULL)
2.47 - {
2.48 - mapper->detach();
2.49 - _regions[_reading] = NULL;
2.50 - delete mapper;
2.51 - }
2.52 + discard_region(_reading);
2.53
2.54 /* Select the next region. */
2.55