nghttpd: Enable kqueue if it is available on the running platform

This commit is contained in:
Tatsuhiro Tsujikawa 2016-05-06 23:45:56 +09:00
parent c6facaf662
commit 15a9dfbaea
1 changed files with 11 additions and 1 deletions

View File

@ -1793,6 +1793,16 @@ void run_worker(Worker *worker) {
} }
} // namespace } // 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 { class AcceptHandler {
public: public:
AcceptHandler(HttpServer *sv, Sessions *sessions, const Config *config) AcceptHandler(HttpServer *sv, Sessions *sessions, const Config *config)
@ -1805,7 +1815,7 @@ public:
std::cerr << "spawning thread #" << i << std::endl; std::cerr << "spawning thread #" << i << std::endl;
} }
auto worker = make_unique<Worker>(); auto worker = make_unique<Worker>();
auto loop = ev_loop_new(0); auto loop = ev_loop_new(get_ev_loop_flags());
worker->sessions = worker->sessions =
make_unique<Sessions>(sv, loop, config_, sessions_->get_ssl_ctx()); make_unique<Sessions>(sv, loop, config_, sessions_->get_ssl_ctx());
ev_async_init(&worker->w, worker_acceptcb); ev_async_init(&worker->w, worker_acceptcb);