Skip to content

Commit

Permalink
HTTP/2: Fix infinite loop in readwrite_data()
Browse files Browse the repository at this point in the history
To prevent infinite loop in readwrite_data() function when stream is
reset before any response body comes, reset closed flag to false once
it is evaluated to true.
  • Loading branch information
tatsuhiro-t authored and bagder committed Aug 3, 2014
1 parent 4d4dd7a commit 67920e1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/http2.c
Expand Up @@ -668,6 +668,9 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
(void)sockindex; /* we always do HTTP2 on sockindex 0 */

if(httpc->closed) {
/* Reset to FALSE to prevent infinite loop in readwrite_data
function. */
httpc->closed = FALSE;
return 0;
}

Expand Down Expand Up @@ -747,6 +750,9 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
/* If stream is closed, return 0 to signal the http routine to close
the connection */
if(httpc->closed) {
/* Reset to FALSE to prevent infinite loop in readwrite_data
function. */
httpc->closed = FALSE;
return 0;
}
*err = CURLE_AGAIN;
Expand Down

0 comments on commit 67920e1

Please sign in to comment.