And that is totally wrong & broken
This commit is contained in:
+16
-21
@@ -127,6 +127,19 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void unlinkDrainableSubscriber(Subscriber *s) {
|
||||||
|
if (s->prev) {
|
||||||
|
s->prev->next = s->next;
|
||||||
|
}
|
||||||
|
if (s->next) {
|
||||||
|
s->next->prev = s->prev;
|
||||||
|
}
|
||||||
|
/* If we are the head, then we also need to reset the head */
|
||||||
|
if (drainableSubscribers == s) {
|
||||||
|
drainableSubscribers = s->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TopicTree(std::function<bool(Subscriber *, T &, IteratorFlags)> cb) : cb(cb) {
|
TopicTree(std::function<bool(Subscriber *, T &, IteratorFlags)> cb) : cb(cb) {
|
||||||
@@ -222,16 +235,7 @@ public:
|
|||||||
|
|
||||||
/* We also need to unlink us */
|
/* We also need to unlink us */
|
||||||
if (s->needsDrainage()) {
|
if (s->needsDrainage()) {
|
||||||
if (s->prev) {
|
unlinkDrainableSubscriber(s);
|
||||||
s->prev->next = s->next;
|
|
||||||
}
|
|
||||||
if (s->next) {
|
|
||||||
s->next->prev = s->prev;
|
|
||||||
}
|
|
||||||
/* If we are the head, then we also need to reset the head */
|
|
||||||
if (drainableSubscribers == s) {
|
|
||||||
drainableSubscribers = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete s;
|
delete s;
|
||||||
@@ -243,17 +247,8 @@ public:
|
|||||||
if (s->needsDrainage()) {
|
if (s->needsDrainage()) {
|
||||||
/* This function differs from drainImpl by properly unlinking
|
/* This function differs from drainImpl by properly unlinking
|
||||||
* the subscriber from drainableSubscribers. drainImpl does not. */
|
* the subscriber from drainableSubscribers. drainImpl does not. */
|
||||||
if (s->prev) {
|
unlinkDrainableSubscriber(s);
|
||||||
s->prev->next = s->next;
|
|
||||||
}
|
|
||||||
if (s->next) {
|
|
||||||
s->next->prev = s->prev;
|
|
||||||
}
|
|
||||||
/* If we are the head, then we also need to reset the head */
|
|
||||||
if (drainableSubscribers == s) {
|
|
||||||
drainableSubscribers = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This one always resets needsDrainage before it calls any cb's.
|
/* This one always resets needsDrainage before it calls any cb's.
|
||||||
* Otherwise we would stackoverflow when sending after publish but before drain. */
|
* Otherwise we would stackoverflow when sending after publish but before drain. */
|
||||||
drainImpl(s);
|
drainImpl(s);
|
||||||
|
|||||||
Reference in New Issue
Block a user