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 (b4bbe2c -> 51165a5)


From: gnunet
Subject: [GNUnet-SVN] [taler-twister] branch master updated (b4bbe2c -> 51165a5)
Date: Thu, 20 Sep 2018 20:10:37 +0200

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

grothoff pushed a change to branch master
in repository twister.

    from b4bbe2c  enable suspend resume
     new c27ec06  fix root cause of #5337: curl interprets early response from 
MHD as error response (even though it is a 200 OK) and then aborted the upload; 
so we should wait with the response until the upload is complete
     new 9ad1ebf  #5337 in proxy: if Web server returns response during upload, 
curl aborts upload so our proxy should give up on the upload as well and just 
proceed with the download
     new 51165a5  remove marcello-fix logic for #5337

The 3 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   |  21 ++++---
 src/twister/taler-twister-service.c | 117 ++++++++++--------------------------
 2 files changed, 47 insertions(+), 91 deletions(-)

diff --git a/src/test/test_twister_webserver.c 
b/src/test/test_twister_webserver.c
index bf32fcf..bb434c0 100644
--- a/src/test/test_twister_webserver.c
+++ b/src/test/test_twister_webserver.c
@@ -43,26 +43,33 @@ answer_to_connection
    const char *version, const char *upload_data,
    size_t *upload_data_size, void **con_cls)
 {
-  #if 0
+#if 0
   const char *page = "<html><body>Hello, browser!</body></html>";
-  #endif
-
+#endif
   const char *page = "{\"hello\": [{\"this\": \"browser!\"}],"\
                      "\"when\": \"today\"}";
-
   struct MHD_Response *response;
   int ret;
+
   (void)cls;               /* Unused. Silent compiler warning. */
   (void)url;               /* Unused. Silent compiler warning. */
   (void)method;            /* Unused. Silent compiler warning. */
   (void)version;           /* Unused. Silent compiler warning. */
   (void)upload_data;       /* Unused. Silent compiler warning. */
-  (void)upload_data_size;  /* Unused. Silent compiler warning. */
-  (void)con_cls;           /* Unused. Silent compiler warning. */
 
+  if (NULL == (*con_cls))
+    {
+      *con_cls = "first";
+      return MHD_YES;
+    }
+  if (0 != *upload_data_size)
+    {
+      *upload_data_size = 0;
+      return MHD_YES;
+    }
   response = MHD_create_response_from_buffer
     (strlen (page),
-     (void *) page, 
+     (void *) page,
      MHD_RESPMEM_PERSISTENT);
   ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
   MHD_destroy_response (response);
diff --git a/src/twister/taler-twister-service.c 
b/src/twister/taler-twister-service.c
index 5b2f43a..377a98f 100644
--- a/src/twister/taler-twister-service.c
+++ b/src/twister/taler-twister-service.c
@@ -41,14 +41,6 @@
 #include <taler/taler_util.h>
 
 /**
- * Keep logic of Marcello's fix for #5337? Unclear how it works, and
- * may be superceeded by subsequent revisions, but kept for now to
- * easily identify what might fix the issue (until CG can actually
- * reproduce it nicely).
- */
-#define MARCELLO_FIX 1
-
-/**
  * Log curl error.
  *
  * @param level log level
@@ -228,13 +220,6 @@ struct HttpRequest
    */
   int curl_paused;
 
-#if MARCELLO_FIX
-  /**
-   * Indicates that the Web server returned a "Connection: close"
-   * header line.
-   */
-  int connection_closed;
-#endif
 };
 
 
@@ -433,17 +418,6 @@ curl_check_hdr (void *buffer,
     *tok = '\0';
   if (NULL != (tok = strchr (hdr_val, '\t')))
     *tok = '\0';
-#if MARCELLO_FIX
-  if ( (0 == strcasecmp (hdr_type,
-                         MHD_HTTP_HEADER_CONNECTION) &&
-        (0 == strcasecmp (hdr_val,
-                          "close")) ) )
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Server wants to close the TCP connection\n");
-    hr->connection_closed = GNUNET_YES;
-  }
-#endif
 
   if (0 != strlen (hdr_val)) /* Rely in MHD to set those */
   {
@@ -522,7 +496,7 @@ static size_t
 curl_download_cb (void *ptr,
                  size_t size,
                  size_t nmemb,
-                 void* ctx)
+                 void *ctx)
 {
   struct HttpRequest *hr = ctx;
   size_t total = size * nmemb;
@@ -533,16 +507,22 @@ curl_download_cb (void *ptr,
   if ( (REQUEST_STATE_UPLOAD_STARTED == hr->state) ||
        (REQUEST_STATE_UPLOAD_DONE == hr->state) )
   {
-    /* we're still not done with the upload, do not yet
-       start the download, the IO buffer is still full
-       with upload data. */
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Pausing CURL download, waiting for UPLOAD to finish\n");
-    hr->curl_paused = GNUNET_YES;
-    return CURL_WRITEFUNC_PAUSE; /* not yet ready for data download */
+    /* Web server started with response before we finished
+       the upload.  In this case, current libcurl decides
+       to NOT complete the upload, so we should jump in the
+       state machine to process the download, dropping the
+       rest of the upload.  This should only really happen
+       with uploads without "Expect: 100 Continue" and
+       Web servers responding with an error (i.e. upload
+       not allowed) */
+    hr->state = REQUEST_STATE_DOWNLOAD_STARTED;
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Stopping %u byte upload: we are already downloading...\n",
+                (unsigned int) hr->io_len);
+    hr->io_len = 0;
   }
 
- if (REQUEST_STATE_DOWNLOAD_STARTED != hr->state)
+  if (REQUEST_STATE_DOWNLOAD_STARTED != hr->state)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Download callback goes to sleep\n");
@@ -571,6 +551,13 @@ curl_download_cb (void *ptr,
 
 
 /**
+ * Ask cURL for the select() sets and schedule cURL operations.
+ */
+static void
+curl_download_prepare (void);
+
+
+/**
  * cURL callback for uploaded (PUT/POST) data.
  * Copies from our `io_buf` to make it available to cURL.
  *
@@ -592,7 +579,13 @@ curl_upload_cb (void *buf,
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Upload cb is working...\n");
-
+  if ( (REQUEST_STATE_UPLOAD_STARTED != hr->state) &&
+       (REQUEST_STATE_UPLOAD_DONE != hr->state) )
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Upload cb aborts: we are already downloading...\n");
+    return CURL_READFUNC_ABORT;
+  }
   if ( (0 == hr->io_len) &&
        (REQUEST_STATE_UPLOAD_DONE != hr->state) )
   {
@@ -610,16 +603,11 @@ curl_upload_cb (void *buf,
       curl_easy_pause (hr->curl,
                       CURLPAUSE_CONT);
     }
+    curl_download_prepare ();
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Completed CURL UPLOAD\n");
     return 0; /* upload finished, can now download */
   }
-  if ( (REQUEST_STATE_UPLOAD_STARTED != hr->state) &&
-       (REQUEST_STATE_UPLOAD_DONE != hr->state) )
-  {
-    GNUNET_break (0);
-    return CURL_READFUNC_ABORT;
-  }
   to_copy = GNUNET_MIN (hr->io_len,
                         len);
   GNUNET_memcpy (buf,
@@ -729,6 +717,7 @@ curl_download_prepare ()
   }
 }
 
+
 /**
  * Task that is run when we are ready to receive
  * more data from curl.
@@ -844,33 +833,6 @@ curl_task_download (void *cls)
 }
 
 
-static int
-curl_progress_cb (void *clientp,
-                  double dltotal,
-                  double dlnow,
-                  double ultotal,
-                  double ulnow)
-{
-  struct HttpRequest *hr = clientp;
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Progress callback..\n");
-#if MARCELLO_FIX
-  if ( (GNUNET_YES == hr->curl_paused) &&
-       (GNUNET_YES == hr->connection_closed) )
-  {
-    hr->state = REQUEST_STATE_DOWNLOAD_STARTED;
-    hr->curl_paused = GNUNET_NO;
-    hr->connection_closed = GNUNET_NO;
-    curl_easy_pause (hr->curl, CURLPAUSE_CONT);
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Unpausing the download callback\n");
-  }
-#endif
-  return CURLE_OK;
-}
-
-
 /* *************** MHD response generation ******************* */
 
 
@@ -1362,10 +1324,9 @@ create_response (void *cls,
       flip_object (con,
                    hr->json,
                    flip_path_ul);
-
+      /* Existing io_len is enough to accomodate this encoding. */
       json_dumpb (hr->json,
                   hr->io_buf,
-/* Existing io_len is enough to accomodate this encoding.  */
                   hr->io_len,
                   JSON_COMPACT);
 
@@ -1387,10 +1348,9 @@ create_response (void *cls,
       modify_object (con,
                      hr->json,
                      modify_path_ul);
-
+      /* Existing io_len is enough to accomodate this encoding. */
       json_dumpb (hr->json,
                   hr->io_buf,
-/* Existing io_len is enough to accomodate this encoding.  */
                   hr->io_len,
                   JSON_COMPACT);
 
@@ -1500,21 +1460,11 @@ create_response (void *cls,
       hr->state = REQUEST_STATE_UPLOAD_STARTED;
 
       curl_easy_setopt (hr->curl,
-                        CURLOPT_XFERINFOFUNCTION,
-                        &curl_progress_cb);
-
-      curl_easy_setopt (hr->curl,
                         CURLOPT_XFERINFODATA,
                         hr);
-
-      curl_easy_setopt (hr->curl,
-                        CURLOPT_NOPROGRESS,
-                        0L);
-
       curl_easy_setopt (hr->curl,
                        CURLOPT_POST,
                        1L);
-
       curl_easy_setopt (hr->curl,
                         CURLOPT_VERBOSE,
                         1L);
@@ -1632,7 +1582,6 @@ create_response (void *cls,
     curl_easy_setopt (hr->curl,
                       CURLOPT_HTTPHEADER,
                       hr->headers);
-
     curl_download_prepare ();
 
     /* means (?) upload is over.  */

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



reply via email to

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