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:44:56 +08:00
parent 2aa6f1bccd
commit d7fb6ad9cf
3 changed files with 10 additions and 5 deletions

View file

@ -1505,7 +1505,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)
{
@ -1530,7 +1530,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;
@ -1560,4 +1560,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

@ -1435,7 +1435,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

@ -1853,8 +1853,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)++);