]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
http2: Fix busy loop when EOF is encountered
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
Sat, 13 Sep 2014 02:59:23 +0000 (11:59 +0900)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 13 Sep 2014 11:54:08 +0000 (13:54 +0200)
Previously we did not handle EOF from underlying transport socket and
wrongly just returned error code CURL_AGAIN from http2_recv, which
caused busy loop since socket has been closed.  This patch adds the
code to handle EOF situation and tells the upper layer that we got
EOF.

lib/http2.c

index 604514d71c7c090da40d64ec8dc22338bd0e544f..f86d3ebff1abf4dac88267d1d56b986a5500f3c4 100644 (file)
@@ -744,6 +744,12 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
   }
 
   infof(conn->data, "nread=%zd\n", nread);
+
+  if(nread == 0) {
+    failf(conn->data, "EOF");
+    return 0;
+  }
+
   rv = nghttp2_session_mem_recv(httpc->h2,
                                 (const uint8_t *)httpc->inbuf, nread);