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; size_t envidx = 0;
if (get_config()->host_unix) { if (get_config()->host_unix) {
auto acceptor = conn_handler->get_acceptor4(); auto acceptor = conn_handler->get_acceptor();
std::string fd = ENV_UNIX_FD "="; std::string fd = ENV_UNIX_FD "=";
fd += util::utos(acceptor->get_fd()); fd += util::utos(acceptor->get_fd());
envp[envidx++] = strdup(fd.c_str()); 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(); path += get_config()->host.get();
envp[envidx++] = strdup(path.c_str()); envp[envidx++] = strdup(path.c_str());
} else { } else {
auto acceptor4 = conn_handler->get_acceptor4(); auto acceptor4 = conn_handler->get_acceptor();
if (acceptor4) { if (acceptor4) {
std::string fd4 = ENV_LISTENER4_FD "="; std::string fd4 = ENV_LISTENER4_FD "=";
fd4 += util::utos(acceptor4->get_fd()); fd4 += util::utos(acceptor4->get_fd());
@ -647,7 +647,7 @@ int event_loop() {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
conn_handler->set_acceptor4(std::move(acceptor)); conn_handler->set_acceptor(std::move(acceptor));
} else { } else {
close_env_fd({ENV_UNIX_FD}); close_env_fd({ENV_UNIX_FD});
auto acceptor6 = create_acceptor(conn_handler.get(), AF_INET6); auto acceptor6 = create_acceptor(conn_handler.get(), AF_INET6);
@ -658,7 +658,7 @@ int event_loop() {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
conn_handler->set_acceptor4(std::move(acceptor4)); conn_handler->set_acceptor(std::move(acceptor4));
conn_handler->set_acceptor6(std::move(acceptor6)); conn_handler->set_acceptor6(std::move(acceptor6));
} }

View File

@ -230,12 +230,12 @@ Worker *ConnectionHandler::get_single_worker() const {
return single_worker_.get(); return single_worker_.get();
} }
void ConnectionHandler::set_acceptor4(std::unique_ptr<AcceptHandler> h) { void ConnectionHandler::set_acceptor(std::unique_ptr<AcceptHandler> h) {
acceptor4_ = std::move(h); acceptor_ = std::move(h);
} }
AcceptHandler *ConnectionHandler::get_acceptor4() const { AcceptHandler *ConnectionHandler::get_acceptor() const {
return acceptor4_.get(); return acceptor_.get();
} }
void ConnectionHandler::set_acceptor6(std::unique_ptr<AcceptHandler> h) { void ConnectionHandler::set_acceptor6(std::unique_ptr<AcceptHandler> h) {
@ -247,8 +247,8 @@ AcceptHandler *ConnectionHandler::get_acceptor6() const {
} }
void ConnectionHandler::enable_acceptor() { void ConnectionHandler::enable_acceptor() {
if (acceptor4_) { if (acceptor_) {
acceptor4_->enable(); acceptor_->enable();
} }
if (acceptor6_) { if (acceptor6_) {
@ -257,8 +257,8 @@ void ConnectionHandler::enable_acceptor() {
} }
void ConnectionHandler::disable_acceptor() { void ConnectionHandler::disable_acceptor() {
if (acceptor4_) { if (acceptor_) {
acceptor4_->disable(); acceptor_->disable();
} }
if (acceptor6_) { if (acceptor6_) {
@ -278,8 +278,8 @@ void ConnectionHandler::disable_acceptor_temporary(ev_tstamp t) {
} }
void ConnectionHandler::accept_pending_connection() { void ConnectionHandler::accept_pending_connection() {
if (acceptor4_) { if (acceptor_) {
acceptor4_->accept_connection(); acceptor_->accept_connection();
} }
if (acceptor6_) { if (acceptor6_) {
acceptor6_->accept_connection(); acceptor6_->accept_connection();

View File

@ -65,8 +65,8 @@ public:
const std::shared_ptr<TicketKeys> &get_ticket_keys() const; const std::shared_ptr<TicketKeys> &get_ticket_keys() const;
struct ev_loop *get_loop() const; struct ev_loop *get_loop() const;
Worker *get_single_worker() const; Worker *get_single_worker() const;
void set_acceptor4(std::unique_ptr<AcceptHandler> h); void set_acceptor(std::unique_ptr<AcceptHandler> h);
AcceptHandler *get_acceptor4() const; AcceptHandler *get_acceptor() const;
void set_acceptor6(std::unique_ptr<AcceptHandler> h); void set_acceptor6(std::unique_ptr<AcceptHandler> h);
AcceptHandler *get_acceptor6() const; AcceptHandler *get_acceptor6() const;
void enable_acceptor(); void enable_acceptor();
@ -87,7 +87,9 @@ private:
// Worker object. // Worker object.
std::shared_ptr<TicketKeys> ticket_keys_; std::shared_ptr<TicketKeys> ticket_keys_;
struct ev_loop *loop_; 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_; std::unique_ptr<AcceptHandler> acceptor6_;
ev_timer disable_acceptor_timer_; ev_timer disable_acceptor_timer_;
unsigned int worker_round_robin_cnt_; unsigned int worker_round_robin_cnt_;