]> granicus.if.org Git - curl/commitdiff
http2: Fix hanging paused stream
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
Fri, 4 Dec 2015 15:40:10 +0000 (00:40 +0900)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 8 Dec 2015 17:40:32 +0000 (18:40 +0100)
When NGHTTP2_ERR_PAUSE is returned from data_source_read_callback, we
might not process DATA frame fully.  Calling nghttp2_session_mem_recv()
again will continue to process DATA frame, but if there is no incoming
frames, then we have to call it again with 0-length data.  Without this,
on_stream_close callback will not be called, and stream could be hanged.

Bug: http://curl.haxx.se/mail/lib-2015-11/0103.html
Reported-by: Francisco Moraes
lib/http2.c

index c4f9a467b5d9d7af17eae3ea21d992a0a8f22c26..dae7f4a6fe2f3faf641b8aa2a694e22dd02b6163 100644 (file)
@@ -1136,6 +1136,15 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
 
       stream->pausedata = NULL;
       stream->pauselen = 0;
+
+      /* When NGHTTP2_ERR_PAUSE is returned from
+         data_source_read_callback, we might not process DATA frame
+         fully.  Calling nghttp2_session_mem_recv() again will
+         continue to process DATA frame, but if there is no incoming
+         frames, then we have to call it again with 0-length data.
+         Without this, on_stream_close callback will not be called,
+         and stream could be hanged. */
+      nghttp2_session_mem_recv(httpc->h2, NULL, 0);
     }
     DEBUGF(infof(data, "http2_recv: returns unpaused %zd bytes on stream %u\n",
                  nread, stream->stream_id));