Skip to content

Commit

Permalink
pmd: revert #3014 and drain extensions before next ssl read
Browse files Browse the repository at this point in the history
  • Loading branch information
lonnywong authored and lws-team committed Nov 24, 2023
1 parent cd6ce19 commit 8d40798
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
14 changes: 12 additions & 2 deletions lib/roles/ws/ops-ws.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ lws_ws_rx_sm(struct lws *wsi, char already_processed, unsigned char c)
}

#if !defined(LWS_WITHOUT_EXTENSIONS)
if (!lin && !(already_processed & ALREADY_PROCESSED_FULL_DRAINING))
if (!lin)
break;
#endif

Expand Down Expand Up @@ -1223,8 +1223,18 @@ rops_handle_POLLIN_ws(struct lws_context_per_thread *pt, struct lws *wsi,
else
pending = pending > wsi->a.context->pt_serv_buf_size ?
wsi->a.context->pt_serv_buf_size : pending;
if (--sanity)
if (--sanity) {
#if !defined(LWS_WITHOUT_EXTENSIONS)
while (wsi->ws->rx_draining_ext) {
// RX Extension needs to be drained before next read
n = lws_ws_rx_sm(wsi, ALREADY_PROCESSED_IGNORE_CHAR, 0);
if (n < 0) {
return LWS_HPI_RET_PLEASE_CLOSE_ME;
}
}
#endif
goto read;
}
else
/*
* Something has gone wrong, we are spinning...
Expand Down
1 change: 0 additions & 1 deletion lib/roles/ws/private-lib-roles-ws.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ enum lws_websocket_opcodes_07 {

#define ALREADY_PROCESSED_IGNORE_CHAR 1
#define ALREADY_PROCESSED_NO_CB 2
#define ALREADY_PROCESSED_FULL_DRAINING 4

#if !defined(LWS_WITHOUT_EXTENSIONS)
struct lws_vhost_role_ws {
Expand Down
2 changes: 1 addition & 1 deletion lib/roles/ws/server-ws.c
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ lws_parse_ws(struct lws *wsi, unsigned char **buf, size_t len)
wsi->ws->rx_draining_ext);
#endif
m = lws_ws_rx_sm(wsi, ALREADY_PROCESSED_IGNORE_CHAR |
ALREADY_PROCESSED_NO_CB | ALREADY_PROCESSED_FULL_DRAINING, 0);
ALREADY_PROCESSED_NO_CB, 0);
}

if (m < 0) {
Expand Down

0 comments on commit 8d40798

Please sign in to comment.