summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-06-26 16:24:39 +0200
committerChristian Grothoff <christian@grothoff.org>2022-06-26 16:24:39 +0200
commitf02805c676d0ffbbd400c7a311477f14b8ecfe0f (patch)
treeb0ac0ad9e92a06cb6dcfe4a094d854a7072a7de4 /src
parentccd79e68c6dd55b1c4b09a0f6abb3783f346ddcc (diff)
downloadanastasis-f02805c676d0ffbbd400c7a311477f14b8ecfe0f.tar.gz
anastasis-f02805c676d0ffbbd400c7a311477f14b8ecfe0f.tar.bz2
anastasis-f02805c676d0ffbbd400c7a311477f14b8ecfe0f.zip
-improve anastasis-gtk with hanging provider: shorten timeout when applicable
Diffstat (limited to 'src')
-rw-r--r--src/reducer/anastasis_api_redux.c39
1 files changed, 36 insertions, 3 deletions
diff --git a/src/reducer/anastasis_api_redux.c b/src/reducer/anastasis_api_redux.c
index 8090e00..7554b06 100644
--- a/src/reducer/anastasis_api_redux.c
+++ b/src/reducer/anastasis_api_redux.c
@@ -138,6 +138,16 @@ struct ConfigRequest
struct ConfigReduxWaiting *w_tail;
/**
+ * When did we start?
+ */
+ struct GNUNET_TIME_Absolute start_time;
+
+ /**
+ * When do we time out?
+ */
+ struct GNUNET_TIME_Absolute timeout_at;
+
+ /**
* Obtained status code.
*/
unsigned int http_status;
@@ -673,12 +683,34 @@ check_config (struct GNUNET_TIME_Relative timeout,
cr->url))
continue;
if (NULL != cr->co)
+ {
+ struct GNUNET_TIME_Relative duration;
+ struct GNUNET_TIME_Relative left;
+ struct GNUNET_TIME_Relative xleft;
+
+ duration = GNUNET_TIME_absolute_get_duration (cr->start_time);
+ left = GNUNET_TIME_relative_subtract (timeout,
+ duration);
+ xleft = GNUNET_TIME_absolute_get_remaining (cr->timeout_at);
+ if (GNUNET_TIME_relative_cmp (left,
+ <,
+ xleft))
+ {
+ /* new timeout is shorter! */
+ cr->timeout_at = GNUNET_TIME_relative_to_absolute (left);
+ GNUNET_SCHEDULER_cancel (cr->tt);
+ cr->tt = GNUNET_SCHEDULER_add_at (cr->timeout_at,
+ &config_request_timeout,
+ cr);
+ }
return cr; /* already on it */
+ }
break;
}
if (NULL == cr)
{
cr = GNUNET_new (struct ConfigRequest);
+ cr->start_time = GNUNET_TIME_absolute_get ();
cr->url = GNUNET_strdup (url);
GNUNET_CONTAINER_DLL_insert (cr_head,
cr_tail,
@@ -695,9 +727,10 @@ check_config (struct GNUNET_TIME_Relative timeout,
GNUNET_break (0);
return NULL;
}
- cr->tt = GNUNET_SCHEDULER_add_delayed (timeout,
- &config_request_timeout,
- cr);
+ cr->timeout_at = GNUNET_TIME_relative_to_absolute (timeout);
+ cr->tt = GNUNET_SCHEDULER_add_at (cr->timeout_at,
+ &config_request_timeout,
+ cr);
return cr;
}