Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
bc8a5831
Commit
bc8a5831
authored
Oct 16, 2014
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor stream tree code
parent
502ff245
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
61 deletions
+85
-61
lib/nghttp2_stream.c
lib/nghttp2_stream.c
+85
-61
No files found.
lib/nghttp2_stream.c
View file @
bc8a5831
...
...
@@ -629,6 +629,80 @@ static void insert_link_dep(nghttp2_stream *dep_stream,
link_dep
(
dep_stream
,
stream
);
}
static
void
unlink_sib
(
nghttp2_stream
*
stream
)
{
nghttp2_stream
*
prev
,
*
next
,
*
dep_next
;
prev
=
stream
->
sib_prev
;
dep_next
=
stream
->
dep_next
;
assert
(
prev
);
if
(
dep_next
)
{
/*
* prev--stream(--sib_next--...)
* |
* dep_next
*/
dep_next
->
dep_prev
=
NULL
;
link_sib
(
prev
,
dep_next
);
if
(
stream
->
sib_next
)
{
link_sib
(
stream_last_sib
(
dep_next
),
stream
->
sib_next
);
}
}
else
{
/*
* prev--stream(--sib_next--...)
*/
next
=
stream
->
sib_next
;
prev
->
sib_next
=
next
;
if
(
next
)
{
next
->
sib_prev
=
prev
;
}
}
}
static
void
unlink_dep
(
nghttp2_stream
*
stream
)
{
nghttp2_stream
*
prev
,
*
next
,
*
dep_next
;
prev
=
stream
->
dep_prev
;
dep_next
=
stream
->
dep_next
;
assert
(
prev
);
if
(
dep_next
)
{
/*
* prev
* |
* stream(--sib_next--...)
* |
* dep_next
*/
link_dep
(
prev
,
dep_next
);
if
(
stream
->
sib_next
)
{
link_sib
(
stream_last_sib
(
dep_next
),
stream
->
sib_next
);
}
}
else
if
(
stream
->
sib_next
)
{
/*
* prev
* |
* stream--sib_next
*/
next
=
stream
->
sib_next
;
next
->
sib_prev
=
NULL
;
link_dep
(
prev
,
next
);
}
else
{
prev
->
dep_next
=
NULL
;
}
}
void
nghttp2_stream_dep_add
(
nghttp2_stream
*
dep_stream
,
nghttp2_stream
*
stream
)
{
...
...
@@ -646,8 +720,7 @@ void nghttp2_stream_dep_add(nghttp2_stream *dep_stream,
dep_stream
->
sum_dep_weight
+=
stream
->
weight
;
if
(
dep_stream
->
dep_next
==
NULL
)
{
dep_stream
->
dep_next
=
stream
;
stream
->
dep_prev
=
dep_stream
;
link_dep
(
dep_stream
,
stream
);
}
else
{
insert_link_dep
(
dep_stream
,
stream
);
}
...
...
@@ -660,7 +733,7 @@ void nghttp2_stream_dep_add(nghttp2_stream *dep_stream,
void
nghttp2_stream_dep_remove
(
nghttp2_stream
*
stream
)
{
nghttp2_stream
*
prev
,
*
next
,
*
dep_
next
,
*
dep_
prev
,
*
si
,
*
root_stream
;
nghttp2_stream
*
prev
,
*
next
,
*
dep_prev
,
*
si
,
*
root_stream
;
int32_t
sum_dep_weight_delta
;
root_stream
=
NULL
;
...
...
@@ -688,46 +761,12 @@ void nghttp2_stream_dep_remove(nghttp2_stream *stream)
}
if
(
stream
->
sib_prev
)
{
prev
=
stream
->
sib_prev
;
dep_next
=
stream
->
dep_next
;
if
(
dep_next
)
{
dep_next
->
dep_prev
=
NULL
;
prev
->
sib_next
=
dep_next
;
dep_next
->
sib_prev
=
prev
;
}
else
{
next
=
stream
->
sib_next
;
prev
->
sib_next
=
next
;
if
(
next
)
{
next
->
sib_prev
=
prev
;
}
}
unlink_sib
(
stream
);
}
else
if
(
stream
->
dep_prev
)
{
prev
=
stream
->
dep_prev
;
dep_next
=
stream
->
dep_next
;
if
(
dep_next
)
{
prev
->
dep_next
=
dep_next
;
dep_next
->
dep_prev
=
prev
;
}
else
if
(
stream
->
sib_next
)
{
next
=
stream
->
sib_next
;
prev
->
dep_next
=
next
;
next
->
dep_prev
=
prev
;
next
->
sib_prev
=
NULL
;
}
else
{
prev
->
dep_next
=
NULL
;
dep_next
=
NULL
;
}
unlink_dep
(
stream
);
}
else
{
nghttp2_stream_roots_remove
(
stream
->
roots
,
stream
);
dep_next
=
NULL
;
/* stream is a root of tree. Removing stream makes its
descendants a root of its own subtree. */
...
...
@@ -747,14 +786,6 @@ void nghttp2_stream_dep_remove(nghttp2_stream *stream)
}
}
if
(
dep_next
&&
stream
->
sib_next
)
{
prev
=
stream_last_sib
(
dep_next
);
next
=
stream
->
sib_next
;
prev
->
sib_next
=
next
;
next
->
sib_prev
=
prev
;
}
if
(
root_stream
)
{
stream_update_dep_sum_norest_weight
(
root_stream
);
stream_update_dep_effective_weight
(
root_stream
);
...
...
@@ -801,23 +832,19 @@ int nghttp2_stream_dep_insert_subtree(nghttp2_stream *dep_stream,
stream_update_dep_set_rest
(
dep_next
);
dep_stream
->
dep_next
=
stream
;
stream
->
dep_prev
=
dep_stream
;
link_dep
(
dep_stream
,
stream
);
if
(
stream
->
dep_next
)
{
last_sib
=
stream_last_sib
(
stream
->
dep_next
);
last_sib
->
sib_next
=
dep_next
;
dep_next
->
sib_prev
=
last_sib
;
link_sib
(
last_sib
,
dep_next
);
dep_next
->
dep_prev
=
NULL
;
}
else
{
stream
->
dep_next
=
dep_next
;
dep_next
->
dep_prev
=
stream
;
link_dep
(
stream
,
dep_next
);
}
}
else
{
dep_stream
->
dep_next
=
stream
;
stream
->
dep_prev
=
dep_stream
;
link_dep
(
dep_stream
,
stream
);
assert
(
dep_stream
->
sum_dep_weight
==
0
);
dep_stream
->
sum_dep_weight
=
stream
->
weight
;
...
...
@@ -852,8 +879,7 @@ int nghttp2_stream_dep_add_subtree(nghttp2_stream *dep_stream,
insert_link_dep
(
dep_stream
,
stream
);
}
else
{
dep_stream
->
dep_next
=
stream
;
stream
->
dep_prev
=
dep_stream
;
link_dep
(
dep_stream
,
stream
);
assert
(
dep_stream
->
sum_dep_weight
==
0
);
dep_stream
->
sum_dep_weight
=
stream
->
weight
;
...
...
@@ -975,8 +1001,7 @@ int nghttp2_stream_dep_all_your_stream_are_belong_to_us
stream
->
sum_dep_weight
+=
si
->
weight
;
stream
->
num_substreams
+=
si
->
num_substreams
;
si
->
sib_prev
=
prev
;
prev
->
sib_next
=
si
;
link_sib
(
prev
,
si
);
prev
=
si
;
}
...
...
@@ -991,8 +1016,7 @@ int nghttp2_stream_dep_all_your_stream_are_belong_to_us
link_sib
(
first
,
sib_next
);
link_dep
(
stream
,
prev
);
}
else
{
stream
->
dep_next
=
first
;
first
->
dep_prev
=
stream
;
link_dep
(
stream
,
first
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment