From 2222b5ab0d925d92e7154cfec0243c8e9005e6d2 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 18 Jan 2014 16:19:28 +0900 Subject: [PATCH] Don't return NGHTTP2_ERR_STREAM_CLOSED when submitting DATA, PRIORITY, WU Remove the check to see that stream exists at the time when submitting DATA, PRIORITY and WINDOW_UPDATE. We will do this check when we actually serialize and send them off to the network (or application provided buffer). --- lib/includes/nghttp2/nghttp2.h | 6 ------ lib/nghttp2_submit.c | 10 +--------- tests/nghttp2_session_test.c | 8 +++----- 3 files changed, 4 insertions(+), 20 deletions(-) diff --git a/lib/includes/nghttp2/nghttp2.h b/lib/includes/nghttp2/nghttp2.h index b405050d..f03002ef 100644 --- a/lib/includes/nghttp2/nghttp2.h +++ b/lib/includes/nghttp2/nghttp2.h @@ -2011,8 +2011,6 @@ int nghttp2_submit_headers(nghttp2_session *session, uint8_t flags, * * :enum:`NGHTTP2_ERR_NOMEM` * Out of memory. - * :enum:`NGHTTP2_ERR_STREAM_CLOSED` - * The stream is already closed or does not exist. */ int nghttp2_submit_data(nghttp2_session *session, uint8_t flags, int32_t stream_id, @@ -2034,8 +2032,6 @@ int nghttp2_submit_data(nghttp2_session *session, uint8_t flags, * Out of memory. * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` * The |pri| is negative. - * :enum:`NGHTTP2_ERR_STREAM_CLOSED` - * The stream is already closed or does not exist. */ int nghttp2_submit_priority(nghttp2_session *session, uint8_t flags, int32_t stream_id, int32_t pri); @@ -2213,8 +2209,6 @@ int nghttp2_submit_goaway(nghttp2_session *session, uint8_t flags, * * :enum:`NGHTTP2_ERR_FLOW_CONTROL` * The local window size overflow or gets negative. - * :enum:`NGHTTP2_ERR_STREAM_CLOSED` - * The stream is already closed or does not exist. * :enum:`NGHTTP2_ERR_NOMEM` * Out of memory. */ diff --git a/lib/nghttp2_submit.c b/lib/nghttp2_submit.c index f4a20165..ced1a831 100644 --- a/lib/nghttp2_submit.c +++ b/lib/nghttp2_submit.c @@ -140,14 +140,9 @@ int nghttp2_submit_priority(nghttp2_session *session, uint8_t flags, { int r; nghttp2_frame *frame; - nghttp2_stream *stream; if(pri < 0) { return NGHTTP2_ERR_INVALID_ARGUMENT; } - stream = nghttp2_session_get_stream(session, stream_id); - if(stream == NULL) { - return NGHTTP2_ERR_STREAM_CLOSED; - } frame = malloc(sizeof(nghttp2_frame)); if(frame == NULL) { return NGHTTP2_ERR_NOMEM; @@ -248,7 +243,7 @@ int nghttp2_submit_window_update(nghttp2_session *session, uint8_t flags, return rv; } } else { - return NGHTTP2_ERR_STREAM_CLOSED; + return 0; } } if(window_size_increment > 0) { @@ -309,9 +304,6 @@ int nghttp2_submit_data(nghttp2_session *session, uint8_t flags, nghttp2_data *data_frame; uint8_t nflags = 0; - if(nghttp2_session_get_stream(session, stream_id) == NULL) { - return NGHTTP2_ERR_STREAM_CLOSED; - } data_frame = malloc(sizeof(nghttp2_data)); if(data_frame == NULL) { return NGHTTP2_ERR_NOMEM; diff --git a/tests/nghttp2_session_test.c b/tests/nghttp2_session_test.c index 3ccd593e..68b5c032 100644 --- a/tests/nghttp2_session_test.c +++ b/tests/nghttp2_session_test.c @@ -2651,7 +2651,9 @@ void test_nghttp2_submit_window_update(void) stream->local_flow_control = 0; CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 2, -1)); - CU_ASSERT(NGHTTP2_ERR_STREAM_CLOSED == + /* It is ok if stream is closed or does not exist at the call + time */ + CU_ASSERT(0 == nghttp2_submit_window_update(session, NGHTTP2_FLAG_NONE, 4, 4096)); nghttp2_session_del(session); @@ -3609,10 +3611,6 @@ void test_nghttp2_session_on_ctrl_not_send(void) CU_ASSERT(NGHTTP2_HEADERS == user_data.not_sent_frame_type); CU_ASSERT(NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE == user_data.not_sent_error); - /* Send PRIORITY to stream ID = 1 which does not exist */ - CU_ASSERT(NGHTTP2_ERR_STREAM_CLOSED == - nghttp2_submit_priority(session, NGHTTP2_FLAG_NONE, 1, 0)); - user_data.frame_not_send_cb_called = 0; /* Send GOAWAY */ CU_ASSERT(0 == nghttp2_submit_goaway(session, NGHTTP2_FLAG_NONE,