src: Use user-defined literals for time (hours and minutes)
This commit is contained in:
parent
39f89f4a60
commit
cebfdacc5a
|
@ -100,8 +100,8 @@ template <typename Array> void append_nv(Stream *stream, const Array &nva) {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Config::Config()
|
Config::Config()
|
||||||
: stream_read_timeout(60.), stream_write_timeout(60.), data_ptr(nullptr),
|
: stream_read_timeout(1_min), stream_write_timeout(1_min),
|
||||||
padding(0), num_worker(1), max_concurrent_streams(100),
|
data_ptr(nullptr), padding(0), num_worker(1), max_concurrent_streams(100),
|
||||||
header_table_size(-1), port(0), verbose(false), daemon(false),
|
header_table_size(-1), port(0), verbose(false), daemon(false),
|
||||||
verify_client(false), no_tls(false), error_gzip(false),
|
verify_client(false), no_tls(false), error_gzip(false),
|
||||||
early_response(false), hexdump(false), echo_upload(false) {}
|
early_response(false), hexdump(false), echo_upload(false) {}
|
||||||
|
|
11
src/shrpx.cc
11
src/shrpx.cc
|
@ -710,8 +710,7 @@ int event_loop() {
|
||||||
}
|
}
|
||||||
if (auto_tls_ticket_key) {
|
if (auto_tls_ticket_key) {
|
||||||
// Renew ticket key every 12hrs
|
// Renew ticket key every 12hrs
|
||||||
ev_timer_init(&renew_ticket_key_timer, renew_ticket_key_cb, 0.,
|
ev_timer_init(&renew_ticket_key_timer, renew_ticket_key_cb, 0., 12_h);
|
||||||
12 * 3600.);
|
|
||||||
renew_ticket_key_timer.data = conn_handler.get();
|
renew_ticket_key_timer.data = conn_handler.get();
|
||||||
ev_timer_again(loop, &renew_ticket_key_timer);
|
ev_timer_again(loop, &renew_ticket_key_timer);
|
||||||
|
|
||||||
|
@ -831,16 +830,16 @@ void fill_default_config() {
|
||||||
mod_config()->cert_file = nullptr;
|
mod_config()->cert_file = nullptr;
|
||||||
|
|
||||||
// Read timeout for HTTP2 upstream connection
|
// Read timeout for HTTP2 upstream connection
|
||||||
mod_config()->http2_upstream_read_timeout = 180.;
|
mod_config()->http2_upstream_read_timeout = 3_min;
|
||||||
|
|
||||||
// Read timeout for non-HTTP2 upstream connection
|
// Read timeout for non-HTTP2 upstream connection
|
||||||
mod_config()->upstream_read_timeout = 180.;
|
mod_config()->upstream_read_timeout = 3_min;
|
||||||
|
|
||||||
// Write timeout for HTTP2/non-HTTP2 upstream connection
|
// Write timeout for HTTP2/non-HTTP2 upstream connection
|
||||||
mod_config()->upstream_write_timeout = 30.;
|
mod_config()->upstream_write_timeout = 30.;
|
||||||
|
|
||||||
// Read/Write timeouts for downstream connection
|
// Read/Write timeouts for downstream connection
|
||||||
mod_config()->downstream_read_timeout = 180.;
|
mod_config()->downstream_read_timeout = 3_min;
|
||||||
mod_config()->downstream_write_timeout = 30.;
|
mod_config()->downstream_write_timeout = 30.;
|
||||||
|
|
||||||
// Read timeout for HTTP/2 stream
|
// Read timeout for HTTP/2 stream
|
||||||
|
@ -951,7 +950,7 @@ void fill_default_config() {
|
||||||
mod_config()->host_unix = false;
|
mod_config()->host_unix = false;
|
||||||
mod_config()->http2_downstream_connections_per_worker = 0;
|
mod_config()->http2_downstream_connections_per_worker = 0;
|
||||||
// ocsp update interval = 14400 secs = 4 hours, borrowed from h2o
|
// ocsp update interval = 14400 secs = 4 hours, borrowed from h2o
|
||||||
mod_config()->ocsp_update_interval = 14400.;
|
mod_config()->ocsp_update_interval = 4_h;
|
||||||
mod_config()->fetch_ocsp_response_file =
|
mod_config()->fetch_ocsp_response_file =
|
||||||
strcopy(PKGDATADIR "/fetch-ocsp-response");
|
strcopy(PKGDATADIR "/fetch-ocsp-response");
|
||||||
mod_config()->no_ocsp = false;
|
mod_config()->no_ocsp = false;
|
||||||
|
|
|
@ -145,6 +145,8 @@ template <typename T> void dlist_delete_all(DList<T> &dl) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// User-defined literals for K, M, and G (powers of 1024)
|
||||||
|
|
||||||
constexpr unsigned long long operator"" _k(unsigned long long k) {
|
constexpr unsigned long long operator"" _k(unsigned long long k) {
|
||||||
return k * 1024;
|
return k * 1024;
|
||||||
}
|
}
|
||||||
|
@ -157,6 +159,12 @@ constexpr unsigned long long operator"" _g(unsigned long long g) {
|
||||||
return g * 1024 * 1024 * 1024;
|
return g * 1024 * 1024 * 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// User-defined literals for time, converted into double in seconds
|
||||||
|
|
||||||
|
constexpr double operator"" _h(unsigned long long h) { return h * 60 * 60; }
|
||||||
|
|
||||||
|
constexpr double operator"" _min(unsigned long long min) { return min * 60; }
|
||||||
|
|
||||||
} // namespace nghttp2
|
} // namespace nghttp2
|
||||||
|
|
||||||
#endif // TEMPLATE_H
|
#endif // TEMPLATE_H
|
||||||
|
|
Loading…
Reference in New Issue