From df32a534fc1021a4507e74198c936b5f9837bcc9 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 22 Feb 2015 17:59:50 +0900 Subject: [PATCH] nghttpx: Rename ConnectionHandler::acceptor4_ as acceptor_ This change is motivated by that fact that we use it for UNIX domain socket as well as IPv4. --- src/shrpx.cc | 8 ++++---- src/shrpx_connection_handler.cc | 20 ++++++++++---------- src/shrpx_connection_handler.h | 8 +++++--- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/shrpx.cc b/src/shrpx.cc index 9a88bf8c..3a06479b 100644 --- a/src/shrpx.cc +++ b/src/shrpx.cc @@ -469,7 +469,7 @@ void exec_binary_signal_cb(struct ev_loop *loop, ev_signal *w, int revents) { size_t envidx = 0; if (get_config()->host_unix) { - auto acceptor = conn_handler->get_acceptor4(); + auto acceptor = conn_handler->get_acceptor(); std::string fd = ENV_UNIX_FD "="; fd += util::utos(acceptor->get_fd()); envp[envidx++] = strdup(fd.c_str()); @@ -478,7 +478,7 @@ void exec_binary_signal_cb(struct ev_loop *loop, ev_signal *w, int revents) { path += get_config()->host.get(); envp[envidx++] = strdup(path.c_str()); } else { - auto acceptor4 = conn_handler->get_acceptor4(); + auto acceptor4 = conn_handler->get_acceptor(); if (acceptor4) { std::string fd4 = ENV_LISTENER4_FD "="; fd4 += util::utos(acceptor4->get_fd()); @@ -647,7 +647,7 @@ int event_loop() { exit(EXIT_FAILURE); } - conn_handler->set_acceptor4(std::move(acceptor)); + conn_handler->set_acceptor(std::move(acceptor)); } else { close_env_fd({ENV_UNIX_FD}); auto acceptor6 = create_acceptor(conn_handler.get(), AF_INET6); @@ -658,7 +658,7 @@ int event_loop() { exit(EXIT_FAILURE); } - conn_handler->set_acceptor4(std::move(acceptor4)); + conn_handler->set_acceptor(std::move(acceptor4)); conn_handler->set_acceptor6(std::move(acceptor6)); } diff --git a/src/shrpx_connection_handler.cc b/src/shrpx_connection_handler.cc index 3290ba1a..1bb1b184 100644 --- a/src/shrpx_connection_handler.cc +++ b/src/shrpx_connection_handler.cc @@ -230,12 +230,12 @@ Worker *ConnectionHandler::get_single_worker() const { return single_worker_.get(); } -void ConnectionHandler::set_acceptor4(std::unique_ptr h) { - acceptor4_ = std::move(h); +void ConnectionHandler::set_acceptor(std::unique_ptr h) { + acceptor_ = std::move(h); } -AcceptHandler *ConnectionHandler::get_acceptor4() const { - return acceptor4_.get(); +AcceptHandler *ConnectionHandler::get_acceptor() const { + return acceptor_.get(); } void ConnectionHandler::set_acceptor6(std::unique_ptr h) { @@ -247,8 +247,8 @@ AcceptHandler *ConnectionHandler::get_acceptor6() const { } void ConnectionHandler::enable_acceptor() { - if (acceptor4_) { - acceptor4_->enable(); + if (acceptor_) { + acceptor_->enable(); } if (acceptor6_) { @@ -257,8 +257,8 @@ void ConnectionHandler::enable_acceptor() { } void ConnectionHandler::disable_acceptor() { - if (acceptor4_) { - acceptor4_->disable(); + if (acceptor_) { + acceptor_->disable(); } if (acceptor6_) { @@ -278,8 +278,8 @@ void ConnectionHandler::disable_acceptor_temporary(ev_tstamp t) { } void ConnectionHandler::accept_pending_connection() { - if (acceptor4_) { - acceptor4_->accept_connection(); + if (acceptor_) { + acceptor_->accept_connection(); } if (acceptor6_) { acceptor6_->accept_connection(); diff --git a/src/shrpx_connection_handler.h b/src/shrpx_connection_handler.h index 955f978a..9b127552 100644 --- a/src/shrpx_connection_handler.h +++ b/src/shrpx_connection_handler.h @@ -65,8 +65,8 @@ public: const std::shared_ptr &get_ticket_keys() const; struct ev_loop *get_loop() const; Worker *get_single_worker() const; - void set_acceptor4(std::unique_ptr h); - AcceptHandler *get_acceptor4() const; + void set_acceptor(std::unique_ptr h); + AcceptHandler *get_acceptor() const; void set_acceptor6(std::unique_ptr h); AcceptHandler *get_acceptor6() const; void enable_acceptor(); @@ -87,7 +87,9 @@ private: // Worker object. std::shared_ptr ticket_keys_; struct ev_loop *loop_; - std::unique_ptr acceptor4_; + // acceptor for IPv4 address or UNIX domain socket. + std::unique_ptr acceptor_; + // acceptor for IPv6 address std::unique_ptr acceptor6_; ev_timer disable_acceptor_timer_; unsigned int worker_round_robin_cnt_;