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).
This commit is contained in:
Tatsuhiro Tsujikawa 2014-01-18 16:19:28 +09:00
parent 59ff0b2f77
commit 2222b5ab0d
3 changed files with 4 additions and 20 deletions

View File

@ -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.
*/

View File

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

View File

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