Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ws: handle reads before EAGAIN better #10856

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/ws.c
Expand Up @@ -425,10 +425,10 @@ CURL_EXTERN CURLcode curl_ws_recv(struct Curl_easy *data, void *buffer,
size_t datalen;
unsigned int recvflags;

if(!wsp->stillblen) {
if(!wsp->stillblen || (result == CURLE_AGAIN)) {
/* try to get more data */
size_t n;
result = curl_easy_recv(data, data->state.buffer,
result = curl_easy_recv(data, &data->state.buffer[wsp->stillblen],
data->set.buffer_size, &n);
bagder marked this conversation as resolved.
Show resolved Hide resolved
if(result)
return result;
Expand All @@ -438,19 +438,19 @@ CURL_EXTERN CURLcode curl_ws_recv(struct Curl_easy *data, void *buffer,
return CURLE_GOT_NOTHING;
}
wsp->stillb = data->state.buffer;
wsp->stillblen = n;
wsp->stillblen += n;
}

infof(data, "WS: %u bytes left to decode", (int)wsp->stillblen);
infof(data, "WS: %zu bytes left to decode", wsp->stillblen);
if(!wsp->frame.bytesleft) {
size_t headlen;
curl_off_t oleft;
/* detect new frame */
result = ws_decode(data, (unsigned char *)wsp->stillb, wsp->stillblen,
&headlen, &datalen, &oleft, &recvflags);
if(result == CURLE_AGAIN)
/* a packet fragment only */
break;
/* a packet fragment only, loop and try reading more */
continue;
else if(result)
return result;
if(datalen > buflen) {
Expand Down