diff --git a/src/TopicTree.h b/src/TopicTree.h index 73eef97..a837128 100644 --- a/src/TopicTree.h +++ b/src/TopicTree.h @@ -252,6 +252,11 @@ public: /* This one always resets needsDrainage before it calls any cb's. * Otherwise we would stackoverflow when sending after publish but before drain. */ drainImpl(s); + + /* If we drained last subscriber, also clear outgoingMessages */ + if (!drainableSubscribers) { + outgoingMessages.clear(); + } } }