gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-twister] branch master updated (70d25f1 -> c5a65df)


From: gnunet
Subject: [GNUnet-SVN] [taler-twister] branch master updated (70d25f1 -> c5a65df)
Date: Sun, 03 Jun 2018 21:13:26 +0200

This is an automated email from the git hooks/post-receive script.

marcello pushed a change to branch master
in repository twister.

    from 70d25f1  Commenting the "testing API" header file
     new e016699  Make sure that upload cb is registered with assert.
     new 9dc6793  use curl_multi_wait().  Less code needed.
     new 0778f32  no retcode check for "multi wait" function.
     new c5a65df  Tolerate download state not set.

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/test/test_twister_webserver.c   |  30 ++++-----
 src/twister/taler-twister-service.c | 128 +++++++++++++-----------------------
 2 files changed, 62 insertions(+), 96 deletions(-)

diff --git a/src/test/test_twister_webserver.c 
b/src/test/test_twister_webserver.c
index 7616e1e..bf32fcf 100644
--- a/src/test/test_twister_webserver.c
+++ b/src/test/test_twister_webserver.c
@@ -1,22 +1,22 @@
 /*
-     This file is part of Taler.
-     Copyright (C) 2009, 2010, 2011, 2016 GNUnet e.V.
-     Copyright (C) 2018 Taler Systems SA
+  This file is part of Taler.
+  Copyright (C) 2009, 2010, 2011, 2016 GNUnet e.V.
+  Copyright (C) 2018 Taler Systems SA
 
-     Taler is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as
-     published by the Free Software Foundation; either version 3,
-     or (at your option) any later version.
+  Taler is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as
+  published by the Free Software Foundation; either version 3,
+  or (at your option) any later version.
 
-     Taler is distributed in the hope that it will be useful, but
-     WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-     GNU General Public License for more details.
+  Taler is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
 
-     You should have received a copy of the GNU General Public
-     License along with Taler; see the file COPYING.  If not,
-     write to the Free Software Foundation, Inc., 51 Franklin
-     Street, Fifth Floor, Boston, MA 02110-1301, USA.
+  You should have received a copy of the GNU General Public
+  License along with Taler; see the file COPYING.  If not,
+  write to the Free Software Foundation, Inc., 51 Franklin
+  Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */
 
 /**
diff --git a/src/twister/taler-twister-service.c 
b/src/twister/taler-twister-service.c
index 003e2f8..fe0e119 100644
--- a/src/twister/taler-twister-service.c
+++ b/src/twister/taler-twister-service.c
@@ -457,8 +457,17 @@ curl_download_cb (void *ptr,
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Curl download proceeding\n");
 
-  GNUNET_assert
-    (REQUEST_STATE_DOWNLOAD_STARTED == hr->state);
+
+  /* This condition holds when, for example, a Web
+   * server gives the response _before_ having received
+   * all the upload data, or no upload data at all.  */
+  if (REQUEST_STATE_DOWNLOAD_STARTED != hr->state)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "Download prematurely started\n");
+    hr->state = REQUEST_STATE_DOWNLOAD_STARTED;
+  }
+
 
   if (hr->io_size - hr->io_len < total)
   {
@@ -499,8 +508,7 @@ curl_upload_cb (void *buf,
   size_t to_copy;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Uploader cb, size: %u.\n",
-              (unsigned int) size);
+              "Upload cb is working...\n");
 
   if (REQUEST_STATE_UPLOAD_STARTED != hr->state)
   {
@@ -553,74 +561,17 @@ curl_task_download (void *cls);
 static void
 curl_download_prepare ()
 {
-  CURLMcode mret;
-  fd_set rs;
-  fd_set ws;
-  fd_set es;
-  int max;
-  struct GNUNET_NETWORK_FDSet *grs;
-  struct GNUNET_NETWORK_FDSet *gws;
-  long to;
-  struct GNUNET_TIME_Relative rtime;
+  int numfds;
 
-  if (NULL != curl_download_task)
-  {
-    GNUNET_SCHEDULER_cancel (curl_download_task);
-    curl_download_task = NULL;
-  }
-  max = -1;
-  FD_ZERO (&rs);
-  FD_ZERO (&ws);
-  FD_ZERO (&es);
-  if (CURLM_OK != (mret = curl_multi_fdset (curl_multi,
-                                           &rs,
-                                           &ws,
-                                           &es,
-                                           &max)))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "%s failed at %s:%d: `%s'\n",
-                "curl_multi_fdset",
-               __FILE__,
-               __LINE__,
-                curl_multi_strerror (mret));
-    return;
-  }
-  to = -1;
-  GNUNET_break (CURLM_OK ==
-               curl_multi_timeout (curl_multi,
-                                   &to));
-  if (-1 == to)
-    rtime = GNUNET_TIME_UNIT_FOREVER_REL;
-  else
-    rtime = GNUNET_TIME_relative_multiply
-      (GNUNET_TIME_UNIT_MILLISECONDS, to);
-  if (-1 != max)
-  {
-    grs = GNUNET_NETWORK_fdset_create ();
-    gws = GNUNET_NETWORK_fdset_create ();
-    GNUNET_NETWORK_fdset_copy_native (grs,
-                                     &rs,
-                                     max + 1);
-    GNUNET_NETWORK_fdset_copy_native (gws,
-                                     &ws,
-                                     max + 1);
-    curl_download_task = GNUNET_SCHEDULER_add_select
-      (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
-       rtime,
-       grs, gws,
-       &curl_task_download,
-       curl_multi);
-    GNUNET_NETWORK_fdset_destroy (gws);
-    GNUNET_NETWORK_fdset_destroy (grs);
-  }
-  else
-  {
-    curl_download_task = GNUNET_SCHEDULER_add_delayed
-      (rtime,
-       &curl_task_download,
-       curl_multi);
-  }
+  curl_multi_wait (curl_multi,
+                   NULL,
+                   0,
+                   1000, // millisecs.
+                   &numfds);
+
+  curl_download_task = GNUNET_SCHEDULER_add_now
+     (&curl_task_download,
+      curl_multi);
 }
 
 
@@ -648,6 +599,8 @@ curl_task_download (void *cls)
     running = 0;
     mret = curl_multi_perform (curl_multi,
                               &running);
+
+
     while (NULL != (msg = curl_multi_info_read (curl_multi,
                                                &msgnum)))
     {
@@ -1155,7 +1108,7 @@ create_response (void *cls,
     return MHD_YES;
   }
 
-  /* Upload (from the *client*) finished,
+  /* Upload (*from the client*) finished,
    * generate curl request to the proxied service.  */
   if (NULL == hr->curl)
   {
@@ -1294,9 +1247,11 @@ create_response (void *cls,
         const char *us;
         long upload_size;
 
-        us = MHD_lookup_connection_value (con,
-                                          MHD_HEADER_KIND,
-                                          MHD_HTTP_HEADER_CONTENT_LENGTH);
+        us = MHD_lookup_connection_value
+          (con,
+           MHD_HEADER_KIND,
+           MHD_HTTP_HEADER_CONTENT_LENGTH);
+
         if ( (1 == sscanf (us,
                            "%ld",
                            &upload_size)) &&
@@ -1315,13 +1270,20 @@ create_response (void *cls,
     else if (0 == strcasecmp (meth,
                              MHD_HTTP_METHOD_POST))
     {
+
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Crafting a CURL POST request\n");
+
       hr->state = REQUEST_STATE_UPLOAD_STARTED;
       curl_easy_setopt (hr->curl,
                        CURLOPT_POST,
                        1L);
-      curl_easy_setopt (hr->curl,
-                        CURLOPT_READFUNCTION,
-                        &curl_upload_cb);
+      GNUNET_assert
+        (CURLE_OK == curl_easy_setopt
+          (hr->curl,
+           CURLOPT_READFUNCTION,
+           &curl_upload_cb));
+
       curl_easy_setopt (hr->curl,
                        CURLOPT_READDATA,
                        hr);
@@ -1329,9 +1291,11 @@ create_response (void *cls,
         const char *us;
         long upload_size;
 
-        us = MHD_lookup_connection_value (con,
-                                          MHD_HEADER_KIND,
-                                          MHD_HTTP_HEADER_CONTENT_LENGTH);
+        us = MHD_lookup_connection_value
+          (con,
+           MHD_HEADER_KIND,
+           MHD_HTTP_HEADER_CONTENT_LENGTH);
+
         if ( (1 == sscanf (us,
                            "%ld",
                            &upload_size)) &&
@@ -1342,9 +1306,11 @@ create_response (void *cls,
                             upload_size);
         }
       }
+
       curl_easy_setopt (hr->curl,
                         CURLOPT_WRITEFUNCTION,
                         &curl_download_cb);
+
       curl_easy_setopt (hr->curl,
                        CURLOPT_WRITEDATA,
                        hr);

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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