1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

rxflow: fix second draining path

This commit is contained in:
Andy Green 2017-11-05 07:10:53 +08:00
parent bc6f8179c6
commit d2ec329531
2 changed files with 19 additions and 8 deletions

View file

@ -1504,14 +1504,12 @@ handle_first:
* if there's no protocol max frame size given, we are
* supposed to default to context->pt_serv_buf_size
*/
if (!wsi->protocol->rx_buffer_size &&
wsi->u.ws.rx_ubuf_head != wsi->context->pt_serv_buf_size)
break;
else
if (wsi->protocol->rx_buffer_size &&
wsi->u.ws.rx_ubuf_head !=
wsi->protocol->rx_buffer_size)
if (wsi->protocol->rx_buffer_size &&
wsi->u.ws.rx_ubuf_head != wsi->protocol->rx_buffer_size)
break;
/* spill because we filled our rx buffer */

View file

@ -2867,18 +2867,31 @@ lws_interpret_incoming_packet(struct lws *wsi, unsigned char **buf, size_t len)
/* account for what we're using in rxflow buffer */
if (wsi->rxflow_buffer) {
wsi->rxflow_pos++;
assert(wsi->rxflow_pos <= wsi->rxflow_len);
if (wsi->rxflow_pos > wsi->rxflow_len) {
lwsl_err("bumped rxflow buffer too far (%d / %d)", wsi->rxflow_pos, wsi->rxflow_len);
assert(0);
}
}
/* consume payload bytes efficiently */
if (
wsi->lws_rx_parse_state ==
if (wsi->lws_rx_parse_state ==
LWS_RXPS_PAYLOAD_UNTIL_LENGTH_EXHAUSTED) {
m = lws_payload_until_length_exhausted(wsi, buf, &len);
if (wsi->rxflow_buffer)
wsi->rxflow_pos += m;
}
if (wsi->rxflow_buffer && wsi->rxflow_pos == wsi->rxflow_len) {
lwsl_debug("%s: %p flow buf: drained\n", __func__, wsi);
lws_free_set_NULL(wsi->rxflow_buffer);
/* having drained the rxflow buffer, can rearm POLLIN */
#ifdef LWS_NO_SERVER
m =
#endif
_lws_rx_flow_control(wsi);
/* m ignored, needed for NO_SERVER case */
}
/* process the byte */
m = lws_rx_sm(wsi, *(*buf)++);
if (m < 0)