summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-12-28 15:04:54 +0100
committerChristian Grothoff <christian@grothoff.org>2022-12-28 15:04:54 +0100
commit99db83bca3b5dbe1399a642eb4192546bbfd24df (patch)
tree7d1c0d84666092d9aca63abfae8dc3ee187de3b0 /src/backend
parentd80d7d637e89415bd5c3dd2fdbd900bb34963848 (diff)
downloadmerchant-99db83bca3b5dbe1399a642eb4192546bbfd24df.tar.gz
merchant-99db83bca3b5dbe1399a642eb4192546bbfd24df.tar.bz2
merchant-99db83bca3b5dbe1399a642eb4192546bbfd24df.zip
modify merchant to use incremental /keys fetching
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/taler-merchant-httpd_exchanges.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/backend/taler-merchant-httpd_exchanges.c b/src/backend/taler-merchant-httpd_exchanges.c
index b74ae211..7f6336c1 100644
--- a/src/backend/taler-merchant-httpd_exchanges.c
+++ b/src/backend/taler-merchant-httpd_exchanges.c
@@ -296,7 +296,6 @@ keys_mgmt_cb (void *cls,
* the closure.
*
* @param cls the exchange
- *
*/
static void
retry_exchange (void *cls)
@@ -308,16 +307,27 @@ retry_exchange (void *cls)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Connecting to exchange %s in retry_exchange()\n",
exchange->url);
- if (NULL != exchange->conn)
+ if (NULL == exchange->conn)
{
- TALER_EXCHANGE_disconnect (exchange->conn);
- exchange->conn = NULL;
+ exchange->conn = TALER_EXCHANGE_connect (merchant_curl_ctx,
+ exchange->url,
+ &keys_mgmt_cb,
+ exchange,
+ TALER_EXCHANGE_OPTION_END);
+ }
+ else
+ {
+ struct GNUNET_TIME_Timestamp next;
+
+ next = TALER_EXCHANGE_check_keys_current (exchange->conn,
+ TALER_EXCHANGE_CKF_NONE);
+ if (! GNUNET_TIME_absolute_is_zero (next.abs_time))
+ {
+ exchange->retry_task = GNUNET_SCHEDULER_add_at (next.abs_time,
+ &retry_exchange,
+ exchange);
+ }
}
- exchange->conn = TALER_EXCHANGE_connect (merchant_curl_ctx,
- exchange->url,
- &keys_mgmt_cb,
- exchange,
- TALER_EXCHANGE_OPTION_END);
/* Note: while the API spec says 'returns NULL on error', the implementation
actually never returns NULL. */
GNUNET_break (NULL != exchange->conn);
@@ -999,9 +1009,16 @@ keys_mgmt_cb (void *cls,
expire = TALER_EXCHANGE_check_keys_current (exchange->conn,
TALER_EXCHANGE_CKF_NONE);
if (0 == GNUNET_TIME_absolute_is_zero (expire.abs_time))
+ {
delay = RELOAD_DELAY;
+ }
else
+ {
delay = GNUNET_TIME_absolute_get_remaining (expire.abs_time);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "/keys response from expires at %s! Retrying at that time!\n",
+ GNUNET_TIME_absolute2s (expire.abs_time));
+ }
if (GNUNET_TIME_relative_is_zero (delay))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,