1.1 --- a/libfsserver/lib/files/file_pager.cc Sun Feb 26 18:43:52 2023 +0100
1.2 +++ b/libfsserver/lib/files/file_pager.cc Sun Feb 26 22:19:31 2023 +0100
1.3 @@ -53,7 +53,7 @@
1.4 /* Notify other users of the file and unsubscribe. */
1.5
1.6 _provider->notify_others(_notifier, NOTIFY_PEER_CLOSED, NOTIFY_VALUES_NULL);
1.7 - unsubscribe();
1.8 + unsubscribe(_notifier);
1.9
1.10 /* Detach the pager, potentially removing the file provider. */
1.11
1.12 @@ -146,24 +146,27 @@
1.13
1.14
1.15
1.16 -/* Subscribe to notifications. */
1.17 +/* Subscribe to notifications.
1.18 + Readers can subscribe to new data (flush) and file closed events.
1.19 + Writers can subscribe to file closed events. */
1.20
1.21 long FilePager::subscribe(l4_cap_idx_t notifier, notify_flags_t flags)
1.22 {
1.23 - /* Readers can subscribe to new data (flush) and file closed events.
1.24 - Writers can subscribe to file closed events. */
1.25 + /* A single notifier is recorded so that it may be unsubscribed when the
1.26 + file is closed. */
1.27 +
1.28 + if ((notifier != _notifier) && l4_is_valid_cap(_notifier))
1.29 + unsubscribe(_notifier);
1.30
1.31 _notifier = notifier;
1.32 -
1.33 return _provider->subscribe(notifier, flags);
1.34 }
1.35
1.36 /* Unsubscribe from notifications. */
1.37
1.38 -long FilePager::unsubscribe()
1.39 +long FilePager::unsubscribe(l4_cap_idx_t notifier)
1.40 {
1.41 - _provider->unsubscribe(_notifier);
1.42 - return L4_EOK;
1.43 + return _provider->unsubscribe(notifier);
1.44 }
1.45
1.46 // vim: tabstop=4 expandtab shiftwidth=4