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
6c23c34d
Commit
6c23c34d
authored
Oct 30, 2013
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new API to return effective received data length and local window size
parent
9b6a0e58
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
98 additions
and
12 deletions
+98
-12
lib/includes/nghttp2/nghttp2.h
lib/includes/nghttp2/nghttp2.h
+32
-0
lib/nghttp2_session.c
lib/nghttp2_session.c
+25
-0
src/shrpx_http2_upstream.cc
src/shrpx_http2_upstream.cc
+12
-4
src/shrpx_http2_upstream.h
src/shrpx_http2_upstream.h
+1
-1
src/shrpx_spdy_downstream_connection.cc
src/shrpx_spdy_downstream_connection.cc
+13
-7
src/shrpx_spdy_session.cc
src/shrpx_spdy_session.cc
+12
-0
src/shrpx_spdy_session.h
src/shrpx_spdy_session.h
+3
-0
No files found.
lib/includes/nghttp2/nghttp2.h
View file @
6c23c34d
...
...
@@ -1550,6 +1550,38 @@ void* nghttp2_session_get_stream_user_data(nghttp2_session *session,
*/
size_t
nghttp2_session_get_outbound_queue_size
(
nghttp2_session
*
session
);
/**
* @function
*
* Returns the number of DATA payload in bytes received without
* WINDOW_UPDATE transmission for the stream |stream_id|. The local
* (receive) window size can be adjusted by
* `nghttp2_submit_window_update()`. This function takes into account
* that and returns effective data length. In particular, if the
* local window size is reduced by submitting negative
* window_size_increment with `nghttp2_submit_window_update()`, this
* function returns the number of bytes less than actually received.
*
* If flow control is disabled for that stream, this function returns
* 0.
*
* This function returns -1 if it fails.
*/
int32_t
nghttp2_session_get_stream_effective_recv_data_length
(
nghttp2_session
*
session
,
int32_t
stream_id
);
/**
* @function
*
* Returns the local (receive) window size. The local window size can
* be adjusted by `nghttp2_submit_window_update()`. This function
* takes into account that and returns effective window size.
*
* This function returns -1 if it fails.
*/
int32_t
nghttp2_session_get_stream_effective_local_window_size
(
nghttp2_session
*
session
,
int32_t
stream_id
);
/**
* @function
*
...
...
lib/nghttp2_session.c
View file @
6c23c34d
...
...
@@ -3571,6 +3571,31 @@ size_t nghttp2_session_get_outbound_queue_size(nghttp2_session *session)
return
nghttp2_pq_size
(
&
session
->
ob_pq
)
+
nghttp2_pq_size
(
&
session
->
ob_ss_pq
);
}
int32_t
nghttp2_session_get_stream_effective_recv_data_length
(
nghttp2_session
*
session
,
int32_t
stream_id
)
{
nghttp2_stream
*
stream
;
stream
=
nghttp2_session_get_stream
(
session
,
stream_id
);
if
(
stream
==
NULL
)
{
return
-
1
;
}
if
(
stream
->
local_flow_control
==
0
)
{
return
0
;
}
return
stream
->
recv_window_size
;
}
int32_t
nghttp2_session_get_stream_effective_local_window_size
(
nghttp2_session
*
session
,
int32_t
stream_id
)
{
nghttp2_stream
*
stream
;
stream
=
nghttp2_session_get_stream
(
session
,
stream_id
);
if
(
stream
==
NULL
)
{
return
-
1
;
}
return
stream
->
local_window_size
;
}
int
nghttp2_session_set_option
(
nghttp2_session
*
session
,
int
optname
,
void
*
optval
,
size_t
optlen
)
{
...
...
src/shrpx_http2_upstream.cc
View file @
6c23c34d
...
...
@@ -723,12 +723,13 @@ int Http2Upstream::rst_stream(Downstream *downstream,
return
0
;
}
int
Http2Upstream
::
window_update
(
Downstream
*
downstream
)
int
Http2Upstream
::
window_update
(
Downstream
*
downstream
,
int32_t
window_size_increment
)
{
int
rv
;
rv
=
nghttp2_submit_window_update
(
session_
,
NGHTTP2_FLAG_NONE
,
downstream
->
get_stream_id
(),
downstream
->
get_recv_window_size
()
);
window_size_increment
);
downstream
->
set_recv_window_size
(
0
);
if
(
rv
<
NGHTTP2_ERR_FATAL
)
{
ULOG
(
FATAL
,
this
)
<<
"nghttp2_submit_window_update() failed: "
...
...
@@ -962,8 +963,15 @@ void Http2Upstream::pause_read(IOCtrlReason reason)
int
Http2Upstream
::
resume_read
(
IOCtrlReason
reason
,
Downstream
*
downstream
)
{
if
(
get_flow_control
())
{
if
(
downstream
->
get_recv_window_size
()
>=
get_initial_window_size
()
/
2
)
{
window_update
(
downstream
);
int32_t
recv_length
,
window_size
;
recv_length
=
nghttp2_session_get_stream_effective_recv_data_length
(
session_
,
downstream
->
get_stream_id
());
window_size
=
nghttp2_session_get_stream_effective_local_window_size
(
session_
,
downstream
->
get_stream_id
());
if
(
recv_length
!=
-
1
&&
window_size
!=
-
1
)
{
if
(
recv_length
>=
window_size
/
2
)
{
window_update
(
downstream
,
recv_length
);
}
}
}
return
send
();
...
...
src/shrpx_http2_upstream.h
View file @
6c23c34d
...
...
@@ -58,7 +58,7 @@ public:
nghttp2_session
*
get_spdy_session
();
int
rst_stream
(
Downstream
*
downstream
,
nghttp2_error_code
error_code
);
int
window_update
(
Downstream
*
downstream
);
int
window_update
(
Downstream
*
downstream
,
int32_t
window_size_increment
);
int
error_reply
(
Downstream
*
downstream
,
unsigned
int
status_code
);
virtual
void
pause_read
(
IOCtrlReason
reason
);
...
...
src/shrpx_spdy_downstream_connection.cc
View file @
6c23c34d
...
...
@@ -442,14 +442,20 @@ int SpdyDownstreamConnection::resume_read(IOCtrlReason reason)
int
rv
;
if
(
spdy_
->
get_state
()
==
SpdySession
::
CONNECTED
&&
spdy_
->
get_flow_control
()
&&
downstream_
&&
downstream_
->
get_downstream_stream_id
()
!=
-
1
&&
recv_window_size_
>=
spdy_
->
get_initial_window_size
()
/
2
)
{
rv
=
spdy_
->
submit_window_update
(
this
,
recv_window_size_
);
if
(
rv
==
-
1
)
{
return
-
1
;
downstream_
&&
downstream_
->
get_downstream_stream_id
()
!=
-
1
)
{
int32_t
recv_length
,
window_size
;
recv_length
=
spdy_
->
get_stream_effective_recv_data_length
(
downstream_
->
get_stream_id
());
window_size
=
spdy_
->
get_stream_effective_local_window_size
(
downstream_
->
get_stream_id
());
if
(
recv_length
>=
window_size
/
2
)
{
rv
=
spdy_
->
submit_window_update
(
this
,
recv_length
);
if
(
rv
==
-
1
)
{
return
-
1
;
}
spdy_
->
notify
();
recv_window_size_
=
0
;
}
spdy_
->
notify
();
recv_window_size_
=
0
;
}
return
0
;
}
...
...
src/shrpx_spdy_session.cc
View file @
6c23c34d
...
...
@@ -618,6 +618,18 @@ int32_t SpdySession::get_initial_window_size() const
return
(
1
<<
get_config
()
->
spdy_downstream_window_bits
)
-
1
;
}
int32_t
SpdySession
::
get_stream_effective_recv_data_length
(
int32_t
stream_id
)
{
return
nghttp2_session_get_stream_effective_recv_data_length
(
session_
,
stream_id
);
}
int32_t
SpdySession
::
get_stream_effective_local_window_size
(
int32_t
stream_id
)
{
return
nghttp2_session_get_stream_effective_local_window_size
(
session_
,
stream_id
);
}
bool
SpdySession
::
get_flow_control
()
const
{
return
flow_control_
;
...
...
src/shrpx_spdy_session.h
View file @
6c23c34d
...
...
@@ -74,6 +74,9 @@ public:
int32_t
get_initial_window_size
()
const
;
int32_t
get_stream_effective_recv_data_length
(
int32_t
stream_id
);
int32_t
get_stream_effective_local_window_size
(
int32_t
stream_id
);
bool
get_flow_control
()
const
;
int
resume_data
(
SpdyDownstreamConnection
*
dconn
);
...
...
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