1.1 --- a/libfsserver/lib/files/file_pager.cc Sat Sep 11 19:44:57 2021 +0200
1.2 +++ b/libfsserver/lib/files/file_pager.cc Sun Sep 12 01:14:30 2021 +0200
1.3 @@ -24,12 +24,14 @@
1.4
1.5
1.6
1.7 -/* Initialise a pager for a file with a unique file identifier and shared page
1.8 - mapper for moderating access to loaded pages. */
1.9 +/* Initialise a pager for a file with a unique file identifier, file provider,
1.10 + mapping flags and a file paging coordinator. The provider offers a shared
1.11 + page mapper for moderating access to loaded pages. */
1.12
1.13 -FilePager::FilePager(fileid_t fileid, PageMapper *mapper, map_flags_t flags,
1.14 +FilePager::FilePager(fileid_t fileid, FileProvider *provider, map_flags_t flags,
1.15 FilePaging *paging)
1.16 -: Pager(mapper, flags), _paging(paging), fileid(fileid)
1.17 +: Pager(provider->mapper(), flags),
1.18 + _paging(paging), _provider(provider), fileid(fileid)
1.19 {
1.20 }
1.21
1.22 @@ -50,14 +52,13 @@
1.23
1.24 void FilePager::close()
1.25 {
1.26 - _paging->detach_pager(fileid, _mapper);
1.27 -
1.28 /* Notify other users of the file. */
1.29
1.30 - FileNotification *notifier = _paging->notifier(fileid);
1.31 + _provider->notify_others(_endpoint, NOTIFY_PEER_CLOSED);
1.32
1.33 - if (notifier != NULL)
1.34 - notifier->notify_others(_endpoint, NOTIFY_PEER_CLOSED);
1.35 + /* Detach the pager, potentially removing the file provider. */
1.36 +
1.37 + _paging->detach_pager(fileid, _provider);
1.38 }
1.39
1.40
1.41 @@ -70,11 +71,7 @@
1.42
1.43 if (_resized)
1.44 {
1.45 - FileNotification *notifier = _paging->notifier(fileid);
1.46 -
1.47 - if (notifier != NULL)
1.48 - notifier->notify_others(_endpoint, NOTIFY_CONTENT_AVAILABLE);
1.49 -
1.50 + _provider->notify_others(_endpoint, NOTIFY_CONTENT_AVAILABLE);
1.51 _resized = false;
1.52 }
1.53
1.54 @@ -121,22 +118,13 @@
1.55 /* Readers can subscribe to new data (at end), and pipe closed events.
1.56 Writers can subscribe to new space and pipe closed events. */
1.57
1.58 - FileNotification *notifier = _paging->notifier(fileid);
1.59 -
1.60 - if (notifier == NULL)
1.61 - return -L4_ENOSYS;
1.62 -
1.63 - _endpoint = notifier->subscribe(endpoint, flags);
1.64 + _endpoint = _provider->subscribe(endpoint, flags);
1.65 return L4_EOK;
1.66 }
1.67
1.68 long FilePager::unsubscribe(l4_cap_idx_t endpoint)
1.69 {
1.70 - FileNotification *notifier = _paging->notifier(fileid);
1.71 -
1.72 - if (notifier != NULL)
1.73 - notifier->unsubscribe(_endpoint, endpoint);
1.74 -
1.75 + _provider->unsubscribe(_endpoint, endpoint);
1.76 return L4_EOK;
1.77 }
1.78