Skip to content

Commit 88eb7b7

Browse files
fix(ws): ensure client parser handles control frames internally
The client-side bulk data handling optimization incorrectly bypassed the internal state machine for control frames (PING, PONG, CLOSE) when they carried a payload. This caused these frames to be passed to the user callback as LWS_CALLBACK_CLIENT_RECEIVE data, preventing the library from handling them correctly (e.g., auto-replying to PING). This patch forces the parser to fallback to the byte-by-byte state machine (lws_ws_client_rx_sm) whenever a control frame is detected (opcode & 8), even if the parser is in the payload state. This ensures control frames are processed correctly by the library.
1 parent 46df866 commit 88eb7b7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/roles/ws/client-parser-ws.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ lws_ws_client_rx_parser_block(struct lws *wsi, const uint8_t **buf, size_t *len)
111111
* We can process headers and control frames byte-by-byte
112112
* using the original state machine.
113113
*/
114-
if (wsi->lws_rx_parse_state != LWS_RXPS_WS_FRAME_PAYLOAD) {
114+
if (wsi->lws_rx_parse_state != LWS_RXPS_WS_FRAME_PAYLOAD ||
115+
(wsi->ws->opcode & 8)) {
115116
hpr = lws_ws_client_rx_sm(wsi, *(*buf));
116117
if (hpr != LWS_HPI_RET_HANDLED)
117118
return hpr;

0 commit comments

Comments
 (0)