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(
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<DownstreamConfig> 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;
......
......@@ -369,9 +369,9 @@ void Worker::process_events() {
std::lock_guard<std::mutex> 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<int>(wev.type);
}
}
}
......
......@@ -211,7 +211,7 @@ struct WorkerStat {
size_t num_connections;
};
enum WorkerEventType {
enum class WorkerEventType {
NEW_CONNECTION = 0x01,
REOPEN_LOG = 0x02,
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