From b86547dc1ef407ca3838444533bc7145e32a0d90 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Wed, 9 Jul 2014 13:02:37 +0200 Subject: Implement async DNS resolution using c-ares fix #2533 --- src/main.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index a67baf9..94c3cb5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -11,6 +10,10 @@ #include +#ifdef CARES_FOUND +# include +#endif + // A flag set by the SIGINT signal handler. static volatile std::atomic stop(false); // Flag set by the SIGUSR1/2 signal handler. @@ -95,6 +98,10 @@ int main(int ac, char** av) xmpp_component->start(); + +#ifdef CARES_FOUND + DNSHandler::instance.watch_dns_sockets(p); +#endif auto timeout = TimedEventsManager::instance().get_timeout(); while (p->poll(timeout) != -1) { @@ -108,6 +115,9 @@ int main(int ac, char** av) exiting = true; stop.store(false); xmpp_component->shutdown(); +#ifdef CARES_FOUND + DNSHandler::instance.destroy(); +#endif // Cancel the timer for an potential reconnection TimedEventsManager::instance().cancel("XMPP reconnection"); } @@ -153,6 +163,10 @@ int main(int ac, char** av) xmpp_component->close(); if (exiting && p->size() == 1 && xmpp_component->is_document_open()) xmpp_component->close_document(); +#ifdef CARES_FOUND + if (!exiting) + DNSHandler::instance.watch_dns_sockets(p); +#endif if (exiting) // If we are exiting, do not wait for any timed event timeout = utils::no_timeout; else -- cgit v1.2.3