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