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