# HG changeset patch # User Paul Boddie # Date 1626124696 -7200 # Node ID 929003b4e133c8353335f2be79b3a0c308d3f8ab # Parent b584c94d252f871d25721d8315eb1350d7e33cb9 Simplified notification functionality slightly, introducing a notify_others method, a special endpoint "role" enumeration, and removing special handling of any "source" notifier when performing notifications. diff -r b584c94d252f -r 929003b4e133 libfsserver/include/fsserver/notification.h --- a/libfsserver/include/fsserver/notification.h Mon Jul 12 22:52:52 2021 +0200 +++ b/libfsserver/include/fsserver/notification.h Mon Jul 12 23:18:16 2021 +0200 @@ -50,7 +50,9 @@ virtual ~NotificationSupport(); - virtual void notify(unsigned int endpoint, notify_flags_t flags, l4_cap_idx_t source=L4_INVALID_CAP); + virtual void notify(unsigned int endpoint, notify_flags_t flags); + + virtual void notify_others(unsigned int endpoint, notify_flags_t flags); virtual void subscribe(unsigned int endpoint, l4_cap_idx_t notifier, notify_flags_t flags); diff -r b584c94d252f -r 929003b4e133 libfsserver/include/fsserver/pipe_paging.h --- a/libfsserver/include/fsserver/pipe_paging.h Mon Jul 12 22:52:52 2021 +0200 +++ b/libfsserver/include/fsserver/pipe_paging.h Mon Jul 12 23:18:16 2021 +0200 @@ -69,14 +69,6 @@ virtual offset_t region_size() { return _size; } - /* Notification support customised for pipes. */ - - virtual void notify(bool writing, notify_flags_t flags); - - virtual void subscribe(bool writing, l4_cap_idx_t notifier, notify_flags_t flags); - - virtual void unsubscribe(bool writing, l4_cap_idx_t notifier); - /* Region management. */ virtual PageMapper *add_region(); @@ -88,6 +80,14 @@ /* Access management. */ virtual int closed(); + + /* Special values for various arrays. */ + + enum PipePagingRoles : unsigned int + { + READER = 0, + WRITER = 1, + }; }; // vim: tabstop=4 expandtab shiftwidth=4 diff -r b584c94d252f -r 929003b4e133 libfsserver/lib/generic/notification.cc --- a/libfsserver/lib/generic/notification.cc Mon Jul 12 22:52:52 2021 +0200 +++ b/libfsserver/lib/generic/notification.cc Mon Jul 12 23:18:16 2021 +0200 @@ -80,9 +80,9 @@ } } -/* Notify the other endpoint. */ +/* Notify a particular endpoint. */ -void NotificationSupport::notify(unsigned int endpoint, notify_flags_t flags, l4_cap_idx_t source) +void NotificationSupport::notify(unsigned int endpoint, notify_flags_t flags) { /* Notify the endpoint or hold any notification for potential future subscription. */ @@ -95,12 +95,6 @@ for (it = _notifiers[endpoint].begin(); it != _notifiers[endpoint].end(); it++) { - /* Avoid notifying the source of the notification if it is - present in the list. */ - - if (l4_is_valid_cap(source) && (*it == source)) - continue; - client_Notifier notifier(*it); notifier.notify(flags & _flags[endpoint]); @@ -111,6 +105,15 @@ _deferred[endpoint] = flags; } +/* Notify the other endpoints. */ + +void NotificationSupport::notify_others(unsigned int endpoint, notify_flags_t flags) +{ + for (unsigned int i = 0; i < _max_endpoints; i++) + if (i != endpoint) + notify(i, flags); +} + /* Release notifiers for each endpoint. */ void NotificationSupport::release_notifiers() diff -r b584c94d252f -r 929003b4e133 libfsserver/lib/pipes/pipe_pager.cc --- a/libfsserver/lib/pipes/pipe_pager.cc Mon Jul 12 22:52:52 2021 +0200 +++ b/libfsserver/lib/pipes/pipe_pager.cc Mon Jul 12 23:18:16 2021 +0200 @@ -59,7 +59,7 @@ /* Notify the other endpoint. */ - _paging->notify(_writing, NOTIFY_PEER_CLOSED); + _paging->notify_others(_writing ? PipePaging::WRITER : PipePaging::READER, NOTIFY_PEER_CLOSED); } /* Support paging. */ @@ -157,7 +157,8 @@ // NOTE: Perhaps employ a distinct event type for metadata updates. - _paging->notify(_writing, NOTIFY_CONTENT_AVAILABLE | NOTIFY_SPACE_AVAILABLE); + _paging->notify_others(_writing ? PipePaging::WRITER : PipePaging::READER, + NOTIFY_CONTENT_AVAILABLE | NOTIFY_SPACE_AVAILABLE); return L4_EOK; } @@ -170,13 +171,13 @@ /* Readers can subscribe to new data (at end), and pipe closed events. Writers can subscribe to new space and pipe closed events. */ - _paging->subscribe(_writing, notifier, flags); + _paging->subscribe(_writing ? PipePaging::WRITER : PipePaging::READER, notifier, flags); return L4_EOK; } long PipePager::unsubscribe(l4_cap_idx_t notifier) { - _paging->unsubscribe(_writing, notifier); + _paging->unsubscribe(_writing ? PipePaging::WRITER : PipePaging::READER, notifier); return L4_EOK; } diff -r b584c94d252f -r 929003b4e133 libfsserver/lib/pipes/pipe_paging.cc --- a/libfsserver/lib/pipes/pipe_paging.cc Mon Jul 12 22:52:52 2021 +0200 +++ b/libfsserver/lib/pipes/pipe_paging.cc Mon Jul 12 23:18:16 2021 +0200 @@ -43,29 +43,6 @@ _regions[i] = NULL; } -/* Subscribe to an endpoint's notifications using a notifier object. */ - -void PipePaging::subscribe(bool writing, l4_cap_idx_t notifier, notify_flags_t flags) -{ - NotificationSupport::subscribe(writing ? 1 : 0, notifier, flags); -} - -/* Unsubscribe from an endpoint's notifications. */ - -void PipePaging::unsubscribe(bool writing, l4_cap_idx_t notifier) -{ - NotificationSupport::unsubscribe(writing ? 1 : 0, notifier); -} - -/* Notify the other endpoint. */ - -void PipePaging::notify(bool writing, notify_flags_t flags) -{ - /* Let the writer notify the reader, and the other way round. */ - - NotificationSupport::notify(writing ? 0 : 1, flags); -} - /* Return whether one or more endpoints have detached. */ int PipePaging::closed() @@ -142,7 +119,7 @@ /* Let the writer notify the reader. */ - notify(true, NOTIFY_CONTENT_AVAILABLE); + notify_others(PipePaging::WRITER, NOTIFY_CONTENT_AVAILABLE); /* Return the next region's mapper. */ @@ -177,7 +154,7 @@ /* Let the reader notify the writer. */ - notify(false, NOTIFY_SPACE_AVAILABLE); + notify_others(PipePaging::READER, NOTIFY_SPACE_AVAILABLE); /* Return the next region's mapper. */