summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-12-22 12:32:52 +0100
committerGitHub <noreply@github.com>2019-12-22 12:32:52 +0100
commite4ecfe90f92a67304e5a2b27af94e6be224eb6c6 (patch)
tree499bec92655578f6dd5b394c1ddb8ffb6bda449e /modules
parent2f2724a40f5862694c7a729b20e2db0d74ae3265 (diff)
parent9afdb9dcd3d08dd287fdf9e0db3de07f8595626a (diff)
Merge pull request #34515 from Faless/ws/closing_ws
WSLPeer now prevents receiving data after close.
Diffstat (limited to 'modules')
-rw-r--r--modules/websocket/wsl_peer.cpp3
-rw-r--r--modules/websocket/wsl_peer.h2
2 files changed, 4 insertions, 1 deletions
diff --git a/modules/websocket/wsl_peer.cpp b/modules/websocket/wsl_peer.cpp
index 9d610109ed..a86bcd1404 100644
--- a/modules/websocket/wsl_peer.cpp
+++ b/modules/websocket/wsl_peer.cpp
@@ -142,7 +142,7 @@ int wsl_genmask_callback(wslay_event_context_ptr ctx, uint8_t *buf, size_t len,
void wsl_msg_recv_callback(wslay_event_context_ptr ctx, const struct wslay_event_on_msg_recv_arg *arg, void *user_data) {
struct WSLPeer::PeerData *peer_data = (struct WSLPeer::PeerData *)user_data;
- if (!peer_data->valid) {
+ if (!peer_data->valid || peer_data->closing) {
return;
}
WSLPeer *peer = (WSLPeer *)peer_data->peer;
@@ -293,6 +293,7 @@ void WSLPeer::close(int p_code, String p_reason) {
CharString cs = p_reason.utf8();
wslay_event_queue_close(_data->ctx, p_code, (uint8_t *)cs.ptr(), cs.size());
wslay_event_send(_data->ctx);
+ _data->closing = true;
}
_in_buffer.clear();
diff --git a/modules/websocket/wsl_peer.h b/modules/websocket/wsl_peer.h
index 01ad250468..a0242d120f 100644
--- a/modules/websocket/wsl_peer.h
+++ b/modules/websocket/wsl_peer.h
@@ -53,6 +53,7 @@ public:
bool destroy;
bool valid;
bool is_server;
+ bool closing;
void *obj;
void *peer;
Ref<StreamPeer> conn;
@@ -68,6 +69,7 @@ public:
id = 1;
ctx = NULL;
obj = NULL;
+ closing = false;
peer = NULL;
}
};