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
44cbc785
Commit
44cbc785
authored
Jul 22, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Don't reuse backend connection if it is not clean
parent
f3288092
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
39 deletions
+25
-39
src/shrpx_downstream.cc
src/shrpx_downstream.cc
+6
-0
src/shrpx_downstream.h
src/shrpx_downstream.h
+3
-0
src/shrpx_http2_upstream.cc
src/shrpx_http2_upstream.cc
+7
-18
src/shrpx_https_upstream.cc
src/shrpx_https_upstream.cc
+3
-5
src/shrpx_spdy_upstream.cc
src/shrpx_spdy_upstream.cc
+6
-16
No files found.
src/shrpx_downstream.cc
View file @
44cbc785
...
...
@@ -1207,4 +1207,10 @@ void Downstream::add_request_headers_sum(size_t amount) {
request_headers_sum_
+=
amount
;
}
bool
Downstream
::
can_detach_downstream_connection
()
const
{
return
dconn_
&&
response_state_
==
Downstream
::
MSG_COMPLETE
&&
request_state_
==
Downstream
::
MSG_COMPLETE
&&
!
upgraded_
&&
!
response_connection_close_
;
}
}
// namespace shrpx
src/shrpx_downstream.h
View file @
44cbc785
...
...
@@ -332,6 +332,9 @@ public:
void
attach_blocked_link
(
BlockedLink
*
l
);
BlockedLink
*
detach_blocked_link
();
// Returns true if downstream_connection can be detached and reused.
bool
can_detach_downstream_connection
()
const
;
enum
{
EVENT_ERROR
=
0x1
,
EVENT_TIMEOUT
=
0x2
,
...
...
src/shrpx_http2_upstream.cc
View file @
44cbc785
...
...
@@ -74,22 +74,13 @@ int on_stream_close_callback(nghttp2_session *session, int32_t stream_id,
return
0
;
}
downstream
->
set_request_state
(
Downstream
::
STREAM_CLOSED
);
if
(
downstream
->
get_response_state
()
==
Downstream
::
MSG_COMPLETE
)
{
// At this point, downstream response was read
if
(
!
downstream
->
get_upgraded
()
&&
!
downstream
->
get_response_connection_close
())
{
// Keep-alive
downstream
->
detach_downstream_connection
();
}
upstream
->
remove_downstream
(
downstream
);
// downstream was deleted
return
0
;
if
(
downstream
->
can_detach_downstream_connection
())
{
// Keep-alive
downstream
->
detach_downstream_connection
();
}
downstream
->
set_request_state
(
Downstream
::
STREAM_CLOSED
);
// At this point, downstream read may be paused.
// If shrpx_downstream::push_request_headers() failed, the
...
...
@@ -915,10 +906,8 @@ int Http2Upstream::downstream_read(DownstreamConnection *dconn) {
}
return
downstream_error
(
dconn
,
Downstream
::
EVENT_ERROR
);
}
// Detach downstream connection early so that it could be reused
// without hitting server's request timeout.
if
(
downstream
->
get_response_state
()
==
Downstream
::
MSG_COMPLETE
&&
!
downstream
->
get_response_connection_close
())
{
if
(
downstream
->
can_detach_downstream_connection
())
{
// Keep-alive
downstream
->
detach_downstream_connection
();
}
...
...
src/shrpx_https_upstream.cc
View file @
44cbc785
...
...
@@ -540,7 +540,8 @@ int HttpsUpstream::on_write() {
// We need to postpone detachment until all data are sent so that
// we can notify nghttp2 library all data consumed.
if
(
downstream
->
get_response_state
()
==
Downstream
::
MSG_COMPLETE
)
{
if
(
downstream
->
get_response_connection_close
())
{
if
(
downstream
->
get_response_connection_close
()
||
downstream
->
get_request_state
()
!=
Downstream
::
MSG_COMPLETE
)
{
// Connection close
downstream
->
pop_downstream_connection
();
// dconn was deleted
...
...
@@ -607,10 +608,7 @@ int HttpsUpstream::downstream_read(DownstreamConnection *dconn) {
goto
end
;
}
// Detach downstream connection early so that it could be reused
// without hitting server's request timeout.
if
(
downstream
->
get_response_state
()
==
Downstream
::
MSG_COMPLETE
&&
!
downstream
->
get_response_connection_close
())
{
if
(
downstream
->
can_detach_downstream_connection
())
{
// Keep-alive
downstream
->
detach_downstream_connection
();
}
...
...
src/shrpx_spdy_upstream.cc
View file @
44cbc785
...
...
@@ -109,20 +109,13 @@ void on_stream_close_callback(spdylay_session *session, int32_t stream_id,
return
;
}
downstream
->
set_request_state
(
Downstream
::
STREAM_CLOSED
);
if
(
downstream
->
get_response_state
()
==
Downstream
::
MSG_COMPLETE
)
{
// At this point, downstream response was read
if
(
!
downstream
->
get_upgraded
()
&&
!
downstream
->
get_response_connection_close
())
{
// Keep-alive
downstream
->
detach_downstream_connection
();
}
upstream
->
remove_downstream
(
downstream
);
// downstrea was deleted
return
;
if
(
downstream
->
can_detach_downstream_connection
())
{
// Keep-alive
downstream
->
detach_downstream_connection
();
}
downstream
->
set_request_state
(
Downstream
::
STREAM_CLOSED
);
// At this point, downstream read may be paused.
// If shrpx_downstream::push_request_headers() failed, the
...
...
@@ -589,10 +582,7 @@ int SpdyUpstream::downstream_read(DownstreamConnection *dconn) {
}
return
downstream_error
(
dconn
,
Downstream
::
EVENT_ERROR
);
}
// Detach downstream connection early so that it could be reused
// without hitting server's request timeout.
if
(
downstream
->
get_response_state
()
==
Downstream
::
MSG_COMPLETE
&&
!
downstream
->
get_response_connection_close
())
{
if
(
downstream
->
can_detach_downstream_connection
())
{
// Keep-alive
downstream
->
detach_downstream_connection
();
}
...
...
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