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
60cb3f67
Commit
60cb3f67
authored
Dec 01, 2014
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor nghttp2_adjust_local_window_size
parent
6b59609f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
41 deletions
+46
-41
lib/nghttp2_helper.c
lib/nghttp2_helper.c
+46
-41
No files found.
lib/nghttp2_helper.c
View file @
60cb3f67
...
@@ -172,40 +172,45 @@ int nghttp2_adjust_local_window_size(int32_t *local_window_size_ptr,
...
@@ -172,40 +172,45 @@ int nghttp2_adjust_local_window_size(int32_t *local_window_size_ptr,
int32_t
*
recv_reduction_ptr
,
int32_t
*
recv_reduction_ptr
,
int32_t
*
delta_ptr
)
{
int32_t
*
delta_ptr
)
{
if
(
*
delta_ptr
>
0
)
{
if
(
*
delta_ptr
>
0
)
{
int32_t
recv_reduction_delta
;
int32_t
delta
;
int32_t
new_recv_window_size
=
int32_t
new_recv_window_size
=
nghttp2_max
(
0
,
*
recv_window_size_ptr
)
-
*
delta_ptr
;
nghttp2_max
(
0
,
*
recv_window_size_ptr
)
-
*
delta_ptr
;
if
(
new_recv_window_size
<
0
)
{
if
(
new_recv_window_size
>=
0
)
{
*
recv_window_size_ptr
=
new_recv_window_size
;
return
0
;
}
delta
=
-
new_recv_window_size
;
/* The delta size is strictly more than received bytes. Increase
/* The delta size is strictly more than received bytes. Increase
local_window_size by that difference. */
local_window_size by that difference |delta|. */
int32_t
recv_reduction_diff
;
if
(
*
local_window_size_ptr
>
NGHTTP2_MAX_WINDOW_SIZE
-
delta
)
{
if
(
*
local_window_size_ptr
>
NGHTTP2_MAX_WINDOW_SIZE
+
new_recv_window_size
)
{
return
NGHTTP2_ERR_FLOW_CONTROL
;
return
NGHTTP2_ERR_FLOW_CONTROL
;
}
}
*
local_window_size_ptr
-=
new_recv_window_size
;
*
local_window_size_ptr
+=
delta
;
/* If there is recv_reduction due to earlier window_size
/* If there is recv_reduction due to earlier window_size
reduction, we have to adjust it too. */
reduction, we have to adjust it too. */
recv_reduction_diff
=
recv_reduction_delta
=
nghttp2_min
(
*
recv_reduction_ptr
,
delta
);
nghttp2_min
(
*
recv_reduction_ptr
,
-
new_recv_window_size
);
*
recv_reduction_ptr
-=
recv_reduction_delta
;
*
recv_reduction_ptr
-=
recv_reduction_diff
;
if
(
*
recv_window_size_ptr
<
0
)
{
if
(
*
recv_window_size_ptr
<
0
)
{
*
recv_window_size_ptr
+=
recv_reduction_diff
;
*
recv_window_size_ptr
+=
recv_reduction_delta
;
}
else
{
}
else
{
/* If *recv_window_size_ptr > 0, then those bytes are going to
/* If *recv_window_size_ptr > 0, then those bytes are going to
be back
ed to the remote peer (by WINDOW_UPDATE with the
be return
ed to the remote peer (by WINDOW_UPDATE with the
adjusted *delta_ptr), so it is effectively 0 now. We set
adjusted *delta_ptr), so it is effectively 0 now. We set to
to *recv_reduction_diff
, because caller does not take into
*recv_reduction_delta
, because caller does not take into
account it in *delta_ptr. */
account it in *delta_ptr. */
*
recv_window_size_ptr
=
recv_reduction_diff
;
*
recv_window_size_ptr
=
recv_reduction_delta
;
}
}
/* recv_reduction_diff
must be paied from *delta_ptr, since it
/* recv_reduction_delta
must be paied from *delta_ptr, since it
was added in window size reduction (see below). */
was added in window size reduction (see below). */
*
delta_ptr
-=
recv_reduction_diff
;
*
delta_ptr
-=
recv_reduction_delta
;
}
else
{
*
recv_window_size_ptr
=
new_recv_window_size
;
}
return
0
;
return
0
;
}
else
{
}
if
(
*
local_window_size_ptr
+
*
delta_ptr
<
0
||
if
(
*
local_window_size_ptr
+
*
delta_ptr
<
0
||
*
recv_window_size_ptr
<
INT32_MIN
-
*
delta_ptr
||
*
recv_window_size_ptr
<
INT32_MIN
-
*
delta_ptr
||
*
recv_reduction_ptr
>
INT32_MAX
+
*
delta_ptr
)
{
*
recv_reduction_ptr
>
INT32_MAX
+
*
delta_ptr
)
{
...
@@ -219,7 +224,7 @@ int nghttp2_adjust_local_window_size(int32_t *local_window_size_ptr,
...
@@ -219,7 +224,7 @@ int nghttp2_adjust_local_window_size(int32_t *local_window_size_ptr,
*
recv_window_size_ptr
+=
*
delta_ptr
;
*
recv_window_size_ptr
+=
*
delta_ptr
;
*
recv_reduction_ptr
-=
*
delta_ptr
;
*
recv_reduction_ptr
-=
*
delta_ptr
;
*
delta_ptr
=
0
;
*
delta_ptr
=
0
;
}
return
0
;
return
0
;
}
}
...
...
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