aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2015-05-07 23:19:08 +0900
committerDaniel Stenberg <daniel@haxx.se>2015-05-18 08:57:18 +0200
commit2ce2f03007cca9e3d8cc1b481ae7c4489c111741 (patch)
tree8deaae9345f4ff391c90f6ef53a9406bcb5583c4 /lib
parentd722138f29bda9386798fbd67c23a874f8992463 (diff)
http2: Fix bug that data to be drained are overwritten by pending "paused" data
Diffstat (limited to 'lib')
-rw-r--r--lib/http2.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/lib/http2.c b/lib/http2.c
index e9eb81180..789f76a85 100644
--- a/lib/http2.c
+++ b/lib/http2.c
@@ -831,7 +831,22 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
return ncopy;
}
- if(stream->data) {
+ infof(data, "http2_recv: %d bytes buffer at %p (stream %x)\n",
+ len, mem, stream->stream_id);
+
+ if(data->state.drain) {
+ DEBUGF(infof(data, "http2_recv: DRAIN %zu bytes stream %x!! (%p => %p)\n",
+ stream->memlen, stream->stream_id,
+ stream->mem, mem));
+ if(mem != stream->mem) {
+ /* if we didn't get the same buffer this time, we must move the data to
+ the beginning */
+ memmove(mem, stream->mem, stream->memlen);
+ stream->len = len - stream->memlen;
+ stream->mem = mem;
+ }
+ }
+ else if(stream->data) {
nread = MIN(len, stream->datalen);
memcpy(mem, stream->data, nread);
@@ -851,22 +866,6 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
(int)nread);
return nread;
}
-
- infof(data, "http2_recv: %d bytes buffer at %p (stream %x)\n",
- len, mem, stream->stream_id);
-
- if(data->state.drain) {
- DEBUGF(infof(data, "http2_recv: DRAIN %zu bytes stream %x!! (%p => %p)\n",
- stream->memlen, stream->stream_id,
- stream->mem, mem));
- if(mem != stream->mem) {
- /* if we didn't get the same buffer this time, we must move the data to
- the beginning */
- memmove(mem, stream->mem, stream->memlen);
- stream->len = len - stream->memlen;
- stream->mem = mem;
- }
- }
else if(httpc->pause_stream_id) {
/* If a stream paused nghttp2_session_mem_recv previously, and has
not processed all data, it still refers to the buffer in