1.1 --- a/libfsserver/lib/generic/notification.cc Thu Feb 23 23:49:26 2023 +0100
1.2 +++ b/libfsserver/lib/generic/notification.cc Sat Feb 25 18:10:13 2023 +0100
1.3 @@ -51,10 +51,13 @@
1.4 unsigned int endpoint = _endpoints.size();
1.5 _endpoints.resize(endpoint + 1);
1.6
1.7 - /* Propagate deferred flags for new endpoints. */
1.8 + /* Propagate deferred flags and values for new endpoints. */
1.9
1.10 - if (_deferred)
1.11 - _endpoints[endpoint].deferred = _deferred;
1.12 + if (_deferred_flags)
1.13 + {
1.14 + _endpoints[endpoint].deferred_flags = _deferred_flags;
1.15 + _endpoints[endpoint].deferred_values = _deferred_values;
1.16 + }
1.17
1.18 *endpoint_number = endpoint;
1.19 return _subscribe(endpoint, notifier, flags, subscriber);
1.20 @@ -73,8 +76,11 @@
1.21
1.22 /* Propagate deferred flags for new endpoints. */
1.23
1.24 - if (_deferred)
1.25 - _endpoints[endpoint].deferred = _deferred;
1.26 + if (_deferred_flags)
1.27 + {
1.28 + _endpoints[endpoint].deferred_flags = _deferred_flags;
1.29 + _endpoints[endpoint].deferred_values = _deferred_values;
1.30 + }
1.31
1.32 return _subscribe(endpoint, notifier, flags, subscriber);
1.33 }
1.34 @@ -102,10 +108,11 @@
1.35
1.36 /* Send deferred conditions held from before subscription occurred. */
1.37
1.38 - if (ep.deferred)
1.39 + if (ep.deferred_flags)
1.40 {
1.41 - _notify(endpoint, ep.deferred);
1.42 - ep.deferred = 0;
1.43 + _notify(endpoint, ep.deferred_flags, ep.deferred_values);
1.44 + ep.deferred_flags = 0;
1.45 + ep.deferred_values = NOTIFY_VALUES_NULL;
1.46 }
1.47
1.48 /* Record the subscriber's notifier. */
1.49 @@ -143,21 +150,24 @@
1.50 if (ep.notifiers.empty())
1.51 {
1.52 ep.flags = 0;
1.53 - ep.deferred = 0;
1.54 + ep.deferred_flags = 0;
1.55 + ep.deferred_values = NOTIFY_VALUES_NULL;
1.56 }
1.57 }
1.58 }
1.59
1.60 /* Notify a particular endpoint. */
1.61
1.62 -void NotificationSupport::notify(unsigned int endpoint, notify_flags_t flags)
1.63 +void NotificationSupport::notify(unsigned int endpoint, notify_flags_t flags,
1.64 + notify_values_t values)
1.65 {
1.66 std::lock_guard<std::mutex> guard(_lock);
1.67
1.68 - _notify(endpoint, flags);
1.69 + _notify(endpoint, flags, values);
1.70 }
1.71
1.72 -void NotificationSupport::_notify(unsigned int endpoint, notify_flags_t flags)
1.73 +void NotificationSupport::_notify(unsigned int endpoint, notify_flags_t flags,
1.74 + notify_values_t values)
1.75 {
1.76 if (endpoint >= _endpoints.size())
1.77 return;
1.78 @@ -177,37 +187,47 @@
1.79 {
1.80 client_Notifier notifier(*it);
1.81
1.82 - notifier.notify(flags & ep.flags, (notify_values_t) NOTIFY_VALUES_NULL);
1.83 + notifier.notify(flags & ep.flags, values);
1.84 }
1.85 }
1.86 }
1.87 else
1.88 - ep.deferred = flags;
1.89 + {
1.90 + ep.deferred_flags = flags;
1.91 + ep.deferred_values = values;
1.92 + }
1.93 }
1.94
1.95 /* Notify all endpoints. */
1.96
1.97 -void NotificationSupport::notify_all(notify_flags_t flags)
1.98 +void NotificationSupport::notify_all(notify_flags_t flags, notify_values_t values)
1.99 {
1.100 std::lock_guard<std::mutex> guard(_lock);
1.101
1.102 for (unsigned int i = 0; i < _endpoints.size(); i++)
1.103 - _notify(i, flags);
1.104 + _notify(i, flags, values);
1.105
1.106 - _deferred |= flags;
1.107 + /* Accumulate flags, but only record the most recent values. */
1.108 +
1.109 + _deferred_flags |= flags;
1.110 + _deferred_values = values;
1.111 }
1.112
1.113 /* Notify the other endpoints. */
1.114
1.115 -void NotificationSupport::notify_others(unsigned int endpoint, notify_flags_t flags)
1.116 +void NotificationSupport::notify_others(unsigned int endpoint, notify_flags_t flags,
1.117 + notify_values_t values)
1.118 {
1.119 std::lock_guard<std::mutex> guard(_lock);
1.120
1.121 for (unsigned int i = 0; i < _endpoints.size(); i++)
1.122 if (i != endpoint)
1.123 - _notify(i, flags);
1.124 + _notify(i, flags, values);
1.125
1.126 - _deferred |= flags;
1.127 + /* Accumulate flags, but only record the most recent values. */
1.128 +
1.129 + _deferred_flags |= flags;
1.130 + _deferred_values = values;
1.131 }
1.132
1.133 /* Release notifiers for each endpoint. */
1.134 @@ -226,7 +246,8 @@
1.135
1.136 ep.notifiers.clear();
1.137 ep.flags = 0;
1.138 - ep.deferred = 0;
1.139 + ep.deferred_flags = 0;
1.140 + ep.deferred_values = NOTIFY_VALUES_NULL;
1.141 }
1.142 }
1.143