From c12b6bc3603cf444cbd1de61d379adeef22eccaa Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 29 Mar 2014 23:57:27 +0900 Subject: [PATCH] Call on_stream_close_callback for a stream in reserved state This is useful because application may allocate resources for it and wants to free the resources if they are not used anymore. --- lib/nghttp2_session.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/nghttp2_session.c b/lib/nghttp2_session.c index 04ea9e78..58d20cf4 100644 --- a/lib/nghttp2_session.c +++ b/lib/nghttp2_session.c @@ -875,19 +875,16 @@ int nghttp2_session_close_stream(nghttp2_session *session, int32_t stream_id, may be PROTOCOL_ERROR, but without notifying stream closure will hang the stream in a local endpoint. */ - /* TODO Should on_stream_close_callback be called against - NGHTTP2_STREAM_RESERVED? It is actually not opened yet. - Maybe we should call callback in this case. */ - if(stream->state != NGHTTP2_STREAM_RESERVED) { - if(session->callbacks.on_stream_close_callback) { - if(session->callbacks.on_stream_close_callback - (session, stream_id, - error_code, - session->user_data) != 0) { - return NGHTTP2_ERR_CALLBACK_FAILURE; - } + if(session->callbacks.on_stream_close_callback) { + if(session->callbacks.on_stream_close_callback + (session, stream_id, error_code, session->user_data) != 0) { + + return NGHTTP2_ERR_CALLBACK_FAILURE; } + } + + if(stream->state != NGHTTP2_STREAM_RESERVED) { if(nghttp2_session_is_my_stream_id(session, stream_id)) { --session->num_outgoing_streams; } else {