WSLPeer now prevents receiving data after close.
Used to spit error and report empty packets when connection was still half-closed (waiting for confirmation from other end).
This commit is contained in:
parent
78f1513928
commit
9afdb9dcd3
2 changed files with 4 additions and 1 deletions
|
@ -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) {
|
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;
|
struct WSLPeer::PeerData *peer_data = (struct WSLPeer::PeerData *)user_data;
|
||||||
if (!peer_data->valid) {
|
if (!peer_data->valid || peer_data->closing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WSLPeer *peer = (WSLPeer *)peer_data->peer;
|
WSLPeer *peer = (WSLPeer *)peer_data->peer;
|
||||||
|
@ -293,6 +293,7 @@ void WSLPeer::close(int p_code, String p_reason) {
|
||||||
CharString cs = p_reason.utf8();
|
CharString cs = p_reason.utf8();
|
||||||
wslay_event_queue_close(_data->ctx, p_code, (uint8_t *)cs.ptr(), cs.size());
|
wslay_event_queue_close(_data->ctx, p_code, (uint8_t *)cs.ptr(), cs.size());
|
||||||
wslay_event_send(_data->ctx);
|
wslay_event_send(_data->ctx);
|
||||||
|
_data->closing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_in_buffer.clear();
|
_in_buffer.clear();
|
||||||
|
|
|
@ -53,6 +53,7 @@ public:
|
||||||
bool destroy;
|
bool destroy;
|
||||||
bool valid;
|
bool valid;
|
||||||
bool is_server;
|
bool is_server;
|
||||||
|
bool closing;
|
||||||
void *obj;
|
void *obj;
|
||||||
void *peer;
|
void *peer;
|
||||||
Ref<StreamPeer> conn;
|
Ref<StreamPeer> conn;
|
||||||
|
@ -68,6 +69,7 @@ public:
|
||||||
id = 1;
|
id = 1;
|
||||||
ctx = NULL;
|
ctx = NULL;
|
||||||
obj = NULL;
|
obj = NULL;
|
||||||
|
closing = false;
|
||||||
peer = NULL;
|
peer = NULL;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue