Commit c70cfe64 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Fix DATA is not consumed if nghttp2_http_on_data_chunk failed

This commit fixes the bug that DATA is not consumed if
nghttp2_http_on_data_chunk is failed.  It also simplify the handling
of missing stream in NGHTTP2_IB_READ_DATA state.
parent 693fba3b
...@@ -5739,6 +5739,14 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in, ...@@ -5739,6 +5739,14 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
break; break;
case NGHTTP2_IB_READ_DATA: case NGHTTP2_IB_READ_DATA:
stream = nghttp2_session_get_stream(session, iframe->frame.hd.stream_id);
if (!stream) {
busy = 1;
iframe->state = NGHTTP2_IB_IGN_DATA;
break;
}
DEBUGF(fprintf(stderr, "recv: [IB_READ_DATA]\n")); DEBUGF(fprintf(stderr, "recv: [IB_READ_DATA]\n"));
readlen = inbound_frame_payload_readlen(iframe, in, last); readlen = inbound_frame_payload_readlen(iframe, in, last);
...@@ -5756,9 +5764,6 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in, ...@@ -5756,9 +5764,6 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
return rv; return rv;
} }
stream =
nghttp2_session_get_stream(session, iframe->frame.hd.stream_id);
if (stream) {
rv = session_update_recv_stream_window_size( rv = session_update_recv_stream_window_size(
session, stream, readlen, session, stream, readlen,
iframe->payloadleft || iframe->payloadleft ||
...@@ -5787,9 +5792,18 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in, ...@@ -5787,9 +5792,18 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
if (data_readlen > 0) { if (data_readlen > 0) {
if (session_enforce_http_messaging(session)) { if (session_enforce_http_messaging(session)) {
if (nghttp2_http_on_data_chunk(stream, data_readlen) != 0) { if (nghttp2_http_on_data_chunk(stream, data_readlen) != 0) {
rv = nghttp2_session_add_rst_stream(session, if (session->opt_flags & NGHTTP2_OPTMASK_NO_AUTO_WINDOW_UPDATE) {
iframe->frame.hd.stream_id, /* Consume all data for connection immediately here */
NGHTTP2_PROTOCOL_ERROR); rv = session_update_connection_consumed_size(session,
data_readlen);
if (nghttp2_is_fatal(rv)) {
return rv;
}
}
rv = nghttp2_session_add_rst_stream(
session, iframe->frame.hd.stream_id, NGHTTP2_PROTOCOL_ERROR);
if (nghttp2_is_fatal(rv)) { if (nghttp2_is_fatal(rv)) {
return rv; return rv;
} }
...@@ -5811,15 +5825,6 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in, ...@@ -5811,15 +5825,6 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
} }
} }
} }
} else if (session->opt_flags & NGHTTP2_OPTMASK_NO_AUTO_WINDOW_UPDATE) {
/* stream was closed or does not exist. Consume all data
for connection immediately here */
rv = session_update_connection_consumed_size(session, readlen);
if (nghttp2_is_fatal(rv)) {
return rv;
}
}
} }
if (iframe->payloadleft) { if (iframe->payloadleft) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment