summaryrefslogtreecommitdiff
path: root/src/Platform.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-02-02 13:48:16 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-02-02 13:48:16 +0000
commitabcc0146759f34fad83730b37776716ba3250ff0 (patch)
treea98ade2f721030f2bf1adb78ff9648b0c71eca72 /src/Platform.cc
parent3f7df00d985c0b4342ee5878b2390e54f1143097 (diff)
2010-02-02 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Call ares_library_init and ares_library_cleanup if they are available. Some code cleanups. * src/Platform.cc
Diffstat (limited to 'src/Platform.cc')
-rw-r--r--src/Platform.cc43
1 files changed, 32 insertions, 11 deletions
diff --git a/src/Platform.cc b/src/Platform.cc
index d510a98a..74f42a5d 100644
--- a/src/Platform.cc
+++ b/src/Platform.cc
@@ -34,13 +34,12 @@
/* copyright --> */
#include "Platform.h"
-#ifdef HAVE_LIBSSL
-# include <openssl/err.h>
-# include <openssl/ssl.h>
-#endif // HAVE_LIBSSL
-#ifdef HAVE_LIBGNUTLS
-# include <gnutls/gnutls.h>
-#endif // HAVE_LIBGNUTLS
+#include <stdlib.h> /* _fmode */
+#include <fcntl.h> /* _O_BINARY */
+
+#include <locale.h> // For setlocale, LC_*
+
+#include <iostream>
#ifdef HAVE_WINSOCK2_H
@@ -55,11 +54,20 @@
#endif // HAVE_WINSOCK2_H
+#ifdef HAVE_LIBSSL
+# include <openssl/err.h>
+# include <openssl/ssl.h>
+#endif // HAVE_LIBSSL
+#ifdef HAVE_LIBGNUTLS
+# include <gnutls/gnutls.h>
+#endif // HAVE_LIBGNUTLS
+
+#ifdef ENABLE_ASYNC_DNS
+# include <ares.h>
+#endif // ENABLE_ASYNC_DNS
+
#include "DlAbortEx.h"
#include "message.h"
-#include <stdlib.h> /* _fmode */
-#include <fcntl.h> /* _O_BINARY */
-#include <locale.h> // For setlocale, LC_*
namespace aria2 {
@@ -97,7 +105,16 @@ bool Platform::setUp()
#ifdef HAVE_LIBGNUTLS
gnutls_global_init();
#endif // HAVE_LIBGNUTLS
-
+
+#ifdef CARES_HAVE_ARES_LIBRARY_INIT
+ int aresErrorCode;
+ if((aresErrorCode = ares_library_init(ARES_LIB_INIT_ALL)) != 0) {
+ std::cerr << "ares_library_init() failed:"
+ << ares_strerror(aresErrorCode)
+ << std::endl;
+ }
+#endif // CARES_HAVE_ARES_LIBRARY_INIT
+
#ifdef HAVE_WINSOCK2_H
WSADATA wsaData;
memset(reinterpret_cast<char*>(&wsaData), 0, sizeof(wsaData));
@@ -124,6 +141,10 @@ bool Platform::tearDown()
gnutls_global_deinit();
#endif // HAVE_LIBGNUTLS
+#ifdef CARES_HAVE_ARES_LIBRARY_CLEANUP
+ ares_library_cleanup();
+#endif // CARES_HAVE_ARES_LIBRARY_CLEANUP
+
#ifdef HAVE_WINSOCK2_H
WSACleanup();
#endif // HAVE_WINSOCK2_H