gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r3348 - in GNUnet: m4 src/applications/bootstrap_http


From: grothoff
Subject: [GNUnet-SVN] r3348 - in GNUnet: m4 src/applications/bootstrap_http
Date: Mon, 4 Sep 2006 10:56:00 -0700 (PDT)

Author: grothoff
Date: 2006-09-04 10:55:55 -0700 (Mon, 04 Sep 2006)
New Revision: 3348

Modified:
   GNUnet/m4/Makefile.in
   GNUnet/src/applications/bootstrap_http/http.c
Log:
use curl multi api

Modified: GNUnet/m4/Makefile.in
===================================================================
--- GNUnet/m4/Makefile.in       2006-09-02 20:05:29 UTC (rev 3347)
+++ GNUnet/m4/Makefile.in       2006-09-04 17:55:55 UTC (rev 3348)
@@ -93,7 +93,6 @@
 GMSGFMT = @GMSGFMT@
 GNUNETGTK_CFLAGS = @GNUNETGTK_CFLAGS@
 GNUNETGTK_LIBS = @GNUNETGTK_LIBS@
-GREP = @GREP@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 GUILE = @GUILE@
@@ -175,9 +174,15 @@
 XFREEBSD_TRUE = @XFREEBSD_TRUE@
 XGETTEXT = @XGETTEXT@
 _libcurl_config = @_libcurl_config@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_AS = @ac_ct_AS@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DLLTOOL = @ac_ct_DLLTOOL@
 ac_ct_F77 = @ac_ct_F77@
+ac_ct_OBJDUMP = @ac_ct_OBJDUMP@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
 am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
 am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
 am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
@@ -192,30 +197,23 @@
 build_os = @build_os@
 build_vendor = @build_vendor@
 datadir = @datadir@
-datarootdir = @datarootdir@
-docdir = @docdir@
-dvidir = @dvidir@
 exec_prefix = @exec_prefix@
 host = @host@
 host_alias = @host_alias@
 host_cpu = @host_cpu@
 host_os = @host_os@
 host_vendor = @host_vendor@
-htmldir = @htmldir@
 includedir = @includedir@
 infodir = @infodir@
 install_sh = @install_sh@
 libdir = @libdir@
 libexecdir = @libexecdir@
-localedir = @localedir@
 localstatedir = @localstatedir@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
-pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
-psdir = @psdir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 subdirs = @subdirs@

Modified: GNUnet/src/applications/bootstrap_http/http.c
===================================================================
--- GNUnet/src/applications/bootstrap_http/http.c       2006-09-02 20:05:29 UTC 
(rev 3347)
+++ GNUnet/src/applications/bootstrap_http/http.c       2006-09-04 17:55:55 UTC 
(rev 3348)
@@ -23,11 +23,7 @@
  * @brief HOSTLISTURL support.  Downloads hellos via http.
  * @author Christian Grothoff
  *
- * TODO:
- * make use of curls multi-API to make the http download
- * interruptable (use select & test for terminate callback
- * -- PTHREAD_STOP_SLEEP should interrupt select
- * as well! -- and if not, we can use a small timeout).
+ * TODO: improve error handling (check curl return values)
  */
 
 #include "platform.h"
@@ -123,6 +119,13 @@
   char * url;
   char * proxy;
   CURL * curl;
+  CURLM * mutli;
+  fd_set rs;
+  fd_set ws;
+  fd_set es;
+  int max;
+  struct timeval tv;
+  int running;
 
   bctx.callback = callback;
   bctx.arg = arg;
@@ -176,8 +179,38 @@
   curl_easy_setopt(curl, 
                   CURLOPT_CONNECTTIMEOUT,
                   15L);
-  curl_easy_perform(curl);
+  multi = curl_multi_init();
+
+  curl_multi_add_handle(multi, curl);
+  while (YES == termTest(targ)) {
+    max = 0;
+    FD_ZERO(&rs);
+    FD_ZERO(&ws);
+    FD_ZERO(&es);
+    curl_multi_fdset(multi,
+                    &rs,
+                    &ws,
+                    &es,
+                    &max);
+    /* use timeout of 1s in case that SELECT is not interrupted by
+       signal (just to increase portability a bit) -- better a 1s
+       delay in the reaction than hanging... */
+    tv.tv_sec = 1;
+    tv.tv_usec = 0;
+    SELECT(max + 1,
+          &rs,
+          &ws,
+          &es,
+          &tv);
+    if (YES != termTest(targ))
+      break;
+    curl_multi_perform(multi, &running);
+    if (running == 0)
+      break;
+  }
+  curl_multi_remove_handle(multi, curl);
   curl_easy_cleanup(curl);
+  curl_multi_cleanup(multi);
   FREE(url);
   FREE(proxy);
 }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]