1.1 --- a/libfsserver/lib/mapping/page_mapper.cc Fri Sep 10 23:16:41 2021 +0200
1.2 +++ b/libfsserver/lib/mapping/page_mapper.cc Sat Sep 11 00:16:10 2021 +0200
1.3 @@ -25,40 +25,26 @@
1.4
1.5
1.6 PageMapper::PageMapper(Accessor *accessor, Pages *pages)
1.7 -: _accessor(accessor), _pages(pages), _attached(0)
1.8 +: _accessor(accessor), _pages(pages)
1.9 {
1.10 }
1.11
1.12 /* Accounting methods. */
1.13
1.14 -/* Attach a pager, opening the accessor if required. */
1.15 -
1.16 -void PageMapper::attach()
1.17 -{
1.18 - std::lock_guard<std::mutex> guard(_lock);
1.19 -
1.20 - _attached += 1;
1.21 -}
1.22 -
1.23 /* Detach a pager, purging active pages and closing the accessor if no more
1.24 pagers are attached. Return whether any pagers are still attached. */
1.25
1.26 unsigned int PageMapper::detach()
1.27 {
1.28 - std::lock_guard<std::mutex> guard(_lock);
1.29 -
1.30 - if (_attached)
1.31 - {
1.32 - _attached -= 1;
1.33 + unsigned int attached = Accountable::detach();
1.34
1.35 - if (!_attached)
1.36 - {
1.37 - _map.purge(this, _pages);
1.38 - _accessor->close();
1.39 - }
1.40 + if (!attached)
1.41 + {
1.42 + _map.purge(this, _pages);
1.43 + _accessor->close();
1.44 }
1.45
1.46 - return _attached;
1.47 + return attached;
1.48 }
1.49
1.50 /* Interface for the pager. */