[Libtorrent-devel] [PATCH] [rtorrent] Add CURL_VERSION_ASYNCHDNS checking.

Pekka Seppänen pexu+libtorrent at kapsi.fi
Tue Jun 30 21:24:16 UTC 2009


Hello,

the first mail never made through, so trying again; Anyway, I made a quick
patch to check if libcurl is compiled with asynchronous dns support, i.e. with
c-ares. The libcurl does not make too much noise if the support is omited and
and neither does rtorrent.

As rtorrent uses libcurl with CURLOPT_NOSIGNAL set, there's no way for libcurl
to use non-blocking dns queries / resolves [unless c-ares is enabled]*. If and
when there are multiple torrents running with e.g. unresolvable trackers
rtorrent is basically frozen 99% of time; not quite something that should go
without any warnings displayed.

The proposed CURL_VERSION_ASYNCHDNS check is toggeable, so it may be easily
skipped without any hacking required. I did not do add any non-configure
related changes as libcurl does not honour (= it can't) any timeout values, so
tweaking does not help (much) here.

-- Pekka

*) I'm too lazy to check the libcurl code again, but it's possible that with the
   NOSIGNAL curl isn't able to use any non-os / configurable timeout. This could
   make sense as ASYNCHDNS feat flag is not related to any runtime configs. I.e.
   libcurl would block anyway but not perhaps for so long time; Anyhow, as
   rtorrent uses the NOSIGNAL option this doesn't really matter.

File: configure.ac
================================================================================
--- const/rtorrent/configure.ac 2009-06-27 03:24:53.000000000 +0300
+++ trunk/rtorrent/configure.ac 2009-06-27 03:01:33.000000000 +0300
@@ -34,6 +34,8 @@
                  CXXFLAGS="$CXXFLAGS $libcurl_CFLAGS";
                  LIBS="$LIBS $libcurl_LIBS")

+LIBCURL_CHECK_FEATS()
+
 PKG_CHECK_MODULES(libtorrent, libtorrent >= 0.12.4,
                  CXXFLAGS="$CXXFLAGS $libtorrent_CFLAGS";
                  LIBS="$LIBS $libtorrent_LIBS")

File: checks.m4
================================================================================
--- const/rtorrent/scripts/checks.m4    2009-06-27 03:24:51.000000000 +0300
+++ trunk/rtorrent/scripts/checks.m4    2009-06-27 03:32:02.000000000 +0300
@@ -358,6 +358,37 @@
     ])
 ])

+AC_DEFUN([LIBCURL_CHECK_FEAT_ASYNCHDNS], [
+  AC_MSG_CHECKING(for libcurl asynchronous dns support)
+
+  AC_RUN_IFELSE(
+    [[#include <curl/curl.h>
+      int main() {
+        curl_version_info_data *vnfo = curl_version_info(CURLVERSION_NOW);
+        return vnfo != NULL && vnfo->features & CURL_VERSION_ASYNCHDNS ? 0 : 1;
+      }
+    ]],
+    [
+      AC_DEFINE(HAVE_LIBCURL_FEAT_ASYNCHDNS, 1, Have libcurl asynchronous dns feature.)
+      AC_MSG_RESULT(yes)
+    ], [
+      AC_MSG_RESULT(no)
+      AC_MSG_ERROR([your libcurl does not support asynchronous dns feature or it has been disabled.])
+    ])
+]);
+
+AC_DEFUN([LIBCURL_CHECK_FEATS], [
+  AC_ARG_ENABLE(libcurl-feat-check,
+    [  --enable-libcurl-feat-check  enable libcurl feature check [[default=yes]]],
+    [
+        if test "$enableval" = "yes"; then
+           LIBCURL_CHECK_FEAT_ASYNCHDNS
+        fi
+    ],
+    [
+           LIBCURL_CHECK_FEAT_ASYNCHDNS
+    ])
+])

 AC_DEFUN([TORRENT_WITH_XMLRPC_C], [
   AC_MSG_CHECKING(for XMLRPC-C)



More information about the Libtorrent-devel mailing list