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

handle rx flow control active when consuming payload

https://github.com/warmcat/libwebsockets/issues/622
This commit is contained in:
Andy Green 2016-09-10 04:43:07 +08:00
parent b8199ba4ab
commit c15714f35a
3 changed files with 10 additions and 5 deletions

View file

@ -1455,7 +1455,7 @@ lws_remaining_packet_payload(struct lws *wsi)
* to expect in that state and can deal with it in bulk more efficiently.
*/
void
int
lws_payload_until_length_exhausted(struct lws *wsi, unsigned char **buf,
size_t *len)
{
@ -1480,7 +1480,7 @@ lws_payload_until_length_exhausted(struct lws *wsi, unsigned char **buf,
/* we want to leave 1 byte for the parser to handle properly */
if (avail <= 1)
return;
return 0;
avail--;
rx_ubuf = wsi->u.ws.rx_ubuf + LWS_PRE + wsi->u.ws.rx_ubuf_head;
@ -1510,4 +1510,6 @@ lws_payload_until_length_exhausted(struct lws *wsi, unsigned char **buf,
wsi->u.ws.rx_ubuf_head += avail;
wsi->u.ws.rx_packet_length -= avail;
*len -= avail;
return avail;
}

View file

@ -1587,7 +1587,7 @@ lws_client_interpret_server_handshake(struct lws *wsi);
LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_rx_sm(struct lws *wsi, unsigned char c);
LWS_EXTERN void
LWS_EXTERN int
lws_payload_until_length_exhausted(struct lws *wsi, unsigned char **buf, size_t *len);
LWS_EXTERN int LWS_WARN_UNUSED_RESULT

View file

@ -2062,8 +2062,11 @@ lws_interpret_incoming_packet(struct lws *wsi, unsigned char **buf, size_t len)
/* consume payload bytes efficiently */
if (wsi->lws_rx_parse_state ==
LWS_RXPS_PAYLOAD_UNTIL_LENGTH_EXHAUSTED)
lws_payload_until_length_exhausted(wsi, buf, &len);
LWS_RXPS_PAYLOAD_UNTIL_LENGTH_EXHAUSTED) {
m = lws_payload_until_length_exhausted(wsi, buf, &len);
if (wsi->rxflow_buffer)
wsi->rxflow_pos += m;
}
/* process the byte */
m = lws_rx_sm(wsi, *(*buf)++);