diff --git a/lib/nghttp2_session.c b/lib/nghttp2_session.c index 73ee765a..9d6734ac 100644 --- a/lib/nghttp2_session.c +++ b/lib/nghttp2_session.c @@ -581,6 +581,13 @@ int nghttp2_session_add_rst_stream(nghttp2_session *session, { int rv; nghttp2_frame *frame; + nghttp2_stream *stream; + + stream = nghttp2_session_get_stream(session, stream_id); + if(stream && stream->state == NGHTTP2_STREAM_CLOSING) { + return 0; + } + frame = malloc(sizeof(nghttp2_frame)); if(frame == NULL) { return NGHTTP2_ERR_NOMEM; diff --git a/lib/nghttp2_session.h b/lib/nghttp2_session.h index 8b402430..78af0077 100644 --- a/lib/nghttp2_session.h +++ b/lib/nghttp2_session.h @@ -229,6 +229,10 @@ int nghttp2_session_add_frame(nghttp2_session *session, * code |error_code|. This is a convenient function built on top of * nghttp2_session_add_frame() to add RST_STREAM easily. * + * This function simply returns 0 without adding RST_STREAM frame if + * given stream is in NGHTTP2_STREAM_CLOSING state, because multiple + * RST_STREAM for a stream is redundant. + * * This function returns 0 if it succeeds, or one of the following * negative error codes: *