nghttpx: Move api enabled to APIConfig

This commit is contained in:
Tatsuhiro Tsujikawa 2016-06-17 00:09:15 +09:00
parent 56e7cd4be2
commit fa8bccbae2
3 changed files with 9 additions and 8 deletions

View File

@ -1724,6 +1724,7 @@ int parse_config(Config *config, int optid, const StringRef &opt,
} }
case SHRPX_OPTID_FRONTEND: { case SHRPX_OPTID_FRONTEND: {
auto &listenerconf = config->conn.listener; auto &listenerconf = config->conn.listener;
auto &apiconf = config->api;
auto addr_end = std::find(std::begin(optarg), std::end(optarg), ';'); auto addr_end = std::find(std::begin(optarg), std::end(optarg), ';');
auto src_params = StringRef{addr_end, std::end(optarg)}; auto src_params = StringRef{addr_end, std::end(optarg)};
@ -1741,7 +1742,7 @@ int parse_config(Config *config, int optid, const StringRef &opt,
addr.alt_mode = params.alt_mode; addr.alt_mode = params.alt_mode;
if (addr.alt_mode == ALTMODE_API) { if (addr.alt_mode == ALTMODE_API) {
listenerconf.api = true; apiconf.enabled = true;
} }
if (util::istarts_with(optarg, SHRPX_UNIX_PATH_PREFIX)) { if (util::istarts_with(optarg, SHRPX_UNIX_PATH_PREFIX)) {

View File

@ -661,8 +661,6 @@ struct ConnectionConfig {
// TCP fastopen. If this is positive, it is passed to // TCP fastopen. If this is positive, it is passed to
// setsockopt() along with TCP_FASTOPEN. // setsockopt() along with TCP_FASTOPEN.
int fastopen; int fastopen;
// true if at least one of UpstreamAddr has api enabled
bool api;
} listener; } listener;
struct { struct {
@ -685,6 +683,8 @@ struct ConnectionConfig {
struct APIConfig { struct APIConfig {
// Maximum request body size for one API request // Maximum request body size for one API request
size_t max_request_body; size_t max_request_body;
// true if at least one of UpstreamAddr has api enabled
bool enabled;
}; };
struct Config { struct Config {

View File

@ -120,7 +120,7 @@ ConnectionHandler::ConnectionHandler(struct ev_loop *loop)
loop_(loop), loop_(loop),
tls_ticket_key_memcached_get_retry_count_(0), tls_ticket_key_memcached_get_retry_count_(0),
tls_ticket_key_memcached_fail_count_(0), tls_ticket_key_memcached_fail_count_(0),
worker_round_robin_cnt_(get_config()->conn.listener.api ? 1 : 0), worker_round_robin_cnt_(get_config()->api.enabled ? 1 : 0),
graceful_shutdown_(false) { graceful_shutdown_(false) {
ev_timer_init(&disable_acceptor_timer_, acceptor_disable_cb, 0., 0.); ev_timer_init(&disable_acceptor_timer_, acceptor_disable_cb, 0., 0.);
disable_acceptor_timer_.data = this; disable_acceptor_timer_.data = this;
@ -268,10 +268,10 @@ int ConnectionHandler::create_worker_thread(size_t num) {
auto &tlsconf = get_config()->tls; auto &tlsconf = get_config()->tls;
auto &memcachedconf = get_config()->tls.session_cache.memcached; auto &memcachedconf = get_config()->tls.session_cache.memcached;
auto &listenerconf = get_config()->conn.listener; auto &apiconf = get_config()->api;
// We have dedicated worker for API request processing. // We have dedicated worker for API request processing.
if (listenerconf.api) { if (apiconf.enabled) {
++num; ++num;
} }
@ -407,9 +407,9 @@ int ConnectionHandler::handle_connection(int fd, sockaddr *addr, int addrlen,
} }
if (++worker_round_robin_cnt_ == workers_.size()) { if (++worker_round_robin_cnt_ == workers_.size()) {
auto &listenerconf = get_config()->conn.listener; auto &apiconf = get_config()->api;
if (listenerconf.api) { if (apiconf.enabled) {
worker_round_robin_cnt_ = 1; worker_round_robin_cnt_ = 1;
} else { } else {
worker_round_robin_cnt_ = 0; worker_round_robin_cnt_ = 0;