Fix bug in priority tree
This change fixes the bug that stream is out of dependency tree if the number of nodes in a dependency tree which we add new node to is already maximum (NGHTTP2_MAX_DEP_TREE_LENGTH) and the number of maximum concurrent streams is more than more than NGHTTP2_MAX_DEP_TREE_LENGTH.
This commit is contained in:
parent
29fcd7c946
commit
9a33116526
|
@ -868,6 +868,8 @@ nghttp2_stream* nghttp2_session_open_stream(nghttp2_session *session,
|
|||
} else {
|
||||
nghttp2_stream_dep_add(dep_stream, stream);
|
||||
}
|
||||
} else {
|
||||
nghttp2_stream_roots_add(&session->roots, stream);
|
||||
}
|
||||
|
||||
return stream;
|
||||
|
|
|
@ -243,6 +243,8 @@ int main(int argc, char* argv[])
|
|||
test_nghttp2_session_stream_attach_data_subtree) ||
|
||||
!CU_add_test(pSuite, "session_stream_keep_closed_stream",
|
||||
test_nghttp2_session_keep_closed_stream) ||
|
||||
!CU_add_test(pSuite, "session_large_dep_tree",
|
||||
test_nghttp2_session_large_dep_tree) ||
|
||||
!CU_add_test(pSuite, "session_graceful_shutdown",
|
||||
test_nghttp2_session_graceful_shutdown) ||
|
||||
!CU_add_test(pSuite, "session_on_header_temporal_failure",
|
||||
|
|
|
@ -6386,6 +6386,41 @@ void test_nghttp2_session_keep_closed_stream(void)
|
|||
nghttp2_session_del(session);
|
||||
}
|
||||
|
||||
void test_nghttp2_session_large_dep_tree(void)
|
||||
{
|
||||
nghttp2_session *session;
|
||||
nghttp2_session_callbacks callbacks;
|
||||
size_t i;
|
||||
nghttp2_stream *dep_stream = NULL;
|
||||
nghttp2_stream *root_stream;
|
||||
int32_t stream_id;
|
||||
|
||||
memset(&callbacks, 0, sizeof(callbacks));
|
||||
callbacks.send_callback = null_send_callback;
|
||||
|
||||
nghttp2_session_server_new(&session, &callbacks, NULL);
|
||||
|
||||
stream_id = 1;
|
||||
for(i = 0; i < NGHTTP2_MAX_DEP_TREE_LENGTH; ++i) {
|
||||
dep_stream = open_stream_with_dep(session, stream_id, dep_stream);
|
||||
stream_id += 2;
|
||||
}
|
||||
|
||||
root_stream = nghttp2_session_get_stream(session, 1);
|
||||
|
||||
/* Check that last dep_stream must be part of tree */
|
||||
CU_ASSERT(nghttp2_stream_dep_subtree_find(root_stream, dep_stream));
|
||||
|
||||
dep_stream = open_stream_with_dep(session, stream_id, dep_stream);
|
||||
|
||||
/* We exceeded NGHTTP2_MAX_DEP_TREE_LENGTH limit. dep_stream is now
|
||||
root node and has no descendants. */
|
||||
CU_ASSERT(!nghttp2_stream_dep_subtree_find(root_stream, dep_stream));
|
||||
CU_ASSERT(nghttp2_stream_in_dep_tree(dep_stream));
|
||||
|
||||
nghttp2_session_del(session);
|
||||
}
|
||||
|
||||
void test_nghttp2_session_graceful_shutdown(void)
|
||||
{
|
||||
nghttp2_session *session;
|
||||
|
|
|
@ -111,6 +111,7 @@ void test_nghttp2_session_stream_dep_all_your_stream_are_belong_to_us(void);
|
|||
void test_nghttp2_session_stream_attach_data(void);
|
||||
void test_nghttp2_session_stream_attach_data_subtree(void);
|
||||
void test_nghttp2_session_keep_closed_stream(void);
|
||||
void test_nghttp2_session_large_dep_tree(void);
|
||||
void test_nghttp2_session_graceful_shutdown(void);
|
||||
void test_nghttp2_session_on_header_temporal_failure(void);
|
||||
void test_nghttp2_session_recv_client_preface(void);
|
||||
|
|
Loading…
Reference in New Issue