From 264a98d1064317ea06297a843be479382da6f936 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 10 Dec 2016 21:41:03 +0900 Subject: [PATCH] nghttpx: Call c-ares initialization/cleanup functions --- src/shrpx_worker_process.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/shrpx_worker_process.cc b/src/shrpx_worker_process.cc index 03cef095..aa1239c7 100644 --- a/src/shrpx_worker_process.cc +++ b/src/shrpx_worker_process.cc @@ -39,6 +39,8 @@ #include +#include + #include "shrpx_config.h" #include "shrpx_connection_handler.h" #include "shrpx_log_config.h" @@ -392,6 +394,7 @@ std::random_device rd; } // namespace int worker_process_event_loop(WorkerProcessConfig *wpconf) { + int rv; std::array errbuf; (void)errbuf; @@ -400,6 +403,12 @@ int worker_process_event_loop(WorkerProcessConfig *wpconf) { return -1; } + rv = ares_library_init(ARES_LIB_INIT_ALL); + if (rv != 0) { + LOG(FATAL) << "ares_library_init failed: " << ares_strerror(rv); + return -1; + } + auto loop = EV_DEFAULT; auto gen = std::mt19937(rd()); @@ -494,8 +503,6 @@ int worker_process_event_loop(WorkerProcessConfig *wpconf) { } } - int rv; - if (config->num_worker == 1) { rv = conn_handler.create_single_worker(); if (rv != 0) { @@ -575,6 +582,8 @@ int worker_process_event_loop(WorkerProcessConfig *wpconf) { } #endif // HAVE_NEVERBLEED + ares_library_cleanup(); + return 0; }