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
f2a1fadd
Commit
f2a1fadd
authored
May 24, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Make backend fail if connect operation was timed out
parent
98396f00
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
4 deletions
+42
-4
src/shrpx_http_downstream_connection.cc
src/shrpx_http_downstream_connection.cc
+39
-3
src/shrpx_http_downstream_connection.h
src/shrpx_http_downstream_connection.h
+3
-1
No files found.
src/shrpx_http_downstream_connection.cc
View file @
f2a1fadd
...
...
@@ -66,6 +66,31 @@ void timeoutcb(struct ev_loop *loop, ev_timer *w, int revents) {
}
}
// namespace
namespace
{
void
connect_timeoutcb
(
struct
ev_loop
*
loop
,
ev_timer
*
w
,
int
revents
)
{
auto
conn
=
static_cast
<
Connection
*>
(
w
->
data
);
auto
dconn
=
static_cast
<
HttpDownstreamConnection
*>
(
conn
->
data
);
if
(
LOG_ENABLED
(
INFO
))
{
DCLOG
(
INFO
,
dconn
)
<<
"Connect time out"
;
}
downstream_failure
(
dconn
->
get_addr
());
auto
downstream
=
dconn
->
get_downstream
();
auto
upstream
=
downstream
->
get_upstream
();
auto
handler
=
upstream
->
get_client_handler
();
auto
&
resp
=
downstream
->
response
();
// Do this so that dconn is not pooled
resp
.
connection_close
=
true
;
if
(
upstream
->
downstream_error
(
dconn
,
Downstream
::
EVENT_TIMEOUT
)
!=
0
)
{
delete
handler
;
}
}
}
// namespace
namespace
{
void
readcb
(
struct
ev_loop
*
loop
,
ev_io
*
w
,
int
revents
)
{
auto
conn
=
static_cast
<
Connection
*>
(
w
->
data
);
...
...
@@ -128,7 +153,8 @@ HttpDownstreamConnection::HttpDownstreamConnection(DownstreamAddrGroup *group,
:
conn_
(
loop
,
-
1
,
nullptr
,
worker
->
get_mcpool
(),
get_config
()
->
conn
.
downstream
.
timeout
.
write
,
get_config
()
->
conn
.
downstream
.
timeout
.
read
,
{},
{},
connectcb
,
readcb
,
timeoutcb
,
this
,
get_config
()
->
tls
.
dyn_rec
.
warmup_threshold
,
readcb
,
connect_timeoutcb
,
this
,
get_config
()
->
tls
.
dyn_rec
.
warmup_threshold
,
get_config
()
->
tls
.
dyn_rec
.
idle_timeout
,
PROTO_HTTP1
),
do_read_
(
&
HttpDownstreamConnection
::
noop
),
do_write_
(
&
HttpDownstreamConnection
::
noop
),
...
...
@@ -920,6 +946,12 @@ int HttpDownstreamConnection::tls_handshake() {
}
}
auto
&
connect_blocker
=
addr_
->
connect_blocker
;
connect_blocker
->
on_success
();
conn_
.
timeoutcb
=
timeoutcb
;
do_read_
=
&
HttpDownstreamConnection
::
read_tls
;
do_write_
=
&
HttpDownstreamConnection
::
write_tls
;
...
...
@@ -1082,8 +1114,6 @@ int HttpDownstreamConnection::connected() {
DCLOG
(
INFO
,
this
)
<<
"Connected to downstream host"
;
}
connect_blocker
->
on_success
();
conn_
.
rlimit
.
startw
();
ev_set_cb
(
&
conn_
.
wev
,
writecb
);
...
...
@@ -1097,6 +1127,10 @@ int HttpDownstreamConnection::connected() {
return
0
;
}
connect_blocker
->
on_success
();
conn_
.
timeoutcb
=
timeoutcb
;
do_read_
=
&
HttpDownstreamConnection
::
read_clear
;
do_write_
=
&
HttpDownstreamConnection
::
write_clear
;
...
...
@@ -1123,4 +1157,6 @@ HttpDownstreamConnection::get_downstream_addr_group() const {
return
group_
;
}
DownstreamAddr
*
HttpDownstreamConnection
::
get_addr
()
const
{
return
addr_
;
}
}
// namespace shrpx
src/shrpx_http_downstream_connection.h
View file @
f2a1fadd
...
...
@@ -79,6 +79,8 @@ public:
int
noop
();
DownstreamAddr
*
get_addr
()
const
;
private:
Connection
conn_
;
std
::
function
<
int
(
HttpDownstreamConnection
&
)
>
do_read_
,
do_write_
,
...
...
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