mirror of
https://github.com/nghttp2/nghttp2.git
synced 2025-12-06 18:18:52 +08:00
nghttpx: Call c-ares initialization/cleanup functions
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user