gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-twister] 02/02: 3557.


From: gnunet
Subject: [GNUnet-SVN] [taler-twister] 02/02: 3557.
Date: Thu, 20 Sep 2018 15:23:37 +0200

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

marcello pushed a commit to branch master
in repository twister.

commit 2f69f626b0e47a7affa206038c217cc0bb09e49c
Author: Marcello Stanisci <address@hidden>
AuthorDate: Thu Sep 20 15:22:33 2018 +0200

    3557.
    
    Unpausing the download callback as soon as a Connection: close
    header is received.
---
 src/twister/taler-twister-service.c | 57 +++++++++++++++++++++++++++++++++++--
 1 file changed, 54 insertions(+), 3 deletions(-)

diff --git a/src/twister/taler-twister-service.c 
b/src/twister/taler-twister-service.c
index 6fde9a3..d12bc67 100644
--- a/src/twister/taler-twister-service.c
+++ b/src/twister/taler-twister-service.c
@@ -41,6 +41,12 @@
 #include <taler/taler_util.h>
 
 
+/** 
+ * We allow X runs of the progress callback before
+ * declaring the upload callback dead.
+ */
+#define DOWNLOAD_PAUSED_TIMES_MAX 10
+
 /**
  * Log curl error.
  *
@@ -118,12 +124,12 @@ struct HttpRequest
   /**
    * Client socket read task
    */
-  struct GNUNET_SCHEDULER_Task * rtask;
+  struct GNUNET_SCHEDULER_Task *rtask;
 
   /**
    * Client socket write task
    */
-  struct GNUNET_SCHEDULER_Task * wtask;
+  struct GNUNET_SCHEDULER_Task *wtask;
 
   /**
    * Buffer we use for moving data between MHD and
@@ -190,6 +196,17 @@ struct HttpRequest
    * Request processing state machine.
    */
   enum RequestState state;
+
+  /**
+   * Indicates that the download callback is sleeping.
+   */
+  int download_paused;
+
+  /**
+   * Indicates that the Web server returned a "Connection: close"
+   * header line.
+   */
+  int connection_closed;
 };
 
 
@@ -334,6 +351,9 @@ curl_check_hdr (void *buffer,
   char *hdr_val;
   char *tok;
 
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Checking headers..\n");
+
   ndup = GNUNET_strndup (buffer, bytes);
   hdr_type = strtok (ndup, ":");
   if (NULL == hdr_type)
@@ -375,6 +395,18 @@ curl_check_hdr (void *buffer,
     *tok = '\0';
   if (NULL != (tok = strchr (hdr_val, '\t')))
     *tok = '\0';
+
+  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;
+  }
+
+
   if (0 != strlen (hdr_val)) /* Rely in MHD to set those */
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -458,7 +490,12 @@ curl_download_cb (void *ptr,
              "Curl download proceeding\n");
 
   if (REQUEST_STATE_DOWNLOAD_STARTED != hr->state) 
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Download callback goes to sleep\n");
+    hr->download_paused = GNUNET_YES;
     return CURL_WRITEFUNC_PAUSE;
+  }
 
   GNUNET_assert
     (REQUEST_STATE_DOWNLOAD_STARTED == hr->state);
@@ -735,8 +772,22 @@ curl_progress_cb (void *clientp,
                   double ultotal,
                   double ulnow)
 {
+  struct HttpRequest *hr = clientp;
+
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "I'm the progress callback\n");
+              "Progress callback..\n");
+
+  if ((GNUNET_YES == hr->download_paused)
+    && (GNUNET_YES == hr->connection_closed))
+  {
+    hr->state = REQUEST_STATE_DOWNLOAD_STARTED;
+    hr->download_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");
+  }
+
   return CURLE_OK;
 }
 

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



reply via email to

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