From ca4a40b8e07b7cf650bcb504bf8c49df572b4ad4 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 21 Dec 2015 21:33:58 +0900 Subject: [PATCH] Don't schedule response HEADERS with priority tree Previously we scheduled the transmission of response HEADERS using priority tree in the belief that it allows more better utilization of bandwidth for prioritized streams. But to reduce the overhead of reconstruction of priority queue when connection level flow control window is depleted, we just don't check priority tree in this case. This means that response HEADERS frames are not sent even though they are not flow controlled. This could waste bandwidth. To improve this situation, we stop scheduling response HEADERS with priority tree for now. Now they are just sent in the order they submitted. The response body DATA continued to be scheduled with priority tree as before. --- lib/nghttp2_outbound_item.h | 3 --- lib/nghttp2_session.c | 14 -------------- lib/nghttp2_submit.c | 20 ++++++++------------ 3 files changed, 8 insertions(+), 29 deletions(-) diff --git a/lib/nghttp2_outbound_item.h b/lib/nghttp2_outbound_item.h index c16d5dfe..f1daeb1c 100644 --- a/lib/nghttp2_outbound_item.h +++ b/lib/nghttp2_outbound_item.h @@ -43,9 +43,6 @@ typedef struct { /* nonzero if request HEADERS is canceled. The error code is stored in |error_code|. */ uint8_t canceled; - /* nonzero if this item should be attached to stream object to make - it under priority control */ - uint8_t attach_stream; } nghttp2_headers_aux_data; /* struct used for DATA frame */ diff --git a/lib/nghttp2_session.c b/lib/nghttp2_session.c index c22216d2..d9baa253 100644 --- a/lib/nghttp2_session.c +++ b/lib/nghttp2_session.c @@ -718,20 +718,6 @@ int nghttp2_session_add_item(nghttp2_session *session, break; } - if (stream && item->aux_data.headers.attach_stream) { - if (stream->item) { - return NGHTTP2_ERR_DATA_EXIST; - } - - rv = nghttp2_stream_attach_item(stream, item); - - if (rv != 0) { - return rv; - } - - break; - } - nghttp2_outbound_queue_push(&session->ob_reg, item); item->queued = 1; break; diff --git a/lib/nghttp2_submit.c b/lib/nghttp2_submit.c index 65226363..2800b60e 100644 --- a/lib/nghttp2_submit.c +++ b/lib/nghttp2_submit.c @@ -40,8 +40,7 @@ static int32_t submit_headers_shared(nghttp2_session *session, uint8_t flags, const nghttp2_priority_spec *pri_spec, nghttp2_nv *nva_copy, size_t nvlen, const nghttp2_data_provider *data_prd, - void *stream_user_data, - uint8_t attach_stream) { + void *stream_user_data) { int rv; uint8_t flags_copy; nghttp2_outbound_item *item = NULL; @@ -69,7 +68,6 @@ static int32_t submit_headers_shared(nghttp2_session *session, uint8_t flags, } item->aux_data.headers.stream_user_data = stream_user_data; - item->aux_data.headers.attach_stream = attach_stream; flags_copy = (uint8_t)((flags & (NGHTTP2_FLAG_END_STREAM | NGHTTP2_FLAG_PRIORITY)) | @@ -122,8 +120,7 @@ static int32_t submit_headers_shared_nva(nghttp2_session *session, const nghttp2_priority_spec *pri_spec, const nghttp2_nv *nva, size_t nvlen, const nghttp2_data_provider *data_prd, - void *stream_user_data, - uint8_t attach_stream) { + void *stream_user_data) { int rv; nghttp2_nv *nva_copy; nghttp2_priority_spec copy_pri_spec; @@ -144,15 +141,14 @@ static int32_t submit_headers_shared_nva(nghttp2_session *session, } return submit_headers_shared(session, flags, stream_id, ©_pri_spec, - nva_copy, nvlen, data_prd, stream_user_data, - attach_stream); + nva_copy, nvlen, data_prd, stream_user_data); } int nghttp2_submit_trailer(nghttp2_session *session, int32_t stream_id, const nghttp2_nv *nva, size_t nvlen) { return (int)submit_headers_shared_nva(session, NGHTTP2_FLAG_END_STREAM, - stream_id, NULL, nva, nvlen, NULL, NULL, - 0); + stream_id, NULL, nva, nvlen, NULL, + NULL); } int32_t nghttp2_submit_headers(nghttp2_session *session, uint8_t flags, @@ -169,7 +165,7 @@ int32_t nghttp2_submit_headers(nghttp2_session *session, uint8_t flags, } return submit_headers_shared_nva(session, flags, stream_id, pri_spec, nva, - nvlen, NULL, stream_user_data, 0); + nvlen, NULL, stream_user_data); } int nghttp2_submit_ping(nghttp2_session *session, uint8_t flags _U_, @@ -398,7 +394,7 @@ int32_t nghttp2_submit_request(nghttp2_session *session, flags = set_request_flags(pri_spec, data_prd); return submit_headers_shared_nva(session, flags, -1, pri_spec, nva, nvlen, - data_prd, stream_user_data, 0); + data_prd, stream_user_data); } static uint8_t set_response_flags(const nghttp2_data_provider *data_prd) { @@ -414,7 +410,7 @@ int nghttp2_submit_response(nghttp2_session *session, int32_t stream_id, const nghttp2_data_provider *data_prd) { uint8_t flags = set_response_flags(data_prd); return submit_headers_shared_nva(session, flags, stream_id, NULL, nva, nvlen, - data_prd, NULL, 1); + data_prd, NULL); } int nghttp2_submit_data(nghttp2_session *session, uint8_t flags,