Fix WebSocket::close being called in close handler (#1320)

This commit is contained in:
Alex Hultman
2021-08-29 21:49:18 +02:00
committed by GitHub
parent 644f3c5ea8
commit 030d113710
+13 -2
View File
@@ -53,8 +53,19 @@ public:
using Super::getRemoteAddressAsText;
using Super::getNativeHandle;
/* Simple, immediate close of the socket. Emits close event */
using Super::close;
/* WebSocket close cannot be an alias to AsyncSocket::close since
* we need to check first if it was shut down by remote peer */
us_socket_t *close() {
if (us_socket_is_closed(SSL, (us_socket_t *) this)) {
return nullptr;
}
WebSocketData *webSocketData = (WebSocketData *) Super::getAsyncSocketData();
if (webSocketData->isShuttingDown) {
return nullptr;
}
return us_socket_close(SSL, (us_socket_t *) this, 0, nullptr);
}
enum SendStatus : int {
BACKPRESSURE,