Don't add RST_STREAM frame if stream is in NGHTTP2_STREAM_CLOSING

This commit is contained in:
Tatsuhiro Tsujikawa 2014-03-22 00:51:40 +09:00
parent 0a80b0c1aa
commit 774cf88f68
2 changed files with 11 additions and 0 deletions

View File

@ -581,6 +581,13 @@ int nghttp2_session_add_rst_stream(nghttp2_session *session,
{ {
int rv; int rv;
nghttp2_frame *frame; 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)); frame = malloc(sizeof(nghttp2_frame));
if(frame == NULL) { if(frame == NULL) {
return NGHTTP2_ERR_NOMEM; return NGHTTP2_ERR_NOMEM;

View File

@ -229,6 +229,10 @@ int nghttp2_session_add_frame(nghttp2_session *session,
* code |error_code|. This is a convenient function built on top of * code |error_code|. This is a convenient function built on top of
* nghttp2_session_add_frame() to add RST_STREAM easily. * 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 * This function returns 0 if it succeeds, or one of the following
* negative error codes: * negative error codes:
* *