From d6ca95a0c9f790a45ea682eccafdb12d8d19976e Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 24 Jun 2015 22:18:07 +0900 Subject: [PATCH] Fix sibling's item is not queued when ancestor's item is detached --- lib/nghttp2_stream.c | 2 +- tests/nghttp2_session_test.c | 40 ++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/lib/nghttp2_stream.c b/lib/nghttp2_stream.c index fae02292..d38ab52d 100644 --- a/lib/nghttp2_stream.c +++ b/lib/nghttp2_stream.c @@ -370,7 +370,7 @@ static int stream_update_dep_on_detach_item(nghttp2_stream *stream, return 0; } - return stream_update_dep_queue_top(stream->dep_next, session); + return stream_update_dep_queue_top(stream, session); } int nghttp2_stream_attach_item(nghttp2_stream *stream, diff --git a/tests/nghttp2_session_test.c b/tests/nghttp2_session_test.c index 157a81ed..c541283b 100644 --- a/tests/nghttp2_session_test.c +++ b/tests/nghttp2_session_test.c @@ -6429,6 +6429,46 @@ void test_nghttp2_session_stream_attach_item(void) { CU_ASSERT(0 == b->sum_norest_weight); nghttp2_session_del(session); + + nghttp2_session_server_new(&session, &callbacks, NULL); + + a = open_stream(session, 1); + b = open_stream_with_dep(session, 3, a); + c = open_stream_with_dep(session, 5, a); + d = open_stream_with_dep(session, 7, c); + + /* a + * | + * c--b + * | + * d + */ + + da = create_data_ob_item(mem); + db = create_data_ob_item(mem); + dc = create_data_ob_item(mem); + + nghttp2_stream_attach_item(a, da, session); + nghttp2_stream_attach_item(b, db, session); + nghttp2_stream_attach_item(c, dc, session); + + CU_ASSERT(NGHTTP2_STREAM_DPRI_TOP == a->dpri); + CU_ASSERT(NGHTTP2_STREAM_DPRI_REST == b->dpri); + CU_ASSERT(NGHTTP2_STREAM_DPRI_REST == c->dpri); + CU_ASSERT(NGHTTP2_STREAM_DPRI_NO_ITEM == d->dpri); + + /* check that all children's item get queued */ + nghttp2_stream_detach_item(a, session); + + CU_ASSERT(NGHTTP2_STREAM_DPRI_NO_ITEM == a->dpri); + CU_ASSERT(NGHTTP2_STREAM_DPRI_TOP == b->dpri); + CU_ASSERT(NGHTTP2_STREAM_DPRI_TOP == c->dpri); + CU_ASSERT(NGHTTP2_STREAM_DPRI_NO_ITEM == d->dpri); + + CU_ASSERT(1 == db->queued); + CU_ASSERT(1 == dc->queued); + + nghttp2_session_del(session); } void test_nghttp2_session_stream_attach_item_subtree(void) {