# HG changeset patch # User Paul Boddie # Date 1646950987 -3600 # Node ID c146c6d1802fe8f7395bd0ed1effe720be483836 # Parent fe6f07b146a278d327bf804e4cd626b3f4d5fd9b Removed unsubscribe operations because they were not functioning correctly and were causing failures, such as when directory reading client programs terminated before the threads providing directory listing data. The unsubscribe operation was accepting a notifier endpoint, following on from a subscribe operation providing the same endpoint. However, the received endpoints are considered as distinct capabilities and so unsubscribing fails to occur, with the latter endpoint not being recognised as the former. diff -r fe6f07b146a2 -r c146c6d1802f libfsclient/include/fsclient/notifier.h --- a/libfsclient/include/fsclient/notifier.h Wed Mar 09 18:13:17 2022 +0100 +++ b/libfsclient/include/fsclient/notifier.h Thu Mar 10 23:23:07 2022 +0100 @@ -93,8 +93,6 @@ virtual bool _transfer(FileNotificationState &state, file_t *file); - virtual void _unsubscribe(FileNotificationState &state, file_t *file); - public: virtual ~FileNotifier(); diff -r fe6f07b146a2 -r c146c6d1802f libfsclient/lib/src/notifier.cc --- a/libfsclient/lib/src/notifier.cc Wed Mar 09 18:13:17 2022 +0100 +++ b/libfsclient/lib/src/notifier.cc Thu Mar 10 23:23:07 2022 +0100 @@ -1,7 +1,7 @@ /* * File event notification support. * - * Copyright (C) 2021 Paul Boddie + * Copyright (C) 2021, 2022 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -221,14 +221,7 @@ if (state.is_null()) return -L4_EINVAL; - client_Notification notify(file->ref); - - long err = notify.unsubscribe(state.endpoint); - - if (err) - return err; - - _unsubscribe(state, file); + _state.erase(file); /* Remove the lock for updating file state. */ @@ -237,21 +230,6 @@ return L4_EOK; } -/* Remove file notification state from the notifier. */ - -void FileNotifier::_unsubscribe(FileNotificationState &state, file_t *file) -{ - /* Acquire the lock for updating file state. */ - - std::mutex &file_lock = _file_locks[file]; - std::unique_lock file_guard(file_lock); - - /* Remove file-specific state. */ - - ipc_cap_free_um(state.endpoint); - _state.erase(file); -} - /* Handle a notification event for a file. Ideally, this would be invoked by the diff -r fe6f07b146a2 -r c146c6d1802f libfsserver/include/fsserver/directory_resource.h --- a/libfsserver/include/fsserver/directory_resource.h Wed Mar 09 18:13:17 2022 +0100 +++ b/libfsserver/include/fsserver/directory_resource.h Thu Mar 10 23:23:07 2022 +0100 @@ -64,8 +64,6 @@ /* Notification methods. */ virtual long subscribe(l4_cap_idx_t endpoint, notify_flags_t flags); - - virtual long unsubscribe(l4_cap_idx_t endpoint); }; // vim: tabstop=4 expandtab shiftwidth=4 diff -r fe6f07b146a2 -r c146c6d1802f libfsserver/include/fsserver/file_pager.h --- a/libfsserver/include/fsserver/file_pager.h Wed Mar 09 18:13:17 2022 +0100 +++ b/libfsserver/include/fsserver/file_pager.h Thu Mar 10 23:23:07 2022 +0100 @@ -75,8 +75,6 @@ /* Notification methods. */ virtual long subscribe(l4_cap_idx_t endpoint, notify_flags_t flags); - - virtual long unsubscribe(l4_cap_idx_t endpoint); }; // vim: tabstop=4 expandtab shiftwidth=4 diff -r fe6f07b146a2 -r c146c6d1802f libfsserver/include/fsserver/notification.h --- a/libfsserver/include/fsserver/notification.h Wed Mar 09 18:13:17 2022 +0100 +++ b/libfsserver/include/fsserver/notification.h Thu Mar 10 23:23:07 2022 +0100 @@ -86,8 +86,6 @@ virtual unsigned int subscribe(l4_cap_idx_t notifier, notify_flags_t flags); virtual void subscribe(unsigned int endpoint, l4_cap_idx_t notifier, notify_flags_t flags); - - virtual void unsubscribe(unsigned int endpoint, l4_cap_idx_t notifier); }; // vim: tabstop=4 expandtab shiftwidth=4 diff -r fe6f07b146a2 -r c146c6d1802f libfsserver/include/fsserver/pipe_pager.h --- a/libfsserver/include/fsserver/pipe_pager.h Wed Mar 09 18:13:17 2022 +0100 +++ b/libfsserver/include/fsserver/pipe_pager.h Thu Mar 10 23:23:07 2022 +0100 @@ -77,8 +77,6 @@ /* Notification methods. */ virtual long subscribe(l4_cap_idx_t notifier, notify_flags_t flags); - - virtual long unsubscribe(l4_cap_idx_t notifier); }; // vim: tabstop=4 expandtab shiftwidth=4 diff -r fe6f07b146a2 -r c146c6d1802f libfsserver/lib/directories/directory_resource.cc --- a/libfsserver/lib/directories/directory_resource.cc Wed Mar 09 18:13:17 2022 +0100 +++ b/libfsserver/lib/directories/directory_resource.cc Thu Mar 10 23:23:07 2022 +0100 @@ -1,7 +1,7 @@ /* * A resource offering support for accessing directories. * - * Copyright (C) 2021 Paul Boddie + * Copyright (C) 2021, 2022 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -134,10 +134,4 @@ return L4_EOK; } -long DirectoryResource::unsubscribe(l4_cap_idx_t endpoint) -{ - _provider->unsubscribe(_endpoint, endpoint); - return L4_EOK; -} - // vim: tabstop=4 expandtab shiftwidth=4 diff -r fe6f07b146a2 -r c146c6d1802f libfsserver/lib/files/file_pager.cc --- a/libfsserver/lib/files/file_pager.cc Wed Mar 09 18:13:17 2022 +0100 +++ b/libfsserver/lib/files/file_pager.cc Thu Mar 10 23:23:07 2022 +0100 @@ -120,10 +120,4 @@ return L4_EOK; } -long FilePager::unsubscribe(l4_cap_idx_t endpoint) -{ - _provider->unsubscribe(_endpoint, endpoint); - return L4_EOK; -} - // vim: tabstop=4 expandtab shiftwidth=4 diff -r fe6f07b146a2 -r c146c6d1802f libfsserver/lib/generic/notification.cc --- a/libfsserver/lib/generic/notification.cc Wed Mar 09 18:13:17 2022 +0100 +++ b/libfsserver/lib/generic/notification.cc Thu Mar 10 23:23:07 2022 +0100 @@ -1,7 +1,7 @@ /* * Notification support. * - * Copyright (C) 2021 Paul Boddie + * Copyright (C) 2021, 2022 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -97,31 +97,6 @@ } } -/* Unsubscribe from an endpoint's notifications. */ - -void NotificationSupport::unsubscribe(unsigned int endpoint, l4_cap_idx_t notifier) -{ - std::lock_guard guard(_lock); - - if (endpoint >= _endpoints.size()) - return; - - NotificationEndpoint &ep = _endpoints[endpoint]; - NotifierSet::iterator it = ep.notifiers.find(notifier); - - if (it != ep.notifiers.end()) - { - ep.notifiers.erase(it); - ipc_cap_free_um(notifier); - - if (ep.notifiers.empty()) - { - ep.flags = 0; - ep.deferred = 0; - } - } -} - /* Notify a particular endpoint. */ void NotificationSupport::notify(unsigned int endpoint, notify_flags_t flags) diff -r fe6f07b146a2 -r c146c6d1802f libfsserver/lib/pipes/pipe_pager.cc --- a/libfsserver/lib/pipes/pipe_pager.cc Wed Mar 09 18:13:17 2022 +0100 +++ b/libfsserver/lib/pipes/pipe_pager.cc Thu Mar 10 23:23:07 2022 +0100 @@ -191,10 +191,4 @@ return L4_EOK; } -long PipePager::unsubscribe(l4_cap_idx_t notifier) -{ - _paging->unsubscribe(_writing ? PipePaging::WRITER : PipePaging::READER, notifier); - return L4_EOK; -} - // vim: tabstop=4 expandtab shiftwidth=4 diff -r fe6f07b146a2 -r c146c6d1802f libsystypes/idl/notification.idl --- a/libsystypes/idl/notification.idl Wed Mar 09 18:13:17 2022 +0100 +++ b/libsystypes/idl/notification.idl Thu Mar 10 23:23:07 2022 +0100 @@ -2,11 +2,8 @@ interface Notification { - /* Subscribe to events. */ + /* Subscribe to events. Unsubscribing is done via the peer returned by the + operation. */ [opcode(23)] void subscribe(in cap notifier, in notify_flags_t flags); - - /* Unsubscribe from events. */ - - [opcode(24)] void unsubscribe(in cap notifier); };