nghttpx: Clean up worker_event handling
This commit is contained in:
parent
689e8c0ee3
commit
53604782e5
|
@ -137,7 +137,6 @@ void ConnectionHandler::graceful_shutdown_worker() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &worker : workers_) {
|
|
||||||
WorkerEvent wev;
|
WorkerEvent wev;
|
||||||
memset(&wev, 0, sizeof(wev));
|
memset(&wev, 0, sizeof(wev));
|
||||||
wev.type = GRACEFUL_SHUTDOWN;
|
wev.type = GRACEFUL_SHUTDOWN;
|
||||||
|
@ -146,6 +145,8 @@ void ConnectionHandler::graceful_shutdown_worker() {
|
||||||
LLOG(INFO, this) << "Sending graceful shutdown signal to worker";
|
LLOG(INFO, this) << "Sending graceful shutdown signal to worker";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto &worker : workers_) {
|
||||||
|
|
||||||
worker->send(wev);
|
worker->send(wev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,8 @@ void Worker::process_events() {
|
||||||
q.swap(q_);
|
q.swap(q_);
|
||||||
}
|
}
|
||||||
for (auto &wev : q) {
|
for (auto &wev : q) {
|
||||||
if (wev.type == NEW_CONNECTION) {
|
switch (wev.type) {
|
||||||
|
case NEW_CONNECTION: {
|
||||||
if (LOG_ENABLED(INFO)) {
|
if (LOG_ENABLED(INFO)) {
|
||||||
WLOG(INFO, this) << "WorkerEvent: client_fd=" << wev.client_fd
|
WLOG(INFO, this) << "WorkerEvent: client_fd=" << wev.client_fd
|
||||||
<< ", addrlen=" << wev.client_addrlen;
|
<< ", addrlen=" << wev.client_addrlen;
|
||||||
|
@ -109,7 +110,7 @@ void Worker::process_events() {
|
||||||
|
|
||||||
close(wev.client_fd);
|
close(wev.client_fd);
|
||||||
|
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto client_handler = ssl::accept_connection(
|
auto client_handler = ssl::accept_connection(
|
||||||
|
@ -120,7 +121,7 @@ void Worker::process_events() {
|
||||||
WLOG(ERROR, this) << "ClientHandler creation failed";
|
WLOG(ERROR, this) << "ClientHandler creation failed";
|
||||||
}
|
}
|
||||||
close(wev.client_fd);
|
close(wev.client_fd);
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
client_handler->set_http2_session(http2session_.get());
|
client_handler->set_http2_session(http2session_.get());
|
||||||
|
@ -130,10 +131,9 @@ void Worker::process_events() {
|
||||||
WLOG(INFO, this) << "CLIENT_HANDLER:" << client_handler << " created ";
|
WLOG(INFO, this) << "CLIENT_HANDLER:" << client_handler << " created ";
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
|
case RENEW_TICKET_KEYS:
|
||||||
if (wev.type == RENEW_TICKET_KEYS) {
|
|
||||||
if (LOG_ENABLED(INFO)) {
|
if (LOG_ENABLED(INFO)) {
|
||||||
WLOG(INFO, this) << "Renew ticket keys: worker_info(" << worker_config
|
WLOG(INFO, this) << "Renew ticket keys: worker_info(" << worker_config
|
||||||
<< ")";
|
<< ")";
|
||||||
|
@ -141,10 +141,8 @@ void Worker::process_events() {
|
||||||
|
|
||||||
worker_config->ticket_keys = wev.ticket_keys;
|
worker_config->ticket_keys = wev.ticket_keys;
|
||||||
|
|
||||||
continue;
|
break;
|
||||||
}
|
case REOPEN_LOG:
|
||||||
|
|
||||||
if (wev.type == REOPEN_LOG) {
|
|
||||||
if (LOG_ENABLED(INFO)) {
|
if (LOG_ENABLED(INFO)) {
|
||||||
WLOG(INFO, this) << "Reopening log files: worker_info(" << worker_config
|
WLOG(INFO, this) << "Reopening log files: worker_info(" << worker_config
|
||||||
<< ")";
|
<< ")";
|
||||||
|
@ -152,10 +150,8 @@ void Worker::process_events() {
|
||||||
|
|
||||||
reopen_log_files();
|
reopen_log_files();
|
||||||
|
|
||||||
continue;
|
break;
|
||||||
}
|
case GRACEFUL_SHUTDOWN:
|
||||||
|
|
||||||
if (wev.type == GRACEFUL_SHUTDOWN) {
|
|
||||||
WLOG(NOTICE, this) << "Graceful shutdown commencing";
|
WLOG(NOTICE, this) << "Graceful shutdown commencing";
|
||||||
|
|
||||||
worker_config->graceful_shutdown = true;
|
worker_config->graceful_shutdown = true;
|
||||||
|
@ -163,16 +159,16 @@ void Worker::process_events() {
|
||||||
if (worker_stat_->num_connections == 0) {
|
if (worker_stat_->num_connections == 0) {
|
||||||
ev_break(loop_);
|
ev_break(loop_);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (LOG_ENABLED(INFO)) {
|
if (LOG_ENABLED(INFO)) {
|
||||||
WLOG(INFO, this) << "unknown event type " << wev.type;
|
WLOG(INFO, this) << "unknown event type " << wev.type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace shrpx
|
} // namespace shrpx
|
||||||
|
|
Loading…
Reference in New Issue