summaryrefslogtreecommitdiff
path: root/src/basic/set.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-02-22 20:39:45 +0100
committerSven Eden <yamakuzure@gmx.net>2017-06-16 10:12:57 +0200
commit3c84247622c7d6ad51e7a49907995e3e48b5f472 (patch)
treec91e04a7402f333994887f4d79dd08526bfcb342 /src/basic/set.h
parent45e507a05750d43384bfbe90b8b22dfb5a1c5d2a (diff)
resolved: fix notification iteration logic when transactions are completed
When a transaction is complete, and we notify its owners, make sure we deal correctly with the requesters removing themselves from the list of owners while we continue iterating. This was previously already dealt with with transactions that require other transactions for DNSSEC purposes, fix this for other possibly transaction owners too now. Since iterating through "Set" objects is not safe regarding removal of entries from it, rework the logic to use two Sets, and move each entry we notified from one set to the other set before we dispatch the notification. This move operation requires no additional memory, and enables us to ensure that we don't notify any object twice. Fixes: #2676
Diffstat (limited to 'src/basic/set.h')
-rw-r--r--src/basic/set.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/basic/set.h b/src/basic/set.h
index f8e86478c..170f0c446 100644
--- a/src/basic/set.h
+++ b/src/basic/set.h
@@ -130,6 +130,9 @@ int set_put_strdupv(Set *s, char **l);
#define SET_FOREACH(e, s, i) \
for ((i) = ITERATOR_FIRST; set_iterate((s), &(i), (void**)&(e)); )
+#define SET_FOREACH_MOVE(e, d, s) \
+ for (; ({ e = set_first(s); assert_se(!e || set_move_one(d, s, e) >= 0); e; }); )
+
DEFINE_TRIVIAL_CLEANUP_FUNC(Set*, set_free);
DEFINE_TRIVIAL_CLEANUP_FUNC(Set*, set_free_free);