1.1 --- a/libfsserver/include/fsserver/notification.h Mon Jul 12 22:52:52 2021 +0200
1.2 +++ b/libfsserver/include/fsserver/notification.h Mon Jul 12 23:18:16 2021 +0200
1.3 @@ -50,7 +50,9 @@
1.4
1.5 virtual ~NotificationSupport();
1.6
1.7 - virtual void notify(unsigned int endpoint, notify_flags_t flags, l4_cap_idx_t source=L4_INVALID_CAP);
1.8 + virtual void notify(unsigned int endpoint, notify_flags_t flags);
1.9 +
1.10 + virtual void notify_others(unsigned int endpoint, notify_flags_t flags);
1.11
1.12 virtual void subscribe(unsigned int endpoint, l4_cap_idx_t notifier, notify_flags_t flags);
1.13
2.1 --- a/libfsserver/include/fsserver/pipe_paging.h Mon Jul 12 22:52:52 2021 +0200
2.2 +++ b/libfsserver/include/fsserver/pipe_paging.h Mon Jul 12 23:18:16 2021 +0200
2.3 @@ -69,14 +69,6 @@
2.4 virtual offset_t region_size()
2.5 { return _size; }
2.6
2.7 - /* Notification support customised for pipes. */
2.8 -
2.9 - virtual void notify(bool writing, notify_flags_t flags);
2.10 -
2.11 - virtual void subscribe(bool writing, l4_cap_idx_t notifier, notify_flags_t flags);
2.12 -
2.13 - virtual void unsubscribe(bool writing, l4_cap_idx_t notifier);
2.14 -
2.15 /* Region management. */
2.16
2.17 virtual PageMapper *add_region();
2.18 @@ -88,6 +80,14 @@
2.19 /* Access management. */
2.20
2.21 virtual int closed();
2.22 +
2.23 + /* Special values for various arrays. */
2.24 +
2.25 + enum PipePagingRoles : unsigned int
2.26 + {
2.27 + READER = 0,
2.28 + WRITER = 1,
2.29 + };
2.30 };
2.31
2.32 // vim: tabstop=4 expandtab shiftwidth=4
3.1 --- a/libfsserver/lib/generic/notification.cc Mon Jul 12 22:52:52 2021 +0200
3.2 +++ b/libfsserver/lib/generic/notification.cc Mon Jul 12 23:18:16 2021 +0200
3.3 @@ -80,9 +80,9 @@
3.4 }
3.5 }
3.6
3.7 -/* Notify the other endpoint. */
3.8 +/* Notify a particular endpoint. */
3.9
3.10 -void NotificationSupport::notify(unsigned int endpoint, notify_flags_t flags, l4_cap_idx_t source)
3.11 +void NotificationSupport::notify(unsigned int endpoint, notify_flags_t flags)
3.12 {
3.13 /* Notify the endpoint or hold any notification for potential future
3.14 subscription. */
3.15 @@ -95,12 +95,6 @@
3.16
3.17 for (it = _notifiers[endpoint].begin(); it != _notifiers[endpoint].end(); it++)
3.18 {
3.19 - /* Avoid notifying the source of the notification if it is
3.20 - present in the list. */
3.21 -
3.22 - if (l4_is_valid_cap(source) && (*it == source))
3.23 - continue;
3.24 -
3.25 client_Notifier notifier(*it);
3.26
3.27 notifier.notify(flags & _flags[endpoint]);
3.28 @@ -111,6 +105,15 @@
3.29 _deferred[endpoint] = flags;
3.30 }
3.31
3.32 +/* Notify the other endpoints. */
3.33 +
3.34 +void NotificationSupport::notify_others(unsigned int endpoint, notify_flags_t flags)
3.35 +{
3.36 + for (unsigned int i = 0; i < _max_endpoints; i++)
3.37 + if (i != endpoint)
3.38 + notify(i, flags);
3.39 +}
3.40 +
3.41 /* Release notifiers for each endpoint. */
3.42
3.43 void NotificationSupport::release_notifiers()
4.1 --- a/libfsserver/lib/pipes/pipe_pager.cc Mon Jul 12 22:52:52 2021 +0200
4.2 +++ b/libfsserver/lib/pipes/pipe_pager.cc Mon Jul 12 23:18:16 2021 +0200
4.3 @@ -59,7 +59,7 @@
4.4
4.5 /* Notify the other endpoint. */
4.6
4.7 - _paging->notify(_writing, NOTIFY_PEER_CLOSED);
4.8 + _paging->notify_others(_writing ? PipePaging::WRITER : PipePaging::READER, NOTIFY_PEER_CLOSED);
4.9 }
4.10
4.11 /* Support paging. */
4.12 @@ -157,7 +157,8 @@
4.13
4.14 // NOTE: Perhaps employ a distinct event type for metadata updates.
4.15
4.16 - _paging->notify(_writing, NOTIFY_CONTENT_AVAILABLE | NOTIFY_SPACE_AVAILABLE);
4.17 + _paging->notify_others(_writing ? PipePaging::WRITER : PipePaging::READER,
4.18 + NOTIFY_CONTENT_AVAILABLE | NOTIFY_SPACE_AVAILABLE);
4.19 return L4_EOK;
4.20 }
4.21
4.22 @@ -170,13 +171,13 @@
4.23 /* Readers can subscribe to new data (at end), and pipe closed events.
4.24 Writers can subscribe to new space and pipe closed events. */
4.25
4.26 - _paging->subscribe(_writing, notifier, flags);
4.27 + _paging->subscribe(_writing ? PipePaging::WRITER : PipePaging::READER, notifier, flags);
4.28 return L4_EOK;
4.29 }
4.30
4.31 long PipePager::unsubscribe(l4_cap_idx_t notifier)
4.32 {
4.33 - _paging->unsubscribe(_writing, notifier);
4.34 + _paging->unsubscribe(_writing ? PipePaging::WRITER : PipePaging::READER, notifier);
4.35 return L4_EOK;
4.36 }
4.37
5.1 --- a/libfsserver/lib/pipes/pipe_paging.cc Mon Jul 12 22:52:52 2021 +0200
5.2 +++ b/libfsserver/lib/pipes/pipe_paging.cc Mon Jul 12 23:18:16 2021 +0200
5.3 @@ -43,29 +43,6 @@
5.4 _regions[i] = NULL;
5.5 }
5.6
5.7 -/* Subscribe to an endpoint's notifications using a notifier object. */
5.8 -
5.9 -void PipePaging::subscribe(bool writing, l4_cap_idx_t notifier, notify_flags_t flags)
5.10 -{
5.11 - NotificationSupport::subscribe(writing ? 1 : 0, notifier, flags);
5.12 -}
5.13 -
5.14 -/* Unsubscribe from an endpoint's notifications. */
5.15 -
5.16 -void PipePaging::unsubscribe(bool writing, l4_cap_idx_t notifier)
5.17 -{
5.18 - NotificationSupport::unsubscribe(writing ? 1 : 0, notifier);
5.19 -}
5.20 -
5.21 -/* Notify the other endpoint. */
5.22 -
5.23 -void PipePaging::notify(bool writing, notify_flags_t flags)
5.24 -{
5.25 - /* Let the writer notify the reader, and the other way round. */
5.26 -
5.27 - NotificationSupport::notify(writing ? 0 : 1, flags);
5.28 -}
5.29 -
5.30 /* Return whether one or more endpoints have detached. */
5.31
5.32 int PipePaging::closed()
5.33 @@ -142,7 +119,7 @@
5.34
5.35 /* Let the writer notify the reader. */
5.36
5.37 - notify(true, NOTIFY_CONTENT_AVAILABLE);
5.38 + notify_others(PipePaging::WRITER, NOTIFY_CONTENT_AVAILABLE);
5.39
5.40 /* Return the next region's mapper. */
5.41
5.42 @@ -177,7 +154,7 @@
5.43
5.44 /* Let the reader notify the writer. */
5.45
5.46 - notify(false, NOTIFY_SPACE_AVAILABLE);
5.47 + notify_others(PipePaging::READER, NOTIFY_SPACE_AVAILABLE);
5.48
5.49 /* Return the next region's mapper. */
5.50