# HG changeset patch # User Paul Boddie # Date 1625526113 -7200 # Node ID 07fdc0fbfdafc4a0e371a6494b39b6f83863a062 # Parent 637bdd44285e90076170ec83ecb139f24b2214ed Introduced accumulation of notifications and guarded transfer to file objects. diff -r 637bdd44285e -r 07fdc0fbfdaf libfsclient/include/fsclient/notifier.h --- a/libfsclient/include/fsclient/notifier.h Tue Jul 06 00:45:25 2021 +0200 +++ b/libfsclient/include/fsclient/notifier.h Tue Jul 06 01:01:53 2021 +0200 @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -31,12 +32,19 @@ +/* Collection types. */ + +typedef std::map FileNotifications; + + + /* An object for monitoring file event notifications. */ class FileNotifier { protected: std::list _affected; + FileNotifications _affected_flags; l4_cap_idx_t _thread = L4_INVALID_CAP; bool _started = false; diff -r 637bdd44285e -r 07fdc0fbfdaf libfsclient/lib/src/notifier.cc --- a/libfsclient/lib/src/notifier.cc Tue Jul 06 00:45:25 2021 +0200 +++ b/libfsclient/lib/src/notifier.cc Tue Jul 06 01:01:53 2021 +0200 @@ -100,9 +100,9 @@ { std::unique_lock guard(_lock); - /* Record the flags in the file object. */ + /* Record the flags for the file object. */ - file->notifications = flags; + _affected_flags[file] |= flags; _affected.push_back(file); /* Notify any waiting caller. */ @@ -193,6 +193,9 @@ { *file = _affected.front(); _affected.pop_front(); + + (*file)->notifications = _affected_flags[*file]; + _affected_flags.erase(*file); return L4_EOK; } else