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
5770c6bd
Commit
5770c6bd
authored
Jan 21, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Return 503 on hard disconnect in HTTP/2 backend
parent
7492f628
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
92 additions
and
15 deletions
+92
-15
integration-tests/nghttpx_test.go
integration-tests/nghttpx_test.go
+57
-0
src/shrpx_http2_session.cc
src/shrpx_http2_session.cc
+1
-5
src/shrpx_http2_upstream.cc
src/shrpx_http2_upstream.cc
+10
-2
src/shrpx_http2_upstream.h
src/shrpx_http2_upstream.h
+1
-1
src/shrpx_https_upstream.cc
src/shrpx_https_upstream.cc
+8
-1
src/shrpx_https_upstream.h
src/shrpx_https_upstream.h
+1
-1
src/shrpx_spdy_upstream.cc
src/shrpx_spdy_upstream.cc
+10
-2
src/shrpx_spdy_upstream.h
src/shrpx_spdy_upstream.h
+1
-1
src/shrpx_upstream.h
src/shrpx_upstream.h
+3
-2
No files found.
integration-tests/nghttpx_test.go
View file @
5770c6bd
...
...
@@ -95,6 +95,25 @@ func TestH1H1ConnectFailure(t *testing.T) {
}
}
func
TestH1H2ConnectFailure
(
t
*
testing
.
T
)
{
st
:=
newServerTester
([]
string
{
"--http2-bridge"
},
t
,
noopHandler
)
defer
st
.
Close
()
// simulate backend connect attempt failure
st
.
ts
.
Close
()
res
,
err
:=
st
.
http1
(
requestParam
{
name
:
"TestH1H2ConnectFailure"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http1() = %v"
,
err
)
}
want
:=
503
if
got
:=
res
.
status
;
got
!=
want
{
t
.
Errorf
(
"status: %v; want %v"
,
got
,
want
)
}
}
func
TestH1H2NoHost
(
t
*
testing
.
T
)
{
st
:=
newServerTester
([]
string
{
"--http2-bridge"
},
t
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
t
.
Errorf
(
"server should not forward bad request"
)
...
...
@@ -409,6 +428,25 @@ func TestH2H2InvalidResponseCL(t *testing.T) {
}
}
func
TestH2H2ConnectFailure
(
t
*
testing
.
T
)
{
st
:=
newServerTester
([]
string
{
"--http2-bridge"
},
t
,
noopHandler
)
defer
st
.
Close
()
// simulate backend connect attempt failure
st
.
ts
.
Close
()
res
,
err
:=
st
.
http2
(
requestParam
{
name
:
"TestH2H2ConnectFailure"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http2() = %v"
,
err
)
}
want
:=
503
if
got
:=
res
.
status
;
got
!=
want
{
t
.
Errorf
(
"status: %v; want %v"
,
got
,
want
)
}
}
func
TestS3H1PlainGET
(
t
*
testing
.
T
)
{
st
:=
newServerTesterTLS
([]
string
{
"--npn-list=spdy/3.1"
},
t
,
noopHandler
)
defer
st
.
Close
()
...
...
@@ -492,3 +530,22 @@ func TestS3H1InvalidRequestCL(t *testing.T) {
t
.
Errorf
(
"status: %v; want %v"
,
got
,
want
)
}
}
func
TestS3H2ConnectFailure
(
t
*
testing
.
T
)
{
st
:=
newServerTesterTLS
([]
string
{
"--npn-list=spdy/3.1"
,
"--http2-bridge"
},
t
,
noopHandler
)
defer
st
.
Close
()
// simulate backend connect attempt failure
st
.
ts
.
Close
()
res
,
err
:=
st
.
spdy
(
requestParam
{
name
:
"TestS3H2ConnectFailure"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.spdy() = %v"
,
err
)
}
want
:=
503
if
got
:=
res
.
status
;
got
!=
want
{
t
.
Errorf
(
"status: %v; want %v"
,
got
,
want
)
}
}
src/shrpx_http2_session.cc
View file @
5770c6bd
...
...
@@ -239,11 +239,7 @@ int Http2Session::disconnect(bool hard) {
handlers
.
insert
(
dc
->
get_client_handler
());
}
for
(
auto
h
:
handlers
)
{
if
(
hard
)
{
delete
h
;
continue
;
}
if
(
h
->
get_upstream
()
->
on_downstream_reset
()
!=
0
)
{
if
(
h
->
get_upstream
()
->
on_downstream_reset
(
hard
)
!=
0
)
{
delete
h
;
}
}
...
...
src/shrpx_http2_upstream.cc
View file @
5770c6bd
...
...
@@ -1345,7 +1345,7 @@ void Http2Upstream::on_handler_delete() {
}
}
int
Http2Upstream
::
on_downstream_reset
()
{
int
Http2Upstream
::
on_downstream_reset
(
bool
no_retry
)
{
int
rv
;
for
(
auto
&
ent
:
downstream_queue_
.
get_active_downstreams
())
{
...
...
@@ -1358,9 +1358,17 @@ int Http2Upstream::on_downstream_reset() {
continue
;
}
downstream
->
pop_downstream_connection
();
if
(
no_retry
)
{
if
(
on_downstream_abort_request
(
downstream
,
503
)
!=
0
)
{
return
-
1
;
}
continue
;
}
// downstream connection is clean; we can retry with new
// downstream connection.
downstream
->
pop_downstream_connection
();
rv
=
downstream
->
attach_downstream_connection
(
handler_
->
get_downstream_connection
());
...
...
src/shrpx_http2_upstream.h
View file @
5770c6bd
...
...
@@ -80,7 +80,7 @@ public:
virtual
int
on_downstream_body_complete
(
Downstream
*
downstream
);
virtual
void
on_handler_delete
();
virtual
int
on_downstream_reset
();
virtual
int
on_downstream_reset
(
bool
no_retry
);
virtual
MemchunkPool
*
get_mcpool
();
...
...
src/shrpx_https_upstream.cc
View file @
5770c6bd
...
...
@@ -815,7 +815,7 @@ void HttpsUpstream::on_handler_delete() {
}
}
int
HttpsUpstream
::
on_downstream_reset
()
{
int
HttpsUpstream
::
on_downstream_reset
(
bool
no_retry
)
{
int
rv
;
if
((
downstream_
->
get_request_state
()
!=
Downstream
::
HEADER_COMPLETE
&&
...
...
@@ -825,6 +825,13 @@ int HttpsUpstream::on_downstream_reset() {
return
-
1
;
}
if
(
no_retry
)
{
if
(
on_downstream_abort_request
(
downstream_
.
get
(),
503
)
!=
0
)
{
return
-
1
;
}
return
0
;
}
downstream_
->
pop_downstream_connection
();
rv
=
downstream_
->
attach_downstream_connection
(
...
...
src/shrpx_https_upstream.h
View file @
5770c6bd
...
...
@@ -74,7 +74,7 @@ public:
virtual
int
on_downstream_body_complete
(
Downstream
*
downstream
);
virtual
void
on_handler_delete
();
virtual
int
on_downstream_reset
();
virtual
int
on_downstream_reset
(
bool
no_retry
);
virtual
MemchunkPool
*
get_mcpool
();
...
...
src/shrpx_spdy_upstream.cc
View file @
5770c6bd
...
...
@@ -1028,7 +1028,7 @@ void SpdyUpstream::on_handler_delete() {
}
}
int
SpdyUpstream
::
on_downstream_reset
()
{
int
SpdyUpstream
::
on_downstream_reset
(
bool
no_retry
)
{
int
rv
;
for
(
auto
&
ent
:
downstream_queue_
.
get_active_downstreams
())
{
...
...
@@ -1041,9 +1041,17 @@ int SpdyUpstream::on_downstream_reset() {
continue
;
}
downstream
->
pop_downstream_connection
();
if
(
no_retry
)
{
if
(
on_downstream_abort_request
(
downstream
,
503
)
!=
0
)
{
return
-
1
;
}
return
0
;
}
// downstream connection is clean; we can retry with new
// downstream connection.
downstream
->
pop_downstream_connection
();
rv
=
downstream
->
attach_downstream_connection
(
handler_
->
get_downstream_connection
());
...
...
src/shrpx_spdy_upstream.h
View file @
5770c6bd
...
...
@@ -75,7 +75,7 @@ public:
virtual
int
on_downstream_body_complete
(
Downstream
*
downstream
);
virtual
void
on_handler_delete
();
virtual
int
on_downstream_reset
();
virtual
int
on_downstream_reset
(
bool
no_retry
);
virtual
MemchunkPool
*
get_mcpool
();
...
...
src/shrpx_upstream.h
View file @
5770c6bd
...
...
@@ -58,8 +58,9 @@ public:
virtual
void
on_handler_delete
()
=
0
;
// Called when downstream connection is reset. Currently this is
// only used by Http2Session.
virtual
int
on_downstream_reset
()
=
0
;
// only used by Http2Session. If |no_retry| is true, another
// connection attempt using new DownstreamConnection is not allowed.
virtual
int
on_downstream_reset
(
bool
no_retry
)
=
0
;
virtual
void
pause_read
(
IOCtrlReason
reason
)
=
0
;
virtual
int
resume_read
(
IOCtrlReason
reason
,
Downstream
*
downstream
,
...
...
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