From 7da88ce71c31dbc799dfa9bdd8171d09a6b80b19 Mon Sep 17 00:00:00 2001 From: uNetworkingAB <110806833+uNetworkingAB@users.noreply.github.com> Date: Wed, 1 Nov 2023 15:05:13 +0100 Subject: [PATCH] Do not free subscriber on last unsubscription --- src/WebSocket.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/WebSocket.h b/src/WebSocket.h index 23c9bbe..1eedc22 100644 --- a/src/WebSocket.h +++ b/src/WebSocket.h @@ -295,11 +295,7 @@ public: webSocketContextData->subscriptionHandler(this, topic, newCount, newCount + 1); } - /* Free us as subscribers if we unsubscribed from our last topic */ - if (ok && last) { - webSocketContextData->topicTree->freeSubscriber(webSocketData->subscriber); - webSocketData->subscriber = nullptr; - } + /* Leave us as subscribers even if we subscribe to nothing (last unsubscribed topic might miss its message otherwise) */ return ok; }