1.1 --- a/libfsclient/include/fsclient/notifier.h Tue Jul 06 00:45:25 2021 +0200
1.2 +++ b/libfsclient/include/fsclient/notifier.h Tue Jul 06 01:01:53 2021 +0200
1.3 @@ -23,6 +23,7 @@
1.4
1.5 #include <condition_variable>
1.6 #include <list>
1.7 +#include <map>
1.8 #include <mutex>
1.9
1.10 #include <fsclient/file.h>
1.11 @@ -31,12 +32,19 @@
1.12
1.13
1.14
1.15 +/* Collection types. */
1.16 +
1.17 +typedef std::map<file_t *, notify_flags_t> FileNotifications;
1.18 +
1.19 +
1.20 +
1.21 /* An object for monitoring file event notifications. */
1.22
1.23 class FileNotifier
1.24 {
1.25 protected:
1.26 std::list<file_t *> _affected;
1.27 + FileNotifications _affected_flags;
1.28 l4_cap_idx_t _thread = L4_INVALID_CAP;
1.29 bool _started = false;
1.30
2.1 --- a/libfsclient/lib/src/notifier.cc Tue Jul 06 00:45:25 2021 +0200
2.2 +++ b/libfsclient/lib/src/notifier.cc Tue Jul 06 01:01:53 2021 +0200
2.3 @@ -100,9 +100,9 @@
2.4 {
2.5 std::unique_lock<std::mutex> guard(_lock);
2.6
2.7 - /* Record the flags in the file object. */
2.8 + /* Record the flags for the file object. */
2.9
2.10 - file->notifications = flags;
2.11 + _affected_flags[file] |= flags;
2.12 _affected.push_back(file);
2.13
2.14 /* Notify any waiting caller. */
2.15 @@ -193,6 +193,9 @@
2.16 {
2.17 *file = _affected.front();
2.18 _affected.pop_front();
2.19 +
2.20 + (*file)->notifications = _affected_flags[*file];
2.21 + _affected_flags.erase(*file);
2.22 return L4_EOK;
2.23 }
2.24 else