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/lib/exchange_api_reserves_get.c | |
parent | e666ad21ecda27d6fb4ada9e83c7d8f0098ca5d4 (diff) | |
download | exchange-1b96f3d3b0e8d7f5b8f4843f4ef728dd72978f3e.tar.xz |
set curl timeout when long-polling
Diffstat (limited to 'src/lib/exchange_api_reserves_get.c')
-rw-r--r-- | src/lib/exchange_api_reserves_get.c | 18 |
1 files changed, 13 insertions, 5 deletions
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, |