1.1 --- a/libfsclient/lib/src/file.cc Wed Mar 22 17:31:05 2023 +0100
1.2 +++ b/libfsclient/lib/src/file.cc Wed Mar 22 18:05:48 2023 +0100
1.3 @@ -633,6 +633,7 @@
1.4
1.5 void file_notify_close(file_notifier_t *notifier)
1.6 {
1.7 + notifier->obj->stop();
1.8 delete notifier->obj;
1.9 delete notifier;
1.10 }
2.1 --- a/libfsclient/lib/src/process.cc Wed Mar 22 17:31:05 2023 +0100
2.2 +++ b/libfsclient/lib/src/process.cc Wed Mar 22 18:05:48 2023 +0100
2.3 @@ -152,6 +152,7 @@
2.4
2.5 void process_notify_close(process_notifier_t *notifier)
2.6 {
2.7 + notifier->obj->stop();
2.8 delete notifier->obj;
2.9 delete notifier;
2.10 }
3.1 --- a/libnotifier/include/notifier/notifier.h Wed Mar 22 17:31:05 2023 +0100
3.2 +++ b/libnotifier/include/notifier/notifier.h Wed Mar 22 18:05:48 2023 +0100
3.3 @@ -88,6 +88,7 @@
3.4
3.5 ServerConfigs _configs;
3.6 bool _started = false;
3.7 + l4_cap_idx_t _irq = L4_INVALID_CAP;
3.8
3.9 /* Convenience method to access object state. */
3.10
3.11 @@ -104,6 +105,8 @@
3.12
3.13 virtual long start();
3.14
3.15 + virtual void stop();
3.16 +
3.17 virtual long subscribe(notifiable_t *object, notify_flags_t flags);
3.18
3.19 virtual long unsubscribe(notifiable_t *object);
4.1 --- a/libnotifier/lib/src/notifier.cc Wed Mar 22 17:31:05 2023 +0100
4.2 +++ b/libnotifier/lib/src/notifier.cc Wed Mar 22 18:05:48 2023 +0100
4.3 @@ -22,6 +22,8 @@
4.4 #include <map>
4.5 #include <mutex>
4.6
4.7 +#include <l4/sys/irq.h>
4.8 +
4.9 #include <ipc/cap_alloc.h>
4.10 #include <ipc/server.h>
4.11 #include <resource/resource_server.h>
4.12 @@ -81,12 +83,19 @@
4.13
4.14 ObjectNotifier::~ObjectNotifier()
4.15 {
4.16 + stop();
4.17 +
4.18 ServerConfigs::iterator it;
4.19
4.20 for (it = _configs.begin(); it != _configs.end(); it++)
4.21 delete *it;
4.22
4.23 _configs.clear();
4.24 +
4.25 + /* Handle deletion of the special task notifier. */
4.26 +
4.27 + if (this == _notifier)
4.28 + _notifier = NULL;
4.29 }
4.30
4.31
4.32 @@ -111,11 +120,28 @@
4.33 _configs.push_back(server.config());
4.34 _started = true;
4.35
4.36 + /* Retain the IRQ created for the server for control purposes. */
4.37 +
4.38 + _irq = server.config()->irq;
4.39 +
4.40 return L4_EOK;
4.41 }
4.42
4.43
4.44
4.45 +/* Stop the notifier. */
4.46 +
4.47 +void ObjectNotifier::stop()
4.48 +{
4.49 + if (l4_is_valid_cap(_irq))
4.50 + {
4.51 + l4_irq_trigger(_irq);
4.52 + _irq = L4_INVALID_CAP;
4.53 + }
4.54 +}
4.55 +
4.56 +
4.57 +
4.58 /* Return notification state for the given object or null state if no record
4.59 existed for the object. */
4.60
5.1 --- a/libresource/lib/src/resource_server.cc Wed Mar 22 17:31:05 2023 +0100
5.2 +++ b/libresource/lib/src/resource_server.cc Wed Mar 22 18:05:48 2023 +0100
5.3 @@ -130,7 +130,14 @@
5.4 l4_cap_idx_t thread, int separate_thread,
5.5 int finalisation, int auto_deletion)
5.6 {
5.7 - if (finalisation)
5.8 + /* Only invoke the finaliser where auto-deletion is employed. This assumes
5.9 + that a single configuration is in use and thus a single resource that can
5.10 + be managed in the server finalisation process. Where multiple
5.11 + configurations are involved with an IPC gate, server finalisation does not
5.12 + attempt to finalise all these configurations and associated resources, and
5.13 + it therefore makes more sense to perform such finalisation elsewhere. */
5.14 +
5.15 + if (auto_deletion)
5.16 config->finaliser = resource_thread_finaliser;
5.17
5.18 config->config_thread = separate_thread;