From 774cf88f68f5f09d989b15e83c5d212cc4f181c6 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 22 Mar 2014 00:51:40 +0900 Subject: [PATCH] Don't add RST_STREAM frame if stream is in NGHTTP2_STREAM_CLOSING --- lib/nghttp2_session.c | 7 +++++++ lib/nghttp2_session.h | 4 ++++ 2 files changed, 11 insertions(+) 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: *