diff --git a/lib/nghttp2_session.c b/lib/nghttp2_session.c index 43968fa5..a2f08735 100644 --- a/lib/nghttp2_session.c +++ b/lib/nghttp2_session.c @@ -541,8 +541,13 @@ int nghttp2_session_close_stream(nghttp2_session *session, int32_t stream_id, { nghttp2_stream *stream = nghttp2_session_get_stream(session, stream_id); if(stream) { - if(stream->state != NGHTTP2_STREAM_INITIAL && - stream->state != NGHTTP2_STREAM_RESERVED && + /* We call on_stream_close_callback even if stream->state is + NGHTTP2_STREAM_INITIAL. This will happen while sending request + HEADERS, a local endpoint receives RST_STREAM for that + stream. It may be PROTOCOL_ERROR, but without notifying stream + closure will hang the stream in a local endpoint. + */ + if(stream->state != NGHTTP2_STREAM_RESERVED && /* TODO Should on_stream_close_callback be called against NGHTTP2_STREAM_RESERVED? It is actually not opened yet. */ session->callbacks.on_stream_close_callback) {