From 15a9dfbaeaaad047ffc484552e9b121979775be7 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 6 May 2016 23:45:56 +0900 Subject: [PATCH] nghttpd: Enable kqueue if it is available on the running platform --- src/HttpServer.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/HttpServer.cc b/src/HttpServer.cc index 9c076f2c..893f731d 100644 --- a/src/HttpServer.cc +++ b/src/HttpServer.cc @@ -1793,6 +1793,16 @@ void run_worker(Worker *worker) { } } // namespace +namespace { +int get_ev_loop_flags() { + if (ev_supported_backends() & ~ev_recommended_backends() & EVBACKEND_KQUEUE) { + return ev_recommended_backends() | EVBACKEND_KQUEUE; + } + + return 0; +} +} // namespace + class AcceptHandler { public: AcceptHandler(HttpServer *sv, Sessions *sessions, const Config *config) @@ -1805,7 +1815,7 @@ public: std::cerr << "spawning thread #" << i << std::endl; } auto worker = make_unique(); - auto loop = ev_loop_new(0); + auto loop = ev_loop_new(get_ev_loop_flags()); worker->sessions = make_unique(sv, loop, config_, sessions_->get_ssl_ctx()); ev_async_init(&worker->w, worker_acceptcb);