1.1 --- a/libfsserver/lib/pipes/pipe_paging.cc Fri Jul 09 00:15:29 2021 +0200
1.2 +++ b/libfsserver/lib/pipes/pipe_paging.cc Fri Jul 09 23:52:49 2021 +0200
1.3 @@ -47,7 +47,6 @@
1.4
1.5 for (unsigned int i = 0; i < 2; i++)
1.6 {
1.7 - _notifiers[i] = L4_INVALID_CAP;
1.8 _flags[i] = 0;
1.9 _deferred[i] = 0;
1.10 }
1.11 @@ -59,10 +58,7 @@
1.12 {
1.13 int i = writing ? 1 : 0;
1.14
1.15 - if (l4_is_valid_cap(_notifiers[i]))
1.16 - unsubscribe(writing);
1.17 -
1.18 - _notifiers[i] = notifier;
1.19 + _notifiers[i].insert(notifier);
1.20 _flags[i] = flags;
1.21
1.22 /* Send deferred conditions on behalf of the other endpoint held before
1.23 @@ -77,16 +73,17 @@
1.24
1.25 /* Unsubscribe from an endpoint's notifications. */
1.26
1.27 -void PipePaging::unsubscribe(bool writing)
1.28 +void PipePaging::unsubscribe(bool writing, l4_cap_idx_t notifier)
1.29 {
1.30 int i = writing ? 1 : 0;
1.31 + std::set<l4_cap_idx_t>::iterator it = _notifiers[i].find(notifier);
1.32
1.33 - if (l4_is_valid_cap(_notifiers[i]))
1.34 + if (it != _notifiers[i].end())
1.35 {
1.36 - ipc_cap_free_um(_notifiers[i]);
1.37 - _notifiers[i] = L4_INVALID_CAP;
1.38 + _notifiers[i].erase(it);
1.39 _flags[i] = 0;
1.40 _deferred[i] = 0;
1.41 + ipc_cap_free_um(notifier);
1.42 }
1.43 }
1.44
1.45 @@ -101,13 +98,18 @@
1.46 /* Notify the other endpoint or hold any notification for potential future
1.47 subscription. */
1.48
1.49 - if (l4_is_valid_cap(_notifiers[i]))
1.50 + if (!_notifiers[i].empty())
1.51 {
1.52 if (flags & _flags[i])
1.53 {
1.54 - client_Notifier notifier(_notifiers[i]);
1.55 + std::set<l4_cap_idx_t>::iterator it;
1.56
1.57 - notifier.notify(flags & _flags[i]);
1.58 + for (it = _notifiers[i].begin(); it != _notifiers[i].end(); it++)
1.59 + {
1.60 + client_Notifier notifier(*it);
1.61 +
1.62 + notifier.notify(flags & _flags[i]);
1.63 + }
1.64 }
1.65 }
1.66 else
1.67 @@ -156,11 +158,12 @@
1.68
1.69 for (unsigned int i = 0; i < 2; i++)
1.70 {
1.71 - if (l4_is_valid_cap(_notifiers[i]))
1.72 - {
1.73 - ipc_cap_free_um(_notifiers[i]);
1.74 - _notifiers[i] = L4_INVALID_CAP;
1.75 - }
1.76 + std::set<l4_cap_idx_t>::iterator it;
1.77 +
1.78 + for (it = _notifiers[i].begin(); it != _notifiers[i].end(); it++)
1.79 + ipc_cap_free_um(*it);
1.80 +
1.81 + _notifiers[i].clear();
1.82 }
1.83
1.84 /* Delete the page collection and related objects. */