nghttpx: Add --frontend-http3-read-timeout option

Add --frontend-http3-read-timeout option.  QUIC idle timeout option
will be added later.
This commit is contained in:
Tatsuhiro Tsujikawa 2021-08-27 18:29:06 +09:00
parent bed00fb8e1
commit 717e7ae8b2
5 changed files with 29 additions and 0 deletions

View File

@ -180,6 +180,7 @@ OPTIONS = [
"bpf-program-file",
"no-bpf",
"http2-altsvc",
"frontend-http3-read-timeout",
]
LOGVARS = [

View File

@ -1590,6 +1590,9 @@ void fill_default_config(Config *config) {
// Read timeout for HTTP2 upstream connection
timeoutconf.http2_read = 3_min;
// Read timeout for HTTP3 upstream connection
timeoutconf.http3_read = 3_min;
// Read timeout for non-HTTP2 upstream connection
timeoutconf.read = 1_min;
@ -2073,6 +2076,10 @@ Timeout:
Specify read timeout for HTTP/2 frontend connection.
Default: )"
<< util::duration_str(config->conn.upstream.timeout.http2_read) << R"(
--frontend-http3-read-timeout=<DURATION>
Specify read timeout for HTTP/3 frontend connection.
Default: )"
<< util::duration_str(config->conn.upstream.timeout.http3_read) << R"(
--frontend-read-timeout=<DURATION>
Specify read timeout for HTTP/1.1 frontend connection.
Default: )"
@ -3589,6 +3596,8 @@ int main(int argc, char **argv) {
{SHRPX_OPT_BPF_PROGRAM_FILE.c_str(), required_argument, &flag, 169},
{SHRPX_OPT_NO_BPF.c_str(), no_argument, &flag, 170},
{SHRPX_OPT_HTTP2_ALTSVC.c_str(), required_argument, &flag, 171},
{SHRPX_OPT_FRONTEND_HTTP3_READ_TIMEOUT.c_str(), required_argument,
&flag, 172},
{nullptr, 0, nullptr, 0}};
int option_index = 0;
@ -4404,6 +4413,11 @@ int main(int argc, char **argv) {
// --http2-altsvc
cmdcfgs.emplace_back(SHRPX_OPT_HTTP2_ALTSVC, StringRef{optarg});
break;
case 172:
// --frontend-http3-read-timeout
cmdcfgs.emplace_back(SHRPX_OPT_FRONTEND_HTTP3_READ_TIMEOUT,
StringRef{optarg});
break;
default:
break;
}

View File

@ -519,6 +519,10 @@ void ClientHandler::setup_http3_upstream(
upstream_ = std::move(upstream);
alpn_ = StringRef::from_lit("h3");
write_ = &ClientHandler::write_quic;
auto config = get_config();
reset_upstream_read_timeout(config->conn.upstream.timeout.http3_read);
}
#endif // ENABLE_HTTP3

View File

@ -2393,6 +2393,9 @@ int option_lookup_token(const char *name, size_t namelen) {
if (util::strieq_l("frontend-http2-read-timeou", name, 26)) {
return SHRPX_OPTID_FRONTEND_HTTP2_READ_TIMEOUT;
}
if (util::strieq_l("frontend-http3-read-timeou", name, 26)) {
return SHRPX_OPTID_FRONTEND_HTTP3_READ_TIMEOUT;
}
if (util::strieq_l("frontend-keep-alive-timeou", name, 26)) {
return SHRPX_OPTID_FRONTEND_KEEP_ALIVE_TIMEOUT;
}
@ -3873,6 +3876,9 @@ int parse_config(Config *config, int optid, const StringRef &opt,
return 0;
}
case SHRPX_OPTID_FRONTEND_HTTP3_READ_TIMEOUT:
return parse_duration(&config->conn.upstream.timeout.http3_read, opt,
optarg);
case SHRPX_OPTID_CONF:
LOG(WARN) << "conf: ignored";

View File

@ -367,6 +367,8 @@ constexpr auto SHRPX_OPT_BPF_PROGRAM_FILE =
StringRef::from_lit("bpf-program-file");
constexpr auto SHRPX_OPT_NO_BPF = StringRef::from_lit("no-bpf");
constexpr auto SHRPX_OPT_HTTP2_ALTSVC = StringRef::from_lit("http2-altsvc");
constexpr auto SHRPX_OPT_FRONTEND_HTTP3_READ_TIMEOUT =
StringRef::from_lit("frontend-http3-read-timeout");
constexpr size_t SHRPX_OBFUSCATED_NODE_LENGTH = 8;
@ -955,6 +957,7 @@ struct ConnectionConfig {
struct {
struct {
ev_tstamp http2_read;
ev_tstamp http3_read;
ev_tstamp read;
ev_tstamp write;
ev_tstamp idle_read;
@ -1160,6 +1163,7 @@ enum {
SHRPX_OPTID_FRONTEND_HTTP2_SETTINGS_TIMEOUT,
SHRPX_OPTID_FRONTEND_HTTP2_WINDOW_BITS,
SHRPX_OPTID_FRONTEND_HTTP2_WINDOW_SIZE,
SHRPX_OPTID_FRONTEND_HTTP3_READ_TIMEOUT,
SHRPX_OPTID_FRONTEND_KEEP_ALIVE_TIMEOUT,
SHRPX_OPTID_FRONTEND_MAX_REQUESTS,
SHRPX_OPTID_FRONTEND_NO_TLS,