Commit 2f994632 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttpx: Fix bug that --listener-disable-timeout option is not used

parent 0402481b
...@@ -1032,6 +1032,7 @@ void fill_default_config() { ...@@ -1032,6 +1032,7 @@ void fill_default_config() {
// Default accept() backlog // Default accept() backlog
listenerconf.backlog = 512; listenerconf.backlog = 512;
listenerconf.host_unix = false; listenerconf.host_unix = false;
listenerconf.timeout.sleep = 30_s;
} }
} }
......
...@@ -87,7 +87,7 @@ void AcceptHandler::accept_connection() { ...@@ -87,7 +87,7 @@ void AcceptHandler::accept_connection() {
case ENFILE: case ENFILE:
LOG(WARN) << "acceptor: running out file descriptor; disable acceptor " LOG(WARN) << "acceptor: running out file descriptor; disable acceptor "
"temporarily"; "temporarily";
conn_hnr_->disable_acceptor_temporary(30.); conn_hnr_->sleep_acceptor(get_config()->conn.listener.timeout.sleep);
break; break;
} }
......
...@@ -385,7 +385,7 @@ void ConnectionHandler::disable_acceptor() { ...@@ -385,7 +385,7 @@ void ConnectionHandler::disable_acceptor() {
} }
} }
void ConnectionHandler::disable_acceptor_temporary(ev_tstamp t) { void ConnectionHandler::sleep_acceptor(ev_tstamp t) {
if (t == 0. || ev_is_active(&disable_acceptor_timer_)) { if (t == 0. || ev_is_active(&disable_acceptor_timer_)) {
return; return;
} }
......
...@@ -98,7 +98,7 @@ public: ...@@ -98,7 +98,7 @@ public:
AcceptHandler *get_acceptor6() const; AcceptHandler *get_acceptor6() const;
void enable_acceptor(); void enable_acceptor();
void disable_acceptor(); void disable_acceptor();
void disable_acceptor_temporary(ev_tstamp t); void sleep_acceptor(ev_tstamp t);
void accept_pending_connection(); void accept_pending_connection();
void graceful_shutdown_worker(); void graceful_shutdown_worker();
void set_graceful_shutdown(bool f); void set_graceful_shutdown(bool f);
......
...@@ -171,10 +171,18 @@ constexpr unsigned long long operator"" _g(unsigned long long g) { ...@@ -171,10 +171,18 @@ constexpr unsigned long long operator"" _g(unsigned long long g) {
// User-defined literals for time, converted into double in seconds // User-defined literals for time, converted into double in seconds
// hours
constexpr double operator"" _h(unsigned long long h) { return h * 60 * 60; } constexpr double operator"" _h(unsigned long long h) { return h * 60 * 60; }
// minutes
constexpr double operator"" _min(unsigned long long min) { return min * 60; } constexpr double operator"" _min(unsigned long long min) { return min * 60; }
// seconds
constexpr double operator"" _s(unsigned long long s) { return s; }
// milliseconds
constexpr double operator"" _ms(unsigned long long ms) { return ms / 1000.; }
// Returns a copy of NULL-terminated string [first, last). // Returns a copy of NULL-terminated string [first, last).
template <typename InputIt> template <typename InputIt>
std::unique_ptr<char[]> strcopy(InputIt first, InputIt last) { std::unique_ptr<char[]> strcopy(InputIt first, InputIt last) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment