From d7b0768ab88ac6b1da80c338fa173f9f13fee40e Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 20 Nov 2015 21:24:54 +0900 Subject: [PATCH] Fix bug that dep_stream->sum_dep_weight was not updated --- lib/nghttp2_session.c | 1 + tests/nghttp2_session_test.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/lib/nghttp2_session.c b/lib/nghttp2_session.c index 411fa7ab..da678409 100644 --- a/lib/nghttp2_session.c +++ b/lib/nghttp2_session.c @@ -661,6 +661,7 @@ int nghttp2_session_reprioritize_stream( } if (dep_stream == stream->dep_prev && !pri_spec->exclusive) { + dep_stream->sum_dep_weight += pri_spec->weight - stream->weight; stream->weight = pri_spec->weight; return 0; } diff --git a/tests/nghttp2_session_test.c b/tests/nghttp2_session_test.c index 149dd81b..32e27a0b 100644 --- a/tests/nghttp2_session_test.c +++ b/tests/nghttp2_session_test.c @@ -3447,6 +3447,15 @@ void test_nghttp2_session_reprioritize_stream(void) { CU_ASSERT(128 == stream->weight); CU_ASSERT(dep_stream == stream->dep_prev); + /* Change weight again to test short-path case */ + pri_spec.weight = 100; + + nghttp2_session_reprioritize_stream(session, stream, &pri_spec); + + CU_ASSERT(100 == stream->weight); + CU_ASSERT(dep_stream == stream->dep_prev); + CU_ASSERT(100 == dep_stream->sum_dep_weight); + /* Test circular dependency; stream 1 is first removed and becomes root. Then stream 3 depends on it. */ nghttp2_priority_spec_init(&pri_spec, 1, 1, 0);