Resolve hosts by DNS name in separate threads so we can cancel them

getaddrinfo(3) may block a long time so proper termination of the daemon may
block if DNS servers are not reachable.

getaddrinfo(3) is an optional cancellation point in posix threads so it
might still block a shutdown but at least on Android (with the signal based
pthread_cancel implementation) it works, on Linux starter will kill charon
anyway after a while.
This commit is contained in:
Tobias Brunner
2012-10-18 10:57:55 +02:00
parent 272ce5b580
commit 292d8f41c3
8 changed files with 373 additions and 50 deletions
+3
View File
@@ -27,6 +27,7 @@
#include <selectors/traffic_selector.h>
#define CHECKSUM_LIBRARY IPSEC_LIB_DIR"/libchecksum.so"
#define HOST_RESOLVER_MAX_THREADS 2
typedef struct private_library_t private_library_t;
@@ -68,6 +69,7 @@ void library_deinit()
this->public.scheduler->destroy(this->public.scheduler);
this->public.processor->destroy(this->public.processor);
this->public.plugins->destroy(this->public.plugins);
this->public.hosts->destroy(this->public.hosts);
this->public.settings->destroy(this->public.settings);
this->public.credmgr->destroy(this->public.credmgr);
this->public.creds->destroy(this->public.creds);
@@ -182,6 +184,7 @@ bool library_init(char *settings)
this->objects = hashtable_create((hashtable_hash_t)hash,
(hashtable_equals_t)equals, 4);
this->public.hosts = host_resolver_create(HOST_RESOLVER_MAX_THREADS);
this->public.settings = settings_create(settings);
this->public.proposal = proposal_keywords_create();
this->public.crypto = crypto_factory_create();