Commit 1daf9ce8 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttpx: Convert WorkerEventType to enum class

parent d68edf56
...@@ -183,7 +183,7 @@ void ConnectionHandler::set_ticket_keys_to_worker( ...@@ -183,7 +183,7 @@ void ConnectionHandler::set_ticket_keys_to_worker(
void ConnectionHandler::worker_reopen_log_files() { void ConnectionHandler::worker_reopen_log_files() {
WorkerEvent wev{}; WorkerEvent wev{};
wev.type = REOPEN_LOG; wev.type = WorkerEventType::REOPEN_LOG;
for (auto &worker : workers_) { for (auto &worker : workers_) {
worker->send(wev); worker->send(wev);
...@@ -194,7 +194,7 @@ void ConnectionHandler::worker_replace_downstream( ...@@ -194,7 +194,7 @@ void ConnectionHandler::worker_replace_downstream(
std::shared_ptr<DownstreamConfig> downstreamconf) { std::shared_ptr<DownstreamConfig> downstreamconf) {
WorkerEvent wev{}; WorkerEvent wev{};
wev.type = REPLACE_DOWNSTREAM; wev.type = WorkerEventType::REPLACE_DOWNSTREAM;
wev.downstreamconf = std::move(downstreamconf); wev.downstreamconf = std::move(downstreamconf);
for (auto &worker : workers_) { for (auto &worker : workers_) {
...@@ -348,7 +348,7 @@ void ConnectionHandler::graceful_shutdown_worker() { ...@@ -348,7 +348,7 @@ void ConnectionHandler::graceful_shutdown_worker() {
} }
WorkerEvent wev{}; WorkerEvent wev{};
wev.type = GRACEFUL_SHUTDOWN; wev.type = WorkerEventType::GRACEFUL_SHUTDOWN;
if (LOG_ENABLED(INFO)) { if (LOG_ENABLED(INFO)) {
LLOG(INFO, this) << "Sending graceful shutdown signal to worker"; LLOG(INFO, this) << "Sending graceful shutdown signal to worker";
...@@ -432,7 +432,7 @@ int ConnectionHandler::handle_connection(int fd, sockaddr *addr, int addrlen, ...@@ -432,7 +432,7 @@ int ConnectionHandler::handle_connection(int fd, sockaddr *addr, int addrlen,
} }
WorkerEvent wev{}; WorkerEvent wev{};
wev.type = NEW_CONNECTION; wev.type = WorkerEventType::NEW_CONNECTION;
wev.client_fd = fd; wev.client_fd = fd;
memcpy(&wev.client_addr, addr, addrlen); memcpy(&wev.client_addr, addr, addrlen);
wev.client_addrlen = addrlen; wev.client_addrlen = addrlen;
......
...@@ -369,9 +369,9 @@ void Worker::process_events() { ...@@ -369,9 +369,9 @@ void Worker::process_events() {
std::lock_guard<std::mutex> g(m_); std::lock_guard<std::mutex> g(m_);
// Process event one at a time. This is important for // Process event one at a time. This is important for
// NEW_CONNECTION event since accepting large number of new // WorkerEventType::NEW_CONNECTION event since accepting large
// connections at once may delay time to 1st byte for existing // number of new connections at once may delay time to 1st byte
// connections. // for existing connections.
if (q_.empty()) { if (q_.empty()) {
ev_timer_stop(loop_, &proc_wev_timer_); ev_timer_stop(loop_, &proc_wev_timer_);
...@@ -389,7 +389,7 @@ void Worker::process_events() { ...@@ -389,7 +389,7 @@ void Worker::process_events() {
auto worker_connections = config->conn.upstream.worker_connections; auto worker_connections = config->conn.upstream.worker_connections;
switch (wev.type) { switch (wev.type) {
case NEW_CONNECTION: { case WorkerEventType::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;
...@@ -423,14 +423,14 @@ void Worker::process_events() { ...@@ -423,14 +423,14 @@ void Worker::process_events() {
break; break;
} }
case REOPEN_LOG: case WorkerEventType::REOPEN_LOG:
WLOG(NOTICE, this) << "Reopening log files: worker process (thread " << this WLOG(NOTICE, this) << "Reopening log files: worker process (thread " << this
<< ")"; << ")";
reopen_log_files(config->logging); reopen_log_files(config->logging);
break; break;
case GRACEFUL_SHUTDOWN: case WorkerEventType::GRACEFUL_SHUTDOWN:
WLOG(NOTICE, this) << "Graceful shutdown commencing"; WLOG(NOTICE, this) << "Graceful shutdown commencing";
graceful_shutdown_ = true; graceful_shutdown_ = true;
...@@ -442,7 +442,7 @@ void Worker::process_events() { ...@@ -442,7 +442,7 @@ void Worker::process_events() {
} }
break; break;
case REPLACE_DOWNSTREAM: case WorkerEventType::REPLACE_DOWNSTREAM:
WLOG(NOTICE, this) << "Replace downstream"; WLOG(NOTICE, this) << "Replace downstream";
replace_downstream_config(wev.downstreamconf); replace_downstream_config(wev.downstreamconf);
...@@ -450,7 +450,7 @@ void Worker::process_events() { ...@@ -450,7 +450,7 @@ void Worker::process_events() {
break; break;
default: default:
if (LOG_ENABLED(INFO)) { if (LOG_ENABLED(INFO)) {
WLOG(INFO, this) << "unknown event type " << wev.type; WLOG(INFO, this) << "unknown event type " << static_cast<int>(wev.type);
} }
} }
} }
......
...@@ -211,7 +211,7 @@ struct WorkerStat { ...@@ -211,7 +211,7 @@ struct WorkerStat {
size_t num_connections; size_t num_connections;
}; };
enum WorkerEventType { enum class WorkerEventType {
NEW_CONNECTION = 0x01, NEW_CONNECTION = 0x01,
REOPEN_LOG = 0x02, REOPEN_LOG = 0x02,
GRACEFUL_SHUTDOWN = 0x03, GRACEFUL_SHUTDOWN = 0x03,
......
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