Never drain a closing socket from unsubscribeAll
This commit is contained in:
+3
-5
@@ -277,16 +277,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Can be called with nullptr, ignore it then */
|
/* Can be called with nullptr, ignore it then */
|
||||||
void unsubscribeAll(Subscriber *subscriber) {
|
void unsubscribeAll(Subscriber *subscriber, bool mayFlush = true) {
|
||||||
if (subscriber) {
|
if (subscriber) {
|
||||||
for (Topic *topic : subscriber->subscriptions) {
|
for (Topic *topic : subscriber->subscriptions) {
|
||||||
|
|
||||||
/* This is questionable; we are called mostly from socket close, so we will
|
/* We do not want to flush when closing a socket, it makes no sense to do so */
|
||||||
* potentially call drain callback with a closed socket, make sure to check there!
|
|
||||||
* Well it doesn't really matter since there are checks in uSockets but still! */
|
|
||||||
|
|
||||||
/* If this topic is triggered, drain the tree before we leave */
|
/* If this topic is triggered, drain the tree before we leave */
|
||||||
if (topic->triggered) {
|
if (mayFlush && topic->triggered) {
|
||||||
drain();
|
drain();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -154,7 +154,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure to unsubscribe from any pub/sub node at exit */
|
/* Make sure to unsubscribe from any pub/sub node at exit */
|
||||||
webSocketContextData->topicTree.unsubscribeAll(webSocketData->subscriber);
|
webSocketContextData->topicTree.unsubscribeAll(webSocketData->subscriber, false);
|
||||||
delete webSocketData->subscriber;
|
delete webSocketData->subscriber;
|
||||||
webSocketData->subscriber = nullptr;
|
webSocketData->subscriber = nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure to unsubscribe from any pub/sub node at exit */
|
/* Make sure to unsubscribe from any pub/sub node at exit */
|
||||||
webSocketContextData->topicTree.unsubscribeAll(webSocketData->subscriber);
|
webSocketContextData->topicTree.unsubscribeAll(webSocketData->subscriber, false);
|
||||||
delete webSocketData->subscriber;
|
delete webSocketData->subscriber;
|
||||||
webSocketData->subscriber = nullptr;
|
webSocketData->subscriber = nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,13 +65,6 @@ struct WebSocketContextData {
|
|||||||
/* We rely on writing to regular asyncSockets */
|
/* We rely on writing to regular asyncSockets */
|
||||||
auto *asyncSocket = (AsyncSocket<SSL> *) s->user;
|
auto *asyncSocket = (AsyncSocket<SSL> *) s->user;
|
||||||
|
|
||||||
/* We might be called from unsubscribeAll from close handler of a socket,
|
|
||||||
* so make sure to check if we are a closed socket before trying to send */
|
|
||||||
if (us_socket_is_closed(SSL, (struct us_socket_t *) s->user) || us_socket_is_shut_down(SSL, (struct us_socket_t *) s->user)) {
|
|
||||||
/* Return code means nothing, todo: remove it */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if we now have too much backpressure (todo: don't buffer up before check) */
|
/* Check if we now have too much backpressure (todo: don't buffer up before check) */
|
||||||
if (!maxBackpressure || (unsigned int) asyncSocket->getBufferedAmount() < maxBackpressure) {
|
if (!maxBackpressure || (unsigned int) asyncSocket->getBufferedAmount() < maxBackpressure) {
|
||||||
/* Pick uncompressed data track */
|
/* Pick uncompressed data track */
|
||||||
|
|||||||
Reference in New Issue
Block a user