Assign default priority if dep_stream in PRIORITY does not exist
This commit is contained in:
parent
292c01fda2
commit
c31be5af4d
|
@ -567,11 +567,13 @@ void nghttp2_session_del(nghttp2_session *session)
|
|||
|
||||
int nghttp2_session_reprioritize_stream
|
||||
(nghttp2_session *session, nghttp2_stream *stream,
|
||||
const nghttp2_priority_spec *pri_spec)
|
||||
const nghttp2_priority_spec *pri_spec_in)
|
||||
{
|
||||
int rv;
|
||||
nghttp2_stream *dep_stream;
|
||||
nghttp2_stream *root_stream;
|
||||
nghttp2_priority_spec pri_spec_default;
|
||||
const nghttp2_priority_spec *pri_spec = pri_spec_in;
|
||||
|
||||
if(!nghttp2_stream_in_dep_tree(stream)) {
|
||||
return 0;
|
||||
|
@ -582,6 +584,15 @@ int nghttp2_session_reprioritize_stream
|
|||
(session, NGHTTP2_PROTOCOL_ERROR, "depend on itself");
|
||||
}
|
||||
|
||||
if(pri_spec->stream_id != 0) {
|
||||
dep_stream = nghttp2_session_get_stream_raw(session, pri_spec->stream_id);
|
||||
|
||||
if(!dep_stream || !nghttp2_stream_in_dep_tree(dep_stream)) {
|
||||
nghttp2_priority_spec_default_init(&pri_spec_default);
|
||||
pri_spec = &pri_spec_default;
|
||||
}
|
||||
}
|
||||
|
||||
if(pri_spec->stream_id == 0) {
|
||||
nghttp2_stream_dep_remove_subtree(stream);
|
||||
|
||||
|
@ -602,12 +613,6 @@ int nghttp2_session_reprioritize_stream
|
|||
return rv;
|
||||
}
|
||||
|
||||
dep_stream = nghttp2_session_get_stream_raw(session, pri_spec->stream_id);
|
||||
|
||||
if(!dep_stream || !nghttp2_stream_in_dep_tree(dep_stream)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(nghttp2_stream_dep_subtree_find(stream, dep_stream)) {
|
||||
DEBUGF(fprintf(stderr,
|
||||
"stream: cycle detected, dep_stream(%p)=%d "
|
||||
|
|
|
@ -3074,13 +3074,13 @@ void test_nghttp2_session_reprioritize_stream(void)
|
|||
CU_ASSERT(10 == stream->weight);
|
||||
CU_ASSERT(NULL == stream->dep_prev);
|
||||
|
||||
/* dep_stream does not exist */
|
||||
/* If dep_stream does not exist, default priority is assigned. */
|
||||
|
||||
nghttp2_priority_spec_init(&pri_spec, 3, 99, 0);
|
||||
|
||||
nghttp2_session_reprioritize_stream(session, stream, &pri_spec);
|
||||
|
||||
CU_ASSERT(10 == stream->weight);
|
||||
CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == stream->weight);
|
||||
CU_ASSERT(NULL == stream->dep_prev);
|
||||
|
||||
dep_stream = open_stream(session, 3);
|
||||
|
|
Loading…
Reference in New Issue