From 1a12a9b397f424ab608537f6a8c3de7e69d0c529 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 17 Apr 2015 21:17:22 +0900 Subject: [PATCH] Penalize cycle according to effective weight --- lib/nghttp2_session.c | 5 +++-- lib/nghttp2_stream.c | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/nghttp2_session.c b/lib/nghttp2_session.c index 6bec4ea8..3d5a25a2 100644 --- a/lib/nghttp2_session.c +++ b/lib/nghttp2_session.c @@ -2246,9 +2246,10 @@ static void session_outbound_item_schedule(nghttp2_session *session, int32_t weight) { size_t delta = item->frame.hd.length * NGHTTP2_MAX_WEIGHT / weight; - assert(session->last_cycle <= item->cycle); + if (session->last_cycle < item->cycle) { + session->last_cycle = item->cycle; + } - session->last_cycle = item->cycle; item->cycle = session->last_cycle + delta; } diff --git a/lib/nghttp2_stream.c b/lib/nghttp2_stream.c index 88cefb51..6725eb0d 100644 --- a/lib/nghttp2_stream.c +++ b/lib/nghttp2_stream.c @@ -101,7 +101,12 @@ static int stream_push_item(nghttp2_stream *stream, nghttp2_session *session) { return 0; } - item->cycle = session->last_cycle; + /* Penalize item by delaying scheduling according to effective + weight. This will delay low priority stream, which is good. + OTOH, this may incur delay for high priority item. Will see. */ + item->cycle = + session->last_cycle + + NGHTTP2_DATA_PAYLOADLEN * NGHTTP2_MAX_WEIGHT / stream->effective_weight; switch (item->frame.hd.type) { case NGHTTP2_DATA: