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.
This commit is contained in:
Tatsuhiro Tsujikawa 2014-03-29 23:57:27 +09:00
parent 58da463ad6
commit c12b6bc360
1 changed files with 8 additions and 11 deletions

View File

@ -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 {