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
00a8c378
Commit
00a8c378
authored
Oct 10, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Add --backend-connect-timeout option
parent
75493410
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
53 additions
and
4 deletions
+53
-4
gennghttpxfun.py
gennghttpxfun.py
+1
-0
src/shrpx.cc
src/shrpx.cc
+13
-0
src/shrpx_config.cc
src/shrpx_config.cc
+8
-0
src/shrpx_config.h
src/shrpx_config.h
+4
-0
src/shrpx_http2_session.cc
src/shrpx_http2_session.cc
+11
-2
src/shrpx_http_downstream_connection.cc
src/shrpx_http_downstream_connection.cc
+7
-1
src/shrpx_live_check.cc
src/shrpx_live_check.cc
+9
-1
No files found.
gennghttpxfun.py
View file @
00a8c378
...
...
@@ -148,6 +148,7 @@ OPTIONS = [
"backend-http2-decoder-dynamic-table-size"
,
"ecdh-curves"
,
"tls-sct-dir"
,
"backend-connect-timeout"
,
]
LOGVARS
=
[
...
...
src/shrpx.cc
View file @
00a8c378
...
...
@@ -1442,6 +1442,7 @@ void fill_default_config(Config *config) {
timeoutconf
.
write
=
30
_s
;
// Timeout for pooled (idle) connections
timeoutconf
.
idle_read
=
2
_s
;
timeoutconf
.
connect
=
30
_s
;
timeoutconf
.
max_backoff
=
120
_s
;
}
...
...
@@ -1787,6 +1788,11 @@ Timeout:
Specify write timeout for backend connection.
Default: )"
<<
util
::
duration_str
(
config
->
conn
.
downstream
->
timeout
.
write
)
<<
R"(
--backend-connect-timeout=<DURATION>
Specify timeout before establishing TCP connection to
backend.
Default: )"
<<
util
::
duration_str
(
config
->
conn
.
downstream
->
timeout
.
connect
)
<<
R"(
--backend-keep-alive-timeout=<DURATION>
Specify keep-alive timeout for backend connection.
Default: )"
...
...
@@ -2956,6 +2962,8 @@ int main(int argc, char **argv) {
required_argument
,
&
flag
,
139
},
{
SHRPX_OPT_ECDH_CURVES
.
c_str
(),
required_argument
,
&
flag
,
140
},
{
SHRPX_OPT_TLS_SCT_DIR
.
c_str
(),
required_argument
,
&
flag
,
141
},
{
SHRPX_OPT_BACKEND_CONNECT_TIMEOUT
.
c_str
(),
required_argument
,
&
flag
,
142
},
{
nullptr
,
0
,
nullptr
,
0
}};
int
option_index
=
0
;
...
...
@@ -3624,6 +3632,11 @@ int main(int argc, char **argv) {
// --tls-sct-dir
cmdcfgs
.
emplace_back
(
SHRPX_OPT_TLS_SCT_DIR
,
StringRef
{
optarg
});
break
;
case
142
:
// --backend-connect-timeout
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_CONNECT_TIMEOUT
,
StringRef
{
optarg
});
break
;
default:
break
;
}
...
...
src/shrpx_config.cc
View file @
00a8c378
...
...
@@ -1657,6 +1657,11 @@ int option_lookup_token(const char *name, size_t namelen) {
return
SHRPX_OPTID_BACKEND_RESPONSE_BUFFER
;
}
break
;
case
't'
:
if
(
util
::
strieq_l
(
"backend-connect-timeou"
,
name
,
22
))
{
return
SHRPX_OPTID_BACKEND_CONNECT_TIMEOUT
;
}
break
;
}
break
;
case
24
:
...
...
@@ -2162,6 +2167,9 @@ int parse_config(Config *config, int optid, const StringRef &opt,
return
parse_duration
(
&
config
->
conn
.
downstream
->
timeout
.
read
,
opt
,
optarg
);
case
SHRPX_OPTID_BACKEND_WRITE_TIMEOUT
:
return
parse_duration
(
&
config
->
conn
.
downstream
->
timeout
.
write
,
opt
,
optarg
);
case
SHRPX_OPTID_BACKEND_CONNECT_TIMEOUT
:
return
parse_duration
(
&
config
->
conn
.
downstream
->
timeout
.
connect
,
opt
,
optarg
);
case
SHRPX_OPTID_STREAM_READ_TIMEOUT
:
return
parse_duration
(
&
config
->
http2
.
timeout
.
stream_read
,
opt
,
optarg
);
case
SHRPX_OPTID_STREAM_WRITE_TIMEOUT
:
...
...
src/shrpx_config.h
View file @
00a8c378
...
...
@@ -310,6 +310,8 @@ constexpr auto SHRPX_OPT_BACKEND_HTTP2_DECODER_DYNAMIC_TABLE_SIZE =
StringRef
::
from_lit
(
"backend-http2-decoder-dynamic-table-size"
);
constexpr
auto
SHRPX_OPT_ECDH_CURVES
=
StringRef
::
from_lit
(
"ecdh-curves"
);
constexpr
auto
SHRPX_OPT_TLS_SCT_DIR
=
StringRef
::
from_lit
(
"tls-sct-dir"
);
constexpr
auto
SHRPX_OPT_BACKEND_CONNECT_TIMEOUT
=
StringRef
::
from_lit
(
"backend-connect-timeout"
);
constexpr
size_t
SHRPX_OBFUSCATED_NODE_LENGTH
=
8
;
...
...
@@ -718,6 +720,7 @@ struct DownstreamConfig {
ev_tstamp
read
;
ev_tstamp
write
;
ev_tstamp
idle_read
;
ev_tstamp
connect
;
// The maximum backoff while checking health check for offline
// backend or while detaching failed backend from load balancing
// group temporarily.
...
...
@@ -850,6 +853,7 @@ enum {
SHRPX_OPTID_API_MAX_REQUEST_BODY
,
SHRPX_OPTID_BACKEND
,
SHRPX_OPTID_BACKEND_ADDRESS_FAMILY
,
SHRPX_OPTID_BACKEND_CONNECT_TIMEOUT
,
SHRPX_OPTID_BACKEND_CONNECTIONS_PER_FRONTEND
,
SHRPX_OPTID_BACKEND_CONNECTIONS_PER_HOST
,
SHRPX_OPTID_BACKEND_HTTP_PROXY_URI
,
...
...
src/shrpx_http2_session.cc
View file @
00a8c378
...
...
@@ -313,6 +313,8 @@ int Http2Session::initiate_connection() {
}
}
auto
&
downstreamconf
=
*
get_config
()
->
conn
.
downstream
;
const
auto
&
proxy
=
get_config
()
->
downstream_http_proxy
;
if
(
!
proxy
.
host
.
empty
()
&&
state_
==
DISCONNECTED
)
{
if
(
LOG_ENABLED
(
INFO
))
{
...
...
@@ -351,7 +353,7 @@ int Http2Session::initiate_connection() {
conn_
.
wlimit
.
startw
();
// TODO we should have timeout for connection establishment
conn_
.
wt
.
repeat
=
downstreamconf
.
timeout
.
connect
;
ev_timer_again
(
conn_
.
loop
,
&
conn_
.
wt
);
write_
=
&
Http2Session
::
connected
;
...
...
@@ -484,7 +486,8 @@ int Http2Session::initiate_connection() {
if
(
state_
!=
CONNECTED
)
{
state_
=
CONNECTING
;
conn_
.
wlimit
.
startw
();
// TODO we should have timeout for connection establishment
conn_
.
wt
.
repeat
=
downstreamconf
.
timeout
.
connect
;
ev_timer_again
(
conn_
.
loop
,
&
conn_
.
wt
);
}
else
{
conn_
.
rlimit
.
startw
();
...
...
@@ -1857,6 +1860,12 @@ int Http2Session::connected() {
SSLOG
(
INFO
,
this
)
<<
"Connection established"
;
}
auto
&
downstreamconf
=
*
get_config
()
->
conn
.
downstream
;
// Reset timeout for write. Previously, we set timeout for connect.
conn_
.
wt
.
repeat
=
downstreamconf
.
timeout
.
write
;
ev_timer_again
(
conn_
.
loop
,
&
conn_
.
wt
);
conn_
.
rlimit
.
startw
();
read_
=
&
Http2Session
::
read_clear
;
...
...
src/shrpx_http_downstream_connection.cc
View file @
00a8c378
...
...
@@ -315,7 +315,7 @@ int HttpDownstreamConnection::attach_downstream(Downstream *downstream) {
break
;
}
// TODO we should have timeout for connection establishment
conn_
.
wt
.
repeat
=
downstreamconf
.
timeout
.
connect
;
ev_timer_again
(
conn_
.
loop
,
&
conn_
.
wt
);
}
else
{
// we may set read timer cb to idle_timeoutcb. Reset again.
...
...
@@ -1178,6 +1178,12 @@ int HttpDownstreamConnection::connected() {
DCLOG
(
INFO
,
this
)
<<
"Connected to downstream host"
;
}
auto
&
downstreamconf
=
*
get_config
()
->
conn
.
downstream
;
// Reset timeout for write. Previously, we set timeout for connect.
conn_
.
wt
.
repeat
=
downstreamconf
.
timeout
.
write
;
ev_timer_again
(
conn_
.
loop
,
&
conn_
.
wt
);
conn_
.
rlimit
.
startw
();
ev_set_cb
(
&
conn_
.
wev
,
writecb
);
...
...
src/shrpx_live_check.cc
View file @
00a8c378
...
...
@@ -252,7 +252,9 @@ int LiveCheck::initiate_connection() {
conn_
.
wlimit
.
startw
();
// TODO we should have timeout for connection establishment
auto
&
downstreamconf
=
*
get_config
()
->
conn
.
downstream
;
conn_
.
wt
.
repeat
=
downstreamconf
.
timeout
.
connect
;
ev_timer_again
(
conn_
.
loop
,
&
conn_
.
wt
);
return
0
;
...
...
@@ -274,6 +276,12 @@ int LiveCheck::connected() {
LOG
(
INFO
)
<<
"Connection established"
;
}
auto
&
downstreamconf
=
*
get_config
()
->
conn
.
downstream
;
// Reset timeout for write. Previously, we set timeout for connect.
conn_
.
wt
.
repeat
=
downstreamconf
.
timeout
.
write
;
ev_timer_again
(
conn_
.
loop
,
&
conn_
.
wt
);
conn_
.
rlimit
.
startw
();
if
(
conn_
.
tls
.
ssl
)
{
...
...
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