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

This commit is contained in:
Tatsuhiro Tsujikawa 2016-01-19 17:03:01 +09:00
parent 0402481be4
commit 2f9946327a
5 changed files with 12 additions and 3 deletions

View File

@ -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;
} }
} }

View File

@ -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;
} }

View File

@ -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;
} }

View File

@ -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);

View File

@ -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) {