diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-02-09 21:25:05 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-02-09 21:25:05 +0100 |
commit | 1b96f3d3b0e8d7f5b8f4843f4ef728dd72978f3e (patch) | |
tree | 73fb16b78756ad43281c7e59c5bdfd34d2e72cb8 /src | |
parent | e666ad21ecda27d6fb4ada9e83c7d8f0098ca5d4 (diff) |
set curl timeout when long-polling
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/exchange_api_deposits_get.c | 18 | ||||
-rw-r--r-- | src/lib/exchange_api_purses_get.c | 18 | ||||
-rw-r--r-- | src/lib/exchange_api_reserves_get.c | 18 |
3 files changed, 39 insertions, 15 deletions
diff --git a/src/lib/exchange_api_deposits_get.c b/src/lib/exchange_api_deposits_get.c index ee5f9dc68..20eaea3d3 100644 --- a/src/lib/exchange_api_deposits_get.c +++ b/src/lib/exchange_api_deposits_get.c @@ -272,6 +272,9 @@ TALER_EXCHANGE_deposits_get ( + sizeof (struct TALER_MerchantPublicKeyP) + sizeof (struct TALER_PrivateContractHashP) + sizeof (struct TALER_MerchantSignatureP)) * 2 + 48]; + unsigned int tms + = (unsigned int) timeout.rel_value_us + / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us; GNUNET_CRYPTO_eddsa_key_get_public (&merchant_priv->eddsa_priv, &merchant.eddsa_pub); @@ -323,10 +326,8 @@ TALER_EXCHANGE_deposits_get ( GNUNET_snprintf ( timeout_str, sizeof (timeout_str), - "%llu", - (unsigned long long) ( - timeout.rel_value_us - / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us)); + "%u", + tms); } GNUNET_snprintf (arg_str, @@ -337,7 +338,7 @@ TALER_EXCHANGE_deposits_get ( chash_str, cpub_str, msig_str, - GNUNET_TIME_relative_is_zero (timeout) + 0 == tms ? "" : "&timeout_ms=", timeout_str); @@ -365,6 +366,13 @@ TALER_EXCHANGE_deposits_get ( GNUNET_free (dwh); return NULL; } + if (0 != tms) + { + GNUNET_break (CURLE_OK == + curl_easy_setopt (eh, + CURLOPT_TIMEOUT_MS, + (long) (tms + 100L))); + } dwh->job = GNUNET_CURL_job_add (ctx, eh, &handle_deposit_wtid_finished, diff --git a/src/lib/exchange_api_purses_get.c b/src/lib/exchange_api_purses_get.c index 7a6b2707f..dc22c75ad 100644 --- a/src/lib/exchange_api_purses_get.c +++ b/src/lib/exchange_api_purses_get.c @@ -217,6 +217,9 @@ TALER_EXCHANGE_purse_get ( struct TALER_EXCHANGE_PurseGetHandle *pgh; CURL *eh; char arg_str[sizeof (*purse_pub) * 2 + 64]; + unsigned int tms + = (unsigned int) timeout.rel_value_us + / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us; pgh = GNUNET_new (struct TALER_EXCHANGE_PurseGetHandle); pgh->cb = cb; @@ -233,11 +236,9 @@ TALER_EXCHANGE_purse_get ( *end = '\0'; GNUNET_snprintf (timeout_str, sizeof (timeout_str), - "%llu", - (unsigned long long) - (timeout.rel_value_us - / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us)); - if (GNUNET_TIME_relative_is_zero (timeout)) + "%u", + tms); + if (0 == tms) GNUNET_snprintf (arg_str, sizeof (arg_str), "purses/%s/%s", @@ -267,6 +268,13 @@ TALER_EXCHANGE_purse_get ( GNUNET_free (pgh); return NULL; } + if (0 != tms) + { + GNUNET_break (CURLE_OK == + curl_easy_setopt (eh, + CURLOPT_TIMEOUT_MS, + (long) (tms + 100L))); + } pgh->job = GNUNET_CURL_job_add (ctx, eh, &handle_purse_get_finished, diff --git a/src/lib/exchange_api_reserves_get.c b/src/lib/exchange_api_reserves_get.c index 7b59ba9a4..b6980dd1d 100644 --- a/src/lib/exchange_api_reserves_get.c +++ b/src/lib/exchange_api_reserves_get.c @@ -191,6 +191,9 @@ TALER_EXCHANGE_reserves_get ( struct TALER_EXCHANGE_ReservesGetHandle *rgh; CURL *eh; char arg_str[sizeof (struct TALER_ReservePublicKeyP) * 2 + 16 + 32]; + unsigned int tms + = (unsigned int) timeout.rel_value_us + / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us; { char pub_str[sizeof (struct TALER_ReservePublicKeyP) * 2]; @@ -205,11 +208,9 @@ TALER_EXCHANGE_reserves_get ( *end = '\0'; GNUNET_snprintf (timeout_str, sizeof (timeout_str), - "%llu", - (unsigned long long) - (timeout.rel_value_us - / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us)); - if (GNUNET_TIME_relative_is_zero (timeout)) + "%u", + tms); + if (0 == tms) GNUNET_snprintf (arg_str, sizeof (arg_str), "reserves/%s", @@ -241,6 +242,13 @@ TALER_EXCHANGE_reserves_get ( GNUNET_free (rgh); return NULL; } + if (0 != tms) + { + GNUNET_break (CURLE_OK == + curl_easy_setopt (eh, + CURLOPT_TIMEOUT_MS, + (long) (tms + 100L))); + } rgh->job = GNUNET_CURL_job_add (ctx, eh, &handle_reserves_get_finished, |