From 4cad48da16e98dd1711db2732bf93753963da8b6 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 29 Aug 2015 23:43:54 +0900 Subject: [PATCH] Reset cycle to 0 if stream has only 1 direct descendant --- lib/nghttp2_stream.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/nghttp2_stream.c b/lib/nghttp2_stream.c index 05d3e410..dc9ab462 100644 --- a/lib/nghttp2_stream.c +++ b/lib/nghttp2_stream.c @@ -201,18 +201,23 @@ void nghttp2_stream_reschedule(nghttp2_stream *stream) { dep_stream = stream->dep_prev; for (; dep_stream; stream = dep_stream, dep_stream = dep_stream->dep_prev) { - dep_stream->descendant_last_cycle = - nghttp2_max(dep_stream->descendant_last_cycle, stream->cycle); + if (nghttp2_pq_size(&dep_stream->obq) == 1) { + dep_stream->descendant_last_cycle = 0; + stream->cycle = 0; + } else { + dep_stream->descendant_last_cycle = + nghttp2_max(dep_stream->descendant_last_cycle, stream->cycle); - stream->cycle = - stream_next_cycle(stream, dep_stream->descendant_last_cycle); + stream->cycle = + stream_next_cycle(stream, dep_stream->descendant_last_cycle); + + nghttp2_pq_remove(&dep_stream->obq, &stream->pq_entry); + nghttp2_pq_push(&dep_stream->obq, &stream->pq_entry); + } DEBUGF(fprintf(stderr, "stream: stream=%d obq resched cycle=%ld\n", stream->stream_id, stream->cycle)); - nghttp2_pq_remove(&dep_stream->obq, &stream->pq_entry); - nghttp2_pq_push(&dep_stream->obq, &stream->pq_entry); - dep_stream->last_writelen = stream->last_writelen; } }