[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-merchant] branch master updated: set curl timeout when long-polli
From: |
gnunet |
Subject: |
[taler-merchant] branch master updated: set curl timeout when long-polling |
Date: |
Fri, 09 Feb 2024 21:25:29 +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 a8e20fe0 set curl timeout when long-polling
a8e20fe0 is described below
commit a8e20fe04d0ab35ab7a881f8a4ec72aa9d06b314
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Fri Feb 9 21:25:27 2024 +0100
set curl timeout when long-polling
---
contrib/wallet-core | 2 +-
src/bank/mb_credit.c | 2 +-
src/lib/merchant_api_get_kyc.c | 17 ++++++++++---
src/lib/merchant_api_get_orders.c | 24 ++++++++++++++----
src/lib/merchant_api_merchant_get_order.c | 31 ++++++++---------------
src/lib/merchant_api_wallet_get_order.c | 41 ++++++-------------------------
6 files changed, 52 insertions(+), 65 deletions(-)
diff --git a/contrib/wallet-core b/contrib/wallet-core
index 2fda3176..ae088de5 160000
--- a/contrib/wallet-core
+++ b/contrib/wallet-core
@@ -1 +1 @@
-Subproject commit 2fda31767a4d74d935ffd56130ad49b4eec1f2f7
+Subproject commit ae088de54c086613a52cd6dd8d88f6535634c420
diff --git a/src/bank/mb_credit.c b/src/bank/mb_credit.c
index f7b09350..65c48ac8 100644
--- a/src/bank/mb_credit.c
+++ b/src/bank/mb_credit.c
@@ -308,7 +308,7 @@ TALER_MERCHANT_BANK_credit_history (
GNUNET_break (CURLE_OK ==
curl_easy_setopt (eh,
CURLOPT_TIMEOUT_MS,
- (long) tms));
+ (long) (tms + 100L)));
}
hh->job = GNUNET_CURL_job_add2 (ctx,
eh,
diff --git a/src/lib/merchant_api_get_kyc.c b/src/lib/merchant_api_get_kyc.c
index 2590745f..a9aabbe0 100644
--- a/src/lib/merchant_api_get_kyc.c
+++ b/src/lib/merchant_api_get_kyc.c
@@ -262,17 +262,19 @@ kyc_get (struct GNUNET_CURL_Context *ctx,
struct TALER_MERCHANT_KycGetHandle *kyc;
CURL *eh;
char timeout_ms[32];
+ unsigned int tms;
kyc = GNUNET_new (struct TALER_MERCHANT_KycGetHandle);
kyc->ctx = ctx;
kyc->cb = cb;
kyc->cb_cls = cb_cls;
+ tms = (unsigned int) (timeout.rel_value_us
+ / GNUNET_TIME_UNIT_MILLISECONDS.
+ rel_value_us);
GNUNET_snprintf (timeout_ms,
sizeof (timeout_ms),
- "%llu",
- (unsigned long long) (timeout.rel_value_us
- / GNUNET_TIME_UNIT_MILLISECONDS.
- rel_value_us));
+ "%u",
+ tms);
kyc->url = TALER_url_join (url,
"kyc",
"h_wire",
@@ -300,6 +302,13 @@ kyc_get (struct GNUNET_CURL_Context *ctx,
"Requesting URL '%s'\n",
kyc->url);
eh = TALER_MERCHANT_curl_easy_get_ (kyc->url);
+ if (0 != tms)
+ {
+ GNUNET_break (CURLE_OK ==
+ curl_easy_setopt (eh,
+ CURLOPT_TIMEOUT_MS,
+ (long) (tms + 100L)));
+ }
kyc->job = GNUNET_CURL_job_add (ctx,
eh,
&handle_get_kyc_finished,
diff --git a/src/lib/merchant_api_get_orders.c
b/src/lib/merchant_api_get_orders.c
index ecddc455..af2b46d9 100644
--- a/src/lib/merchant_api_get_orders.c
+++ b/src/lib/merchant_api_get_orders.c
@@ -271,8 +271,8 @@ TALER_MERCHANT_orders_get3 (
{
struct TALER_MERCHANT_OrdersGetHandle *ogh;
CURL *eh;
- unsigned int timeout_ms = timeout.rel_value_us
- / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us;
+ unsigned int tms = timeout.rel_value_us
+ / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us;
GNUNET_assert (NULL != backend_url);
if (0 == delta)
@@ -298,8 +298,8 @@ TALER_MERCHANT_orders_get3 (
GNUNET_snprintf (tbuf,
sizeof (tbuf),
- "%llu",
- (unsigned long long) timeout_ms);
+ "%u",
+ tms);
GNUNET_snprintf (dbuf,
sizeof (dbuf),
"%lld",
@@ -354,7 +354,7 @@ TALER_MERCHANT_orders_get3 (
? dbuf
: NULL,
"timeout_ms",
- (0 != timeout_ms)
+ (0 != tms)
? tbuf
: NULL,
"session_id",
@@ -377,6 +377,20 @@ TALER_MERCHANT_orders_get3 (
"Requesting URL '%s'\n",
ogh->url);
eh = TALER_MERCHANT_curl_easy_get_ (ogh->url);
+ if (NULL == eh)
+ {
+ GNUNET_break (0);
+ GNUNET_free (ogh->url);
+ GNUNET_free (ogh);
+ return NULL;
+ }
+ if (0 != tms)
+ {
+ GNUNET_break (CURLE_OK ==
+ curl_easy_setopt (eh,
+ CURLOPT_TIMEOUT_MS,
+ (long) (tms + 100L)));
+ }
ogh->job = GNUNET_CURL_job_add (ctx,
eh,
&handle_get_orders_finished,
diff --git a/src/lib/merchant_api_merchant_get_order.c
b/src/lib/merchant_api_merchant_get_order.c
index 9f10c347..f410ee50 100644
--- a/src/lib/merchant_api_merchant_get_order.c
+++ b/src/lib/merchant_api_merchant_get_order.c
@@ -409,17 +409,10 @@ TALER_MERCHANT_merchant_order_get (struct
GNUNET_CURL_Context *ctx,
void *cb_cls)
{
struct TALER_MERCHANT_OrderMerchantGetHandle *omgh;
- unsigned long long tms;
- long tlong;
-
- tms = (unsigned long long) (timeout.rel_value_us
- / GNUNET_TIME_UNIT_MILLISECONDS.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);
+ unsigned int tms;
+
+ tms = (unsigned int) (timeout.rel_value_us
+ / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us);
omgh = GNUNET_new (struct TALER_MERCHANT_OrderMerchantGetHandle);
omgh->ctx = ctx;
omgh->cb = cb;
@@ -430,7 +423,7 @@ TALER_MERCHANT_merchant_order_get (struct
GNUNET_CURL_Context *ctx,
GNUNET_snprintf (timeout_ms,
sizeof (timeout_ms),
- "%llu",
+ "%u",
tms);
GNUNET_asprintf (&path,
"private/orders/%s",
@@ -461,16 +454,12 @@ TALER_MERCHANT_merchant_order_get (struct
GNUNET_CURL_Context *ctx,
GNUNET_free (omgh);
return NULL;
}
- if (CURLE_OK !=
- curl_easy_setopt (eh,
- CURLOPT_TIMEOUT_MS,
- tlong))
+ if (0 != tms)
{
- GNUNET_break (0);
- curl_easy_cleanup (eh);
- GNUNET_free (omgh->url);
- GNUNET_free (omgh);
- return NULL;
+ GNUNET_break (CURLE_OK ==
+ curl_easy_setopt (eh,
+ CURLOPT_TIMEOUT_MS,
+ (long) (tms + 100L)));
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
diff --git a/src/lib/merchant_api_wallet_get_order.c
b/src/lib/merchant_api_wallet_get_order.c
index b0a4d9b9..763b2c83 100644
--- a/src/lib/merchant_api_wallet_get_order.c
+++ b/src/lib/merchant_api_wallet_get_order.c
@@ -205,8 +205,7 @@ TALER_MERCHANT_wallet_order_get (
void *cb_cls)
{
struct TALER_MERCHANT_OrderWalletGetHandle *owgh;
- unsigned long long tms;
- long tlong;
+ unsigned int tms;
GNUNET_assert (NULL != backend_url);
GNUNET_assert (NULL != order_id);
@@ -214,14 +213,8 @@ TALER_MERCHANT_wallet_order_get (
owgh->ctx = ctx;
owgh->cb = cb;
owgh->cb_cls = cb_cls;
- tms = (unsigned long long) (timeout.rel_value_us
- / GNUNET_TIME_UNIT_MILLISECONDS.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);
+ tms = (unsigned int) (timeout.rel_value_us
+ / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us);
{
char timeout_ms[32];
struct GNUNET_CRYPTO_HashAsciiEncoded h_contract_s;
@@ -231,7 +224,7 @@ TALER_MERCHANT_wallet_order_get (
&h_contract_s);
GNUNET_snprintf (timeout_ms,
sizeof (timeout_ms),
- "%llu",
+ "%u",
tms);
GNUNET_asprintf (&path,
"orders/%s",
@@ -271,28 +264,10 @@ TALER_MERCHANT_wallet_order_get (
eh = TALER_MERCHANT_curl_easy_get_ (owgh->url);
if (0 != tms)
{
- if (CURLE_OK !=
- curl_easy_setopt (eh,
- CURLOPT_TIMEOUT_MS,
- (long) tms))
- {
- GNUNET_break (0);
- curl_easy_cleanup (eh);
- GNUNET_free (owgh->url);
- GNUNET_free (owgh);
- return NULL;
- }
- }
- if (CURLE_OK !=
- curl_easy_setopt (eh,
- CURLOPT_TIMEOUT_MS,
- tlong))
- {
- GNUNET_break (0);
- curl_easy_cleanup (eh);
- GNUNET_free (owgh->url);
- GNUNET_free (owgh);
- return NULL;
+ GNUNET_break (CURLE_OK ==
+ curl_easy_setopt (eh,
+ CURLOPT_TIMEOUT_MS,
+ (long) (tms + 100L)));
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-merchant] branch master updated: set curl timeout when long-polling,
gnunet <=