diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-06-28 13:28:11 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-06-28 13:28:11 +0200 |
commit | c7546a62b87c735ef3921904f1253adf9a74b9b1 (patch) | |
tree | f374f48d0be29d3606dbf63f7699368f5a84d304 /src/reducer/anastasis_api_redux.c | |
parent | 3e74c39480cb1236a31e7a167d306e32a0a92f5d (diff) | |
download | anastasis-c7546a62b87c735ef3921904f1253adf9a74b9b1.tar.gz anastasis-c7546a62b87c735ef3921904f1253adf9a74b9b1.tar.bz2 anastasis-c7546a62b87c735ef3921904f1253adf9a74b9b1.zip |
-support poll_providers also during backup
Diffstat (limited to 'src/reducer/anastasis_api_redux.c')
-rw-r--r-- | src/reducer/anastasis_api_redux.c | 71 |
1 files changed, 63 insertions, 8 deletions
diff --git a/src/reducer/anastasis_api_redux.c b/src/reducer/anastasis_api_redux.c index 7554b06..36386de 100644 --- a/src/reducer/anastasis_api_redux.c +++ b/src/reducer/anastasis_api_redux.c @@ -148,6 +148,11 @@ struct ConfigRequest struct GNUNET_TIME_Absolute timeout_at; /** + * How long do we wait before trying again? + */ + struct GNUNET_TIME_Relative backoff; + + /** * Obtained status code. */ unsigned int http_status; @@ -581,6 +586,16 @@ notify_waiting_cb (void *cls) /** + * Function called when it is time to retry a + * failed /config request. + * + * @param cls the `struct ConfigRequest *` to retry. + */ +static void +retry_config (void *cls); + + +/** * Function called with the results of a #ANASTASIS_get_config(). * * @param cls closure @@ -595,8 +610,11 @@ config_cb (void *cls, struct ConfigRequest *cr = cls; cr->co = NULL; - GNUNET_SCHEDULER_cancel (cr->tt); - cr->tt = NULL; + if (NULL != cr->tt) + { + GNUNET_SCHEDULER_cancel (cr->tt); + cr->tt = NULL; + } cr->http_status = http_status; if (MHD_HTTP_OK != http_status) { @@ -642,6 +660,13 @@ config_cb (void *cls, } } notify_waiting (cr); + if (MHD_HTTP_OK != http_status) + { + cr->backoff = GNUNET_TIME_STD_BACKOFF (cr->backoff); + cr->tt = GNUNET_SCHEDULER_add_delayed (cr->backoff, + &retry_config, + cr); + } } @@ -656,11 +681,41 @@ config_request_timeout (void *cls) struct ConfigRequest *cr = cls; cr->tt = NULL; - ANASTASIS_config_cancel (cr->co); - cr->co = NULL; + if (NULL != cr->co) + { + ANASTASIS_config_cancel (cr->co); + cr->co = NULL; + } cr->http_status = 0; cr->ec = TALER_EC_GENERIC_TIMEOUT; notify_waiting (cr); + cr->backoff = GNUNET_TIME_STD_BACKOFF (cr->backoff); + cr->tt = GNUNET_SCHEDULER_add_delayed (cr->backoff, + &retry_config, + cr); +} + + +static void +retry_config (void *cls) +{ + struct ConfigRequest *cr = cls; + + cr->tt = NULL; + if (NULL != cr->co) + { + ANASTASIS_config_cancel (cr->co); + cr->co = NULL; + } + cr->timeout_at = GNUNET_TIME_relative_to_absolute (CONFIG_GENERIC_TIMEOUT); + cr->tt = GNUNET_SCHEDULER_add_at (cr->timeout_at, + &config_request_timeout, + cr); + cr->co = ANASTASIS_get_config (ANASTASIS_REDUX_ctx_, + cr->url, + &config_cb, + cr); + GNUNET_break (NULL != cr->co); } @@ -718,6 +773,10 @@ check_config (struct GNUNET_TIME_Relative timeout, } if (MHD_HTTP_OK == cr->http_status) return cr; + cr->timeout_at = GNUNET_TIME_relative_to_absolute (timeout); + cr->tt = GNUNET_SCHEDULER_add_at (cr->timeout_at, + &config_request_timeout, + cr); cr->co = ANASTASIS_get_config (ANASTASIS_REDUX_ctx_, cr->url, &config_cb, @@ -727,10 +786,6 @@ check_config (struct GNUNET_TIME_Relative timeout, GNUNET_break (0); return NULL; } - cr->timeout_at = GNUNET_TIME_relative_to_absolute (timeout); - cr->tt = GNUNET_SCHEDULER_add_at (cr->timeout_at, - &config_request_timeout, - cr); return cr; } |