Commit 264a98d1 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttpx: Call c-ares initialization/cleanup functions

parent 7c11d2d9
...@@ -39,6 +39,8 @@ ...@@ -39,6 +39,8 @@
#include <ev.h> #include <ev.h>
#include <ares.h>
#include "shrpx_config.h" #include "shrpx_config.h"
#include "shrpx_connection_handler.h" #include "shrpx_connection_handler.h"
#include "shrpx_log_config.h" #include "shrpx_log_config.h"
...@@ -392,6 +394,7 @@ std::random_device rd; ...@@ -392,6 +394,7 @@ std::random_device rd;
} // namespace } // namespace
int worker_process_event_loop(WorkerProcessConfig *wpconf) { int worker_process_event_loop(WorkerProcessConfig *wpconf) {
int rv;
std::array<char, STRERROR_BUFSIZE> errbuf; std::array<char, STRERROR_BUFSIZE> errbuf;
(void)errbuf; (void)errbuf;
...@@ -400,6 +403,12 @@ int worker_process_event_loop(WorkerProcessConfig *wpconf) { ...@@ -400,6 +403,12 @@ int worker_process_event_loop(WorkerProcessConfig *wpconf) {
return -1; 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 loop = EV_DEFAULT;
auto gen = std::mt19937(rd()); auto gen = std::mt19937(rd());
...@@ -494,8 +503,6 @@ int worker_process_event_loop(WorkerProcessConfig *wpconf) { ...@@ -494,8 +503,6 @@ int worker_process_event_loop(WorkerProcessConfig *wpconf) {
} }
} }
int rv;
if (config->num_worker == 1) { if (config->num_worker == 1) {
rv = conn_handler.create_single_worker(); rv = conn_handler.create_single_worker();
if (rv != 0) { if (rv != 0) {
...@@ -575,6 +582,8 @@ int worker_process_event_loop(WorkerProcessConfig *wpconf) { ...@@ -575,6 +582,8 @@ int worker_process_event_loop(WorkerProcessConfig *wpconf) {
} }
#endif // HAVE_NEVERBLEED #endif // HAVE_NEVERBLEED
ares_library_cleanup();
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment