http2: if there is paused data, do not clear the drain field

This commit is contained in:
Daniel Stenberg 2015-05-11 15:54:50 +02:00
Родитель 522ca8c035
Коммит 3e8a5d88a5
1 изменённых файлов: 17 добавлений и 8 удалений

Просмотреть файл

@ -388,7 +388,9 @@ static int on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
if(nread < len) { if(nread < len) {
stream->pausedata = data + nread; stream->pausedata = data + nread;
stream->pauselen = len - nread; stream->pauselen = len - nread;
DEBUGF(infof(data_s, "NGHTTP2_ERR_PAUSE - out of buffer\n")); DEBUGF(infof(data_s, "NGHTTP2_ERR_PAUSE - %zu bytes out of buffer"
", stream %x\n",
len - nread, stream_id));
conn->proto.httpc.pause_stream_id = stream_id; conn->proto.httpc.pause_stream_id = stream_id;
return NGHTTP2_ERR_PAUSE; return NGHTTP2_ERR_PAUSE;
} }
@ -853,7 +855,7 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
infof(data, "http2_recv: %d bytes buffer at %p (stream %x)\n", infof(data, "http2_recv: %d bytes buffer at %p (stream %x)\n",
len, mem, stream->stream_id); len, mem, stream->stream_id);
if(data->state.drain) { if((data->state.drain) && stream->memlen) {
DEBUGF(infof(data, "http2_recv: DRAIN %zu bytes stream %x!! (%p => %p)\n", DEBUGF(infof(data, "http2_recv: DRAIN %zu bytes stream %x!! (%p => %p)\n",
stream->memlen, stream->stream_id, stream->memlen, stream->stream_id,
stream->mem, mem)); stream->mem, mem));
@ -881,8 +883,8 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
stream->pausedata = NULL; stream->pausedata = NULL;
stream->pauselen = 0; stream->pauselen = 0;
} }
infof(data, "http2_recv: returns %zd bytes from stream->data\n", infof(data, "http2_recv: returns unpaused %zd bytes on stream %x\n",
nread); nread, stream->stream_id);
return nread; return nread;
} }
else if(httpc->pause_stream_id) { else if(httpc->pause_stream_id) {
@ -967,12 +969,19 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
} }
if(stream->memlen) { if(stream->memlen) {
ssize_t retlen = stream->memlen; ssize_t retlen = stream->memlen;
infof(data, "http2_recv: returns %zd for stream %x (%zu/%zu)\n", infof(data, "http2_recv: returns %zd for stream %x\n",
retlen, stream->stream_id, retlen, stream->stream_id);
len, stream->len);
data->state.drain = 0; /* this stream is hereby drained */
stream->memlen = 0; stream->memlen = 0;
if(httpc->pause_stream_id == stream->stream_id) {
/* data for this stream is returned now, but this stream caused a pause
already so we need it called again asap */
DEBUGF(infof(data, "Data returned for PAUSED stream %x\n",
stream->stream_id));
}
else
data->state.drain = 0; /* this stream is hereby drained */
return retlen; return retlen;
} }
/* If stream is closed, return 0 to signal the http routine to close /* If stream is closed, return 0 to signal the http routine to close