# HG changeset patch # User Paul Boddie # Date 1679504748 -3600 # Node ID c3799acf75b4db3bb8923ca9803a0123e78d7a4d # Parent b33673595ce04cd41d61cebd815eee2bf2b42a2e Introduced support for stopping a notifier. diff -r b33673595ce0 -r c3799acf75b4 libfsclient/lib/src/file.cc --- a/libfsclient/lib/src/file.cc Wed Mar 22 17:31:05 2023 +0100 +++ b/libfsclient/lib/src/file.cc Wed Mar 22 18:05:48 2023 +0100 @@ -633,6 +633,7 @@ void file_notify_close(file_notifier_t *notifier) { + notifier->obj->stop(); delete notifier->obj; delete notifier; } diff -r b33673595ce0 -r c3799acf75b4 libfsclient/lib/src/process.cc --- a/libfsclient/lib/src/process.cc Wed Mar 22 17:31:05 2023 +0100 +++ b/libfsclient/lib/src/process.cc Wed Mar 22 18:05:48 2023 +0100 @@ -152,6 +152,7 @@ void process_notify_close(process_notifier_t *notifier) { + notifier->obj->stop(); delete notifier->obj; delete notifier; } diff -r b33673595ce0 -r c3799acf75b4 libnotifier/include/notifier/notifier.h --- a/libnotifier/include/notifier/notifier.h Wed Mar 22 17:31:05 2023 +0100 +++ b/libnotifier/include/notifier/notifier.h Wed Mar 22 18:05:48 2023 +0100 @@ -88,6 +88,7 @@ ServerConfigs _configs; bool _started = false; + l4_cap_idx_t _irq = L4_INVALID_CAP; /* Convenience method to access object state. */ @@ -104,6 +105,8 @@ virtual long start(); + virtual void stop(); + virtual long subscribe(notifiable_t *object, notify_flags_t flags); virtual long unsubscribe(notifiable_t *object); diff -r b33673595ce0 -r c3799acf75b4 libnotifier/lib/src/notifier.cc --- a/libnotifier/lib/src/notifier.cc Wed Mar 22 17:31:05 2023 +0100 +++ b/libnotifier/lib/src/notifier.cc Wed Mar 22 18:05:48 2023 +0100 @@ -22,6 +22,8 @@ #include #include +#include + #include #include #include @@ -81,12 +83,19 @@ ObjectNotifier::~ObjectNotifier() { + stop(); + ServerConfigs::iterator it; for (it = _configs.begin(); it != _configs.end(); it++) delete *it; _configs.clear(); + + /* Handle deletion of the special task notifier. */ + + if (this == _notifier) + _notifier = NULL; } @@ -111,11 +120,28 @@ _configs.push_back(server.config()); _started = true; + /* Retain the IRQ created for the server for control purposes. */ + + _irq = server.config()->irq; + return L4_EOK; } +/* Stop the notifier. */ + +void ObjectNotifier::stop() +{ + if (l4_is_valid_cap(_irq)) + { + l4_irq_trigger(_irq); + _irq = L4_INVALID_CAP; + } +} + + + /* Return notification state for the given object or null state if no record existed for the object. */ diff -r b33673595ce0 -r c3799acf75b4 libresource/lib/src/resource_server.cc --- a/libresource/lib/src/resource_server.cc Wed Mar 22 17:31:05 2023 +0100 +++ b/libresource/lib/src/resource_server.cc Wed Mar 22 18:05:48 2023 +0100 @@ -130,7 +130,14 @@ l4_cap_idx_t thread, int separate_thread, int finalisation, int auto_deletion) { - if (finalisation) + /* Only invoke the finaliser where auto-deletion is employed. This assumes + that a single configuration is in use and thus a single resource that can + be managed in the server finalisation process. Where multiple + configurations are involved with an IPC gate, server finalisation does not + attempt to finalise all these configurations and associated resources, and + it therefore makes more sense to perform such finalisation elsewhere. */ + + if (auto_deletion) config->finaliser = resource_thread_finaliser; config->config_thread = separate_thread;