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.
This commit is contained in:
Tatsuhiro Tsujikawa 2015-02-22 17:59:50 +09:00
parent e583a25a8b
commit df32a534fc
3 changed files with 19 additions and 17 deletions

View File

@ -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));
}

View File

@ -230,12 +230,12 @@ Worker *ConnectionHandler::get_single_worker() const {
return single_worker_.get();
}
void ConnectionHandler::set_acceptor4(std::unique_ptr<AcceptHandler> h) {
acceptor4_ = std::move(h);
void ConnectionHandler::set_acceptor(std::unique_ptr<AcceptHandler> 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<AcceptHandler> 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();

View File

@ -65,8 +65,8 @@ public:
const std::shared_ptr<TicketKeys> &get_ticket_keys() const;
struct ev_loop *get_loop() const;
Worker *get_single_worker() const;
void set_acceptor4(std::unique_ptr<AcceptHandler> h);
AcceptHandler *get_acceptor4() const;
void set_acceptor(std::unique_ptr<AcceptHandler> h);
AcceptHandler *get_acceptor() const;
void set_acceptor6(std::unique_ptr<AcceptHandler> h);
AcceptHandler *get_acceptor6() const;
void enable_acceptor();
@ -87,7 +87,9 @@ private:
// Worker object.
std::shared_ptr<TicketKeys> ticket_keys_;
struct ev_loop *loop_;
std::unique_ptr<AcceptHandler> acceptor4_;
// acceptor for IPv4 address or UNIX domain socket.
std::unique_ptr<AcceptHandler> acceptor_;
// acceptor for IPv6 address
std::unique_ptr<AcceptHandler> acceptor6_;
ev_timer disable_acceptor_timer_;
unsigned int worker_round_robin_cnt_;