nghttpx: Enable kqueue by default
We enabled libev kqueue backend in nghttpx by default. Since it might not work on some platforms, we also added --no-kqueue option to disable it.
This commit is contained in:
parent
5d4f3f36e3
commit
d39335829d
|
@ -129,6 +129,7 @@ OPTIONS = [
|
|||
"backend-tls",
|
||||
"backend-connections-per-host",
|
||||
"error-page",
|
||||
"no-kqueue",
|
||||
]
|
||||
|
||||
LOGVARS = [
|
||||
|
|
15
src/shrpx.cc
15
src/shrpx.cc
|
@ -969,7 +969,7 @@ int event_loop() {
|
|||
return -1;
|
||||
}
|
||||
|
||||
auto loop = EV_DEFAULT;
|
||||
auto loop = ev_default_loop(get_config()->ev_loop_flags);
|
||||
|
||||
auto pid = fork_worker_process(&ssv);
|
||||
|
||||
|
@ -1042,6 +1042,10 @@ void fill_default_config() {
|
|||
mod_config()->conf_path = "/etc/nghttpx/nghttpx.conf";
|
||||
mod_config()->pid = getpid();
|
||||
|
||||
if (ev_supported_backends() & ~ev_recommended_backends() & EVBACKEND_KQUEUE) {
|
||||
mod_config()->ev_loop_flags = ev_recommended_backends() | EVBACKEND_KQUEUE;
|
||||
}
|
||||
|
||||
auto &tlsconf = mod_config()->tls;
|
||||
{
|
||||
auto &ticketconf = tlsconf.ticket;
|
||||
|
@ -1439,6 +1443,10 @@ Performance:
|
|||
that have not yet completed the three-way handshake. If
|
||||
value is 0 then fast open is disabled.
|
||||
Default: )" << get_config()->conn.listener.fastopen << R"(
|
||||
--no-kqueue Don't use kqueue. This option is only applicable for
|
||||
the platforms which have kqueue. For other platforms,
|
||||
this option will be simply ignored.
|
||||
|
||||
Timeout:
|
||||
--frontend-http2-read-timeout=<DURATION>
|
||||
Specify read timeout for HTTP/2 and SPDY frontend
|
||||
|
@ -2560,6 +2568,7 @@ int main(int argc, char **argv) {
|
|||
{SHRPX_OPT_BACKEND_CONNECTIONS_PER_HOST.c_str(), required_argument,
|
||||
&flag, 121},
|
||||
{SHRPX_OPT_ERROR_PAGE.c_str(), required_argument, &flag, 122},
|
||||
{SHRPX_OPT_NO_KQUEUE.c_str(), no_argument, &flag, 123},
|
||||
{nullptr, 0, nullptr, 0}};
|
||||
|
||||
int option_index = 0;
|
||||
|
@ -3135,6 +3144,10 @@ int main(int argc, char **argv) {
|
|||
// --error-page
|
||||
cmdcfgs.emplace_back(SHRPX_OPT_ERROR_PAGE, StringRef{optarg});
|
||||
break;
|
||||
case 123:
|
||||
// --no-kqueue
|
||||
cmdcfgs.emplace_back(SHRPX_OPT_NO_KQUEUE, StringRef::from_lit("yes"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -993,6 +993,7 @@ enum {
|
|||
SHRPX_OPTID_MRUBY_FILE,
|
||||
SHRPX_OPTID_NO_HOST_REWRITE,
|
||||
SHRPX_OPTID_NO_HTTP2_CIPHER_BLACK_LIST,
|
||||
SHRPX_OPTID_NO_KQUEUE,
|
||||
SHRPX_OPTID_NO_LOCATION_REWRITE,
|
||||
SHRPX_OPTID_NO_OCSP,
|
||||
SHRPX_OPTID_NO_SERVER_PUSH,
|
||||
|
@ -1161,6 +1162,9 @@ int option_lookup_token(const char *name, size_t namelen) {
|
|||
case 9:
|
||||
switch (name[8]) {
|
||||
case 'e':
|
||||
if (util::strieq_l("no-kqueu", name, 8)) {
|
||||
return SHRPX_OPTID_NO_KQUEUE;
|
||||
}
|
||||
if (util::strieq_l("read-rat", name, 8)) {
|
||||
return SHRPX_OPTID_READ_RATE;
|
||||
}
|
||||
|
@ -2712,6 +2716,15 @@ int parse_config(const StringRef &opt, const StringRef &optarg,
|
|||
opt, optarg);
|
||||
case SHRPX_OPTID_ERROR_PAGE:
|
||||
return parse_error_page(mod_config()->http.error_pages, opt, optarg);
|
||||
case SHRPX_OPTID_NO_KQUEUE:
|
||||
if ((ev_supported_backends() & EVBACKEND_KQUEUE) == 0) {
|
||||
LOG(WARN) << opt << ": kqueue is not supported on this platform";
|
||||
return 0;
|
||||
}
|
||||
|
||||
mod_config()->ev_loop_flags = ev_recommended_backends() & ~EVBACKEND_KQUEUE;
|
||||
|
||||
return 0;
|
||||
case SHRPX_OPTID_CONF:
|
||||
LOG(WARN) << "conf: ignored";
|
||||
|
||||
|
|
|
@ -275,6 +275,7 @@ constexpr auto SHRPX_OPT_BACKEND_TLS = StringRef::from_lit("backend-tls");
|
|||
constexpr auto SHRPX_OPT_BACKEND_CONNECTIONS_PER_HOST =
|
||||
StringRef::from_lit("backend-connections-per-host");
|
||||
constexpr auto SHRPX_OPT_ERROR_PAGE = StringRef::from_lit("error-page");
|
||||
constexpr auto SHRPX_OPT_NO_KQUEUE = StringRef::from_lit("no-kqueue");
|
||||
|
||||
constexpr size_t SHRPX_OBFUSCATED_NODE_LENGTH = 8;
|
||||
|
||||
|
@ -652,6 +653,8 @@ struct Config {
|
|||
bool verbose;
|
||||
bool daemon;
|
||||
bool http2_proxy;
|
||||
// flags passed to ev_default_loop() and ev_loop_new()
|
||||
int ev_loop_flags;
|
||||
};
|
||||
|
||||
const Config *get_config();
|
||||
|
|
|
@ -244,7 +244,7 @@ int ConnectionHandler::create_worker_thread(size_t num) {
|
|||
auto &memcachedconf = get_config()->tls.session_cache.memcached;
|
||||
|
||||
for (size_t i = 0; i < num; ++i) {
|
||||
auto loop = ev_loop_new(0);
|
||||
auto loop = ev_loop_new(get_config()->ev_loop_flags);
|
||||
|
||||
SSL_CTX *session_cache_ssl_ctx = nullptr;
|
||||
if (memcachedconf.tls) {
|
||||
|
|
Loading…
Reference in New Issue