nghttpx: Call c-ares initialization/cleanup functions

This commit is contained in:
Tatsuhiro Tsujikawa 2016-12-10 21:41:03 +09:00
parent 7c11d2d9bb
commit 264a98d106
1 changed files with 11 additions and 2 deletions

View File

@ -39,6 +39,8 @@
#include <ev.h>
#include <ares.h>
#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<char, STRERROR_BUFSIZE> 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;
}