gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: pass timeout in /check-payment


From: gnunet
Subject: [taler-merchant] branch master updated: pass timeout in /check-payment
Date: Sat, 09 Nov 2019 13:08:54 +0100

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

grothoff pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new 8629eb5  pass timeout in /check-payment
8629eb5 is described below

commit 8629eb50c25e71cd58de6932c6129998ec4cb5ac
Author: Christian Grothoff <address@hidden>
AuthorDate: Sat Nov 9 13:08:45 2019 +0100

    pass timeout in /check-payment
---
 src/lib/merchant_api_check_payment.c | 28 +++++++++++++++++++++++++---
 src/lib/merchant_api_poll_payment.c  |  5 -----
 2 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/src/lib/merchant_api_check_payment.c 
b/src/lib/merchant_api_check_payment.c
index fe38a18..4a9e70e 100644
--- a/src/lib/merchant_api_check_payment.c
+++ b/src/lib/merchant_api_check_payment.c
@@ -198,10 +198,23 @@ TALER_MERCHANT_check_payment (struct GNUNET_CURL_Context 
*ctx,
 {
   struct TALER_MERCHANT_CheckPaymentOperation *cpo;
   CURL *eh;
+  char *timeout_s;
+  unsigned int ts;
+  long tlong;
 
   GNUNET_assert (NULL != backend_url);
   GNUNET_assert (NULL != order_id);
-
+  ts = (unsigned int) (timeout.rel_value_us
+                       / GNUNET_TIME_UNIT_SECONDS.rel_value_us);
+  /* set curl timeout to *our* long poll timeout plus one minute
+     (for network latency and processing delays) */
+  tlong = (long) (GNUNET_TIME_relative_add (timeout,
+                                            GNUNET_TIME_UNIT_MINUTES).
+                  rel_value_us
+                  / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us);
+  GNUNET_asprintf (&timeout_s,
+                   "%u",
+                   ts);
   cpo = GNUNET_new (struct TALER_MERCHANT_CheckPaymentOperation);
   cpo->ctx = ctx;
   cpo->cb = check_payment_cb;
@@ -209,7 +222,10 @@ TALER_MERCHANT_check_payment (struct GNUNET_CURL_Context 
*ctx,
   cpo->url = TALER_url_join (backend_url, "check-payment",
                              "order_id", order_id,
                              "session_id", session_id,
+                             (0 != ts) ? "timeout" : NULL,
+                             timeout_s,
                              NULL);
+  GNUNET_free (timeout_s);
   eh = curl_easy_init ();
   if (CURLE_OK != curl_easy_setopt (eh,
                                     CURLOPT_URL,
@@ -218,11 +234,17 @@ TALER_MERCHANT_check_payment (struct GNUNET_CURL_Context 
*ctx,
     GNUNET_break (0);
     return NULL;
   }
+  if (CURLE_OK != curl_easy_setopt (eh,
+                                    CURLOPT_TIMEOUT_MS,
+                                    tlong))
+  {
+    GNUNET_break (0);
+    return NULL;
+  }
 
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "checking payment from %s\n",
+              "Checking payment from %s\n",
               cpo->url);
-
   if (NULL == (cpo->job = GNUNET_CURL_job_add (ctx,
                                                eh,
                                                GNUNET_YES,
diff --git a/src/lib/merchant_api_poll_payment.c 
b/src/lib/merchant_api_poll_payment.c
index 024595d..af44d2b 100644
--- a/src/lib/merchant_api_poll_payment.c
+++ b/src/lib/merchant_api_poll_payment.c
@@ -248,11 +248,6 @@ TALER_MERCHANT_poll_payment (struct GNUNET_CURL_Context 
*ctx,
                              (0 != ts) ? "timeout" : NULL,
                              timeout_s,
                              NULL);
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Long poll timeout is %s/%llu, url is %s\n",
-              timeout_s,
-              (unsigned long long) timeout.rel_value_us,
-              cpo->url);
   GNUNET_free (h_contract_s);
   GNUNET_free (timeout_s);
   eh = curl_easy_init ();

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



reply via email to

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