浏览代码

[WS] Fix peer stuck in CLOSING state

This was due by the buffer being cleared on close (including in closing
state) preventing further reads.

This commit changes the close logic to only clear the buffer when the
peer connection has been fully closed (acknowledged by the other end, or
closed due to a "broken" connection).
Fabio Alessandrelli 7 月之前
父节点
当前提交
81181c5941
共有 1 个文件被更改,包括 6 次插入4 次删除
  1. 6 4
      modules/websocket/wsl_peer.cpp

+ 6 - 4
modules/websocket/wsl_peer.cpp

@@ -860,10 +860,12 @@ void WSLPeer::close(int p_code, String p_reason) {
 		}
 	}
 
-	heartbeat_waiting = false;
-	in_buffer.clear();
-	packet_buffer.resize(0);
-	pending_message.clear();
+	if (ready_state == STATE_CLOSED) {
+		heartbeat_waiting = false;
+		in_buffer.clear();
+		packet_buffer.resize(0);
+		pending_message.clear();
+	}
 }
 
 IPAddress WSLPeer::get_connected_host() const {