Don't call on_frame_recv_callback after stream close or being closed

This commit is contained in:
Tatsuhiro Tsujikawa 2014-03-13 22:49:37 +09:00
parent d07bb1ddff
commit 0fa4779d38
1 changed files with 18 additions and 14 deletions

View File

@ -2286,19 +2286,22 @@ static int session_after_header_block_received(nghttp2_session *session)
nghttp2_frame *frame = &session->iframe.frame; nghttp2_frame *frame = &session->iframe.frame;
nghttp2_stream *stream; nghttp2_stream *stream;
/* We call on_frame_recv_callback regardless of the existence of /* We don't call on_frame_recv_callback if stream has been closed
stream */ already or being closed. */
stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
if(!stream || stream->state == NGHTTP2_STREAM_CLOSING) {
return 0;
}
rv = nghttp2_session_call_on_frame_received(session, frame); rv = nghttp2_session_call_on_frame_received(session, frame);
if(nghttp2_is_fatal(rv)) { if(nghttp2_is_fatal(rv)) {
return rv; return rv;
} }
if(frame->hd.type != NGHTTP2_HEADERS) { if(frame->hd.type != NGHTTP2_HEADERS) {
return 0; return 0;
} }
stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
if(!stream) {
return 0;
}
switch(frame->headers.cat) { switch(frame->headers.cat) {
case NGHTTP2_HCAT_REQUEST: case NGHTTP2_HCAT_REQUEST:
return nghttp2_session_end_request_headers_received return nghttp2_session_end_request_headers_received
@ -3184,20 +3187,21 @@ int nghttp2_session_on_data_received(nghttp2_session *session,
int rv = 0; int rv = 0;
nghttp2_stream *stream; nghttp2_stream *stream;
/* We call on_frame_recv_callback even if stream has been closed /* We don't call on_frame_recv_callback if stream has been closed
already */ already or being closed. */
rv = nghttp2_session_call_on_frame_received(session, frame);
if(nghttp2_is_fatal(rv)) {
return rv;
}
stream = nghttp2_session_get_stream(session, frame->hd.stream_id); stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
if(!stream) { if(!stream || stream->state == NGHTTP2_STREAM_CLOSING) {
/* This should be treated as stream error, but it results in lots /* This should be treated as stream error, but it results in lots
of RST_STREAM. So just ignore frame against nonexistent stream of RST_STREAM. So just ignore frame against nonexistent stream
for now. */ for now. */
return 0; return 0;
} }
rv = nghttp2_session_call_on_frame_received(session, frame);
if(nghttp2_is_fatal(rv)) {
return rv;
}
if(frame->hd.flags & NGHTTP2_FLAG_END_STREAM) { if(frame->hd.flags & NGHTTP2_FLAG_END_STREAM) {
nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_RD); nghttp2_stream_shutdown(stream, NGHTTP2_SHUT_RD);
rv = nghttp2_session_close_stream_if_shut_rdwr(session, stream); rv = nghttp2_session_close_stream_if_shut_rdwr(session, stream);