nghttpx: Close listening socket on graceful shutdown
This commit is contained in:
parent
54573f28a8
commit
45d76cf501
|
@ -573,9 +573,14 @@ void signal_cb(struct ev_loop *loop, ev_signal *w, int revents) {
|
||||||
case EXEC_BINARY_SIGNAL:
|
case EXEC_BINARY_SIGNAL:
|
||||||
exec_binary();
|
exec_binary();
|
||||||
return;
|
return;
|
||||||
case GRACEFUL_SHUTDOWN_SIGNAL:
|
case GRACEFUL_SHUTDOWN_SIGNAL: {
|
||||||
|
auto &listenerconf = get_config()->conn.listener;
|
||||||
|
for (auto &addr : listenerconf.addrs) {
|
||||||
|
close(addr.fd);
|
||||||
|
}
|
||||||
ipc_send(wp, SHRPX_IPC_GRACEFUL_SHUTDOWN);
|
ipc_send(wp, SHRPX_IPC_GRACEFUL_SHUTDOWN);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
case RELOAD_SIGNAL:
|
case RELOAD_SIGNAL:
|
||||||
reload_config(wp);
|
reload_config(wp);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -452,6 +452,8 @@ void ConnectionHandler::add_acceptor(std::unique_ptr<AcceptHandler> h) {
|
||||||
acceptors_.push_back(std::move(h));
|
acceptors_.push_back(std::move(h));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConnectionHandler::delete_acceptor() { acceptors_.clear(); }
|
||||||
|
|
||||||
void ConnectionHandler::enable_acceptor() {
|
void ConnectionHandler::enable_acceptor() {
|
||||||
for (auto &a : acceptors_) {
|
for (auto &a : acceptors_) {
|
||||||
a->enable();
|
a->enable();
|
||||||
|
|
|
@ -117,6 +117,7 @@ public:
|
||||||
struct ev_loop *get_loop() const;
|
struct ev_loop *get_loop() const;
|
||||||
Worker *get_single_worker() const;
|
Worker *get_single_worker() const;
|
||||||
void add_acceptor(std::unique_ptr<AcceptHandler> h);
|
void add_acceptor(std::unique_ptr<AcceptHandler> h);
|
||||||
|
void delete_acceptor();
|
||||||
void enable_acceptor();
|
void enable_acceptor();
|
||||||
void disable_acceptor();
|
void disable_acceptor();
|
||||||
void sleep_acceptor(ev_tstamp t);
|
void sleep_acceptor(ev_tstamp t);
|
||||||
|
|
|
@ -114,12 +114,10 @@ void graceful_shutdown(ConnectionHandler *conn_handler) {
|
||||||
|
|
||||||
conn_handler->set_graceful_shutdown(true);
|
conn_handler->set_graceful_shutdown(true);
|
||||||
|
|
||||||
conn_handler->disable_acceptor();
|
// TODO What happens for the connections not established in the
|
||||||
|
// kernel?
|
||||||
// After disabling accepting new connection, dispatch incoming
|
|
||||||
// connection in backlog.
|
|
||||||
|
|
||||||
conn_handler->accept_pending_connection();
|
conn_handler->accept_pending_connection();
|
||||||
|
conn_handler->delete_acceptor();
|
||||||
|
|
||||||
conn_handler->graceful_shutdown_worker();
|
conn_handler->graceful_shutdown_worker();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue