diff options
-rw-r--r-- | src/backend/taler-merchant-httpd_exchanges.c | 35 |
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, |