http2: Fix bug that data to be drained are overwritten by pending "paused" data
This commit is contained in:
committed by
Daniel Stenberg
parent
d722138f29
commit
2ce2f03007
33
lib/http2.c
33
lib/http2.c
@@ -831,7 +831,22 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
|
|||||||
return ncopy;
|
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);
|
nread = MIN(len, stream->datalen);
|
||||||
memcpy(mem, stream->data, nread);
|
memcpy(mem, stream->data, nread);
|
||||||
|
|
||||||
@@ -851,22 +866,6 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
|
|||||||
(int)nread);
|
(int)nread);
|
||||||
return 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) {
|
else if(httpc->pause_stream_id) {
|
||||||
/* If a stream paused nghttp2_session_mem_recv previously, and has
|
/* If a stream paused nghttp2_session_mem_recv previously, and has
|
||||||
not processed all data, it still refers to the buffer in
|
not processed all data, it still refers to the buffer in
|
||||||
|
|||||||
Reference in New Issue
Block a user