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: