1.1 --- a/libexec/include/exec/external_pager.h Sun Feb 26 18:43:52 2023 +0100
1.2 +++ b/libexec/include/exec/external_pager.h Sun Feb 26 22:19:31 2023 +0100
1.3 @@ -34,9 +34,6 @@
1.4 class ExternalPager : public ExecPager, public ParentPagerObject,
1.5 public NotificationSupport
1.6 {
1.7 -protected:
1.8 - l4_cap_idx_t _notifier;
1.9 -
1.10 public:
1.11 explicit ExternalPager(address_t start = 0, address_t end = 0);
1.12
1.13 @@ -61,7 +58,7 @@
1.14
1.15 virtual long subscribe(l4_cap_idx_t notifier, notify_flags_t flags);
1.16
1.17 - virtual long unsubscribe();
1.18 + virtual long unsubscribe(l4_cap_idx_t notifier);
1.19 };
1.20
1.21 /* vim: tabstop=2 expandtab shiftwidth=2
2.1 --- a/libexec/lib/src/external_pager.cc Sun Feb 26 18:43:52 2023 +0100
2.2 +++ b/libexec/lib/src/external_pager.cc Sun Feb 26 22:19:31 2023 +0100
2.3 @@ -172,16 +172,14 @@
2.4
2.5 long ExternalPager::subscribe(l4_cap_idx_t notifier, notify_flags_t flags)
2.6 {
2.7 - _notifier = notifier;
2.8 return NotificationSupport::subscribe(notifier, flags);
2.9 }
2.10
2.11 /* Unsubscribe from notifications. */
2.12
2.13 -long ExternalPager::unsubscribe()
2.14 +long ExternalPager::unsubscribe(l4_cap_idx_t notifier)
2.15 {
2.16 - NotificationSupport::unsubscribe(_notifier);
2.17 - return L4_EOK;
2.18 + return NotificationSupport::unsubscribe(notifier);
2.19 }
2.20
2.21 /* vim: tabstop=2 expandtab shiftwidth=2
3.1 --- a/libfsclient/lib/src/notifier.cc Sun Feb 26 18:43:52 2023 +0100
3.2 +++ b/libfsclient/lib/src/notifier.cc Sun Feb 26 22:19:31 2023 +0100
3.3 @@ -216,7 +216,7 @@
3.4
3.5 client_Notification notify(object->base->ref);
3.6
3.7 - notify.unsubscribe();
3.8 + notify.unsubscribe(endpoint);
3.9
3.10 return remove_endpoint(object, endpoint);
3.11 }
4.1 --- a/libfsserver/include/fsserver/directory_resource.h Sun Feb 26 18:43:52 2023 +0100
4.2 +++ b/libfsserver/include/fsserver/directory_resource.h Sun Feb 26 22:19:31 2023 +0100
4.3 @@ -63,7 +63,7 @@
4.4
4.5 virtual long subscribe(l4_cap_idx_t notifier, notify_flags_t flags);
4.6
4.7 - virtual long unsubscribe();
4.8 + virtual long unsubscribe(l4_cap_idx_t notifier);
4.9 };
4.10
4.11 // vim: tabstop=4 expandtab shiftwidth=4
5.1 --- a/libfsserver/include/fsserver/file_pager.h Sun Feb 26 18:43:52 2023 +0100
5.2 +++ b/libfsserver/include/fsserver/file_pager.h Sun Feb 26 22:19:31 2023 +0100
5.3 @@ -83,7 +83,7 @@
5.4
5.5 virtual long subscribe(l4_cap_idx_t notifier, notify_flags_t flags);
5.6
5.7 - virtual long unsubscribe();
5.8 + virtual long unsubscribe(l4_cap_idx_t notifier);
5.9 };
5.10
5.11 // vim: tabstop=4 expandtab shiftwidth=4
6.1 --- a/libfsserver/include/fsserver/notification.h Sun Feb 26 18:43:52 2023 +0100
6.2 +++ b/libfsserver/include/fsserver/notification.h Sun Feb 26 22:19:31 2023 +0100
6.3 @@ -121,7 +121,7 @@
6.4 virtual long subscribe(unsigned int endpoint, l4_cap_idx_t notifier,
6.5 notify_flags_t flags);
6.6
6.7 - virtual void unsubscribe(l4_cap_idx_t notifier);
6.8 + virtual long unsubscribe(l4_cap_idx_t notifier);
6.9 };
6.10
6.11 // vim: tabstop=4 expandtab shiftwidth=4
7.1 --- a/libfsserver/include/fsserver/pipe_pager.h Sun Feb 26 18:43:52 2023 +0100
7.2 +++ b/libfsserver/include/fsserver/pipe_pager.h Sun Feb 26 22:19:31 2023 +0100
7.3 @@ -77,7 +77,7 @@
7.4
7.5 virtual long subscribe(l4_cap_idx_t notifier, notify_flags_t flags);
7.6
7.7 - virtual long unsubscribe();
7.8 + virtual long unsubscribe(l4_cap_idx_t notifier);
7.9 };
7.10
7.11 // vim: tabstop=4 expandtab shiftwidth=4
8.1 --- a/libfsserver/lib/directories/directory_resource.cc Sun Feb 26 18:43:52 2023 +0100
8.2 +++ b/libfsserver/lib/directories/directory_resource.cc Sun Feb 26 22:19:31 2023 +0100
8.3 @@ -131,10 +131,9 @@
8.4
8.5 /* Unsubscribe from notifications. */
8.6
8.7 -long DirectoryResource::unsubscribe()
8.8 +long DirectoryResource::unsubscribe(l4_cap_idx_t notifier)
8.9 {
8.10 - _provider->unsubscribe(_notifier);
8.11 - return L4_EOK;
8.12 + return _provider->unsubscribe(notifier);
8.13 }
8.14
8.15 // vim: tabstop=4 expandtab shiftwidth=4
9.1 --- a/libfsserver/lib/files/file_pager.cc Sun Feb 26 18:43:52 2023 +0100
9.2 +++ b/libfsserver/lib/files/file_pager.cc Sun Feb 26 22:19:31 2023 +0100
9.3 @@ -53,7 +53,7 @@
9.4 /* Notify other users of the file and unsubscribe. */
9.5
9.6 _provider->notify_others(_notifier, NOTIFY_PEER_CLOSED, NOTIFY_VALUES_NULL);
9.7 - unsubscribe();
9.8 + unsubscribe(_notifier);
9.9
9.10 /* Detach the pager, potentially removing the file provider. */
9.11
9.12 @@ -146,24 +146,27 @@
9.13
9.14
9.15
9.16 -/* Subscribe to notifications. */
9.17 +/* Subscribe to notifications.
9.18 + Readers can subscribe to new data (flush) and file closed events.
9.19 + Writers can subscribe to file closed events. */
9.20
9.21 long FilePager::subscribe(l4_cap_idx_t notifier, notify_flags_t flags)
9.22 {
9.23 - /* Readers can subscribe to new data (flush) and file closed events.
9.24 - Writers can subscribe to file closed events. */
9.25 + /* A single notifier is recorded so that it may be unsubscribed when the
9.26 + file is closed. */
9.27 +
9.28 + if ((notifier != _notifier) && l4_is_valid_cap(_notifier))
9.29 + unsubscribe(_notifier);
9.30
9.31 _notifier = notifier;
9.32 -
9.33 return _provider->subscribe(notifier, flags);
9.34 }
9.35
9.36 /* Unsubscribe from notifications. */
9.37
9.38 -long FilePager::unsubscribe()
9.39 +long FilePager::unsubscribe(l4_cap_idx_t notifier)
9.40 {
9.41 - _provider->unsubscribe(_notifier);
9.42 - return L4_EOK;
9.43 + return _provider->unsubscribe(notifier);
9.44 }
9.45
9.46 // vim: tabstop=4 expandtab shiftwidth=4
10.1 --- a/libfsserver/lib/generic/notification.cc Sun Feb 26 18:43:52 2023 +0100
10.2 +++ b/libfsserver/lib/generic/notification.cc Sun Feb 26 22:19:31 2023 +0100
10.3 @@ -103,11 +103,12 @@
10.4
10.5 /* Unsubscribe from an endpoint's notifications. */
10.6
10.7 -void NotificationSupport::unsubscribe(l4_cap_idx_t notifier)
10.8 +long NotificationSupport::unsubscribe(l4_cap_idx_t notifier)
10.9 {
10.10 std::lock_guard<std::mutex> guard(_lock);
10.11
10.12 _unsubscribe(notifier);
10.13 + return L4_EOK;
10.14 }
10.15
10.16 /* Common subscription functionality. */
11.1 --- a/libfsserver/lib/pipes/pipe_pager.cc Sun Feb 26 18:43:52 2023 +0100
11.2 +++ b/libfsserver/lib/pipes/pipe_pager.cc Sun Feb 26 22:19:31 2023 +0100
11.3 @@ -64,7 +64,7 @@
11.4
11.5 _paging->notify_others(_writing ? PipePaging::WRITER : PipePaging::READER,
11.6 NOTIFY_PEER_CLOSED, NOTIFY_VALUES_NULL);
11.7 - unsubscribe();
11.8 + unsubscribe(_notifier);
11.9
11.10 /* Deallocate the paging coordinator if no other endpoints are active. */
11.11
11.12 @@ -178,12 +178,17 @@
11.13
11.14
11.15
11.16 -/* Subscribe to notifications. */
11.17 +/* Subscribe to notifications.
11.18 + Readers can subscribe to new data (at end), and pipe closed events.
11.19 + Writers can subscribe to new space and pipe closed events. */
11.20
11.21 long PipePager::subscribe(l4_cap_idx_t notifier, notify_flags_t flags)
11.22 {
11.23 - /* Readers can subscribe to new data (at end), and pipe closed events.
11.24 - Writers can subscribe to new space and pipe closed events. */
11.25 + /* A single notifier is recorded so that it may be unsubscribed when the
11.26 + file is closed. */
11.27 +
11.28 + if ((notifier != _notifier) && l4_is_valid_cap(_notifier))
11.29 + unsubscribe(_notifier);
11.30
11.31 _notifier = notifier;
11.32
11.33 @@ -193,10 +198,9 @@
11.34
11.35 /* Unsubscribe from notifications. */
11.36
11.37 -long PipePager::unsubscribe()
11.38 +long PipePager::unsubscribe(l4_cap_idx_t notifier)
11.39 {
11.40 - _paging->unsubscribe(_notifier);
11.41 - return L4_EOK;
11.42 + return _paging->unsubscribe(notifier);
11.43 }
11.44
11.45 // vim: tabstop=4 expandtab shiftwidth=4
12.1 --- a/libsystypes/idl/notification.idl Sun Feb 26 18:43:52 2023 +0100
12.2 +++ b/libsystypes/idl/notification.idl Sun Feb 26 22:19:31 2023 +0100
12.3 @@ -9,5 +9,5 @@
12.4
12.5 /* Unsubscribe from events. */
12.6
12.7 - [opcode(24)] void unsubscribe();
12.8 + [opcode(24)] void unsubscribe(in cap notifier);
12.9 };