diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-12-24 01:10:47 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-12-24 01:10:47 +0000 |
commit | f1f603c7d0b3f03dca46a4f313472288eb080eb1 (patch) | |
tree | 3a29966b02dfb83e0a8a8d5c42b3116380209fb0 /src/statistics/statistics_api.c | |
parent | 53cd5b8eda2fa8db86b0907a62a39598981d008a (diff) | |
download | gnunet-f1f603c7d0b3f03dca46a4f313472288eb080eb1.tar.gz gnunet-f1f603c7d0b3f03dca46a4f313472288eb080eb1.zip |
making GNUNET_SCHEDULER_cancel() perform in O(1) instead of O(n) to help or even fully address #3247
Diffstat (limited to 'src/statistics/statistics_api.c')
-rw-r--r-- | src/statistics/statistics_api.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c index 52d49308a..661cca796 100644 --- a/src/statistics/statistics_api.c +++ b/src/statistics/statistics_api.c | |||
@@ -149,7 +149,7 @@ struct GNUNET_STATISTICS_GetHandle | |||
149 | /** | 149 | /** |
150 | * Task run on timeout. | 150 | * Task run on timeout. |
151 | */ | 151 | */ |
152 | GNUNET_SCHEDULER_TaskIdentifier timeout_task; | 152 | struct GNUNET_SCHEDULER_Task * timeout_task; |
153 | 153 | ||
154 | /** | 154 | /** |
155 | * Associated value. | 155 | * Associated value. |
@@ -230,7 +230,7 @@ struct GNUNET_STATISTICS_Handle | |||
230 | /** | 230 | /** |
231 | * Task doing exponential back-off trying to reconnect. | 231 | * Task doing exponential back-off trying to reconnect. |
232 | */ | 232 | */ |
233 | GNUNET_SCHEDULER_TaskIdentifier backoff_task; | 233 | struct GNUNET_SCHEDULER_Task * backoff_task; |
234 | 234 | ||
235 | /** | 235 | /** |
236 | * Time for next connect retry. | 236 | * Time for next connect retry. |
@@ -367,10 +367,10 @@ schedule_watch_request (struct GNUNET_STATISTICS_Handle *h, | |||
367 | static void | 367 | static void |
368 | free_action_item (struct GNUNET_STATISTICS_GetHandle *gh) | 368 | free_action_item (struct GNUNET_STATISTICS_GetHandle *gh) |
369 | { | 369 | { |
370 | if (GNUNET_SCHEDULER_NO_TASK != gh->timeout_task) | 370 | if (NULL != gh->timeout_task) |
371 | { | 371 | { |
372 | GNUNET_SCHEDULER_cancel (gh->timeout_task); | 372 | GNUNET_SCHEDULER_cancel (gh->timeout_task); |
373 | gh->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 373 | gh->timeout_task = NULL; |
374 | } | 374 | } |
375 | GNUNET_free_non_null (gh->subsystem); | 375 | GNUNET_free_non_null (gh->subsystem); |
376 | GNUNET_free_non_null (gh->name); | 376 | GNUNET_free_non_null (gh->name); |
@@ -426,7 +426,7 @@ try_connect (struct GNUNET_STATISTICS_Handle *h) | |||
426 | struct GNUNET_STATISTICS_GetHandle *gn; | 426 | struct GNUNET_STATISTICS_GetHandle *gn; |
427 | unsigned int i; | 427 | unsigned int i; |
428 | 428 | ||
429 | if (GNUNET_SCHEDULER_NO_TASK != h->backoff_task) | 429 | if (NULL != h->backoff_task) |
430 | return GNUNET_NO; | 430 | return GNUNET_NO; |
431 | if (NULL != h->client) | 431 | if (NULL != h->client) |
432 | return GNUNET_YES; | 432 | return GNUNET_YES; |
@@ -470,7 +470,7 @@ reconnect_task (void *cls, | |||
470 | { | 470 | { |
471 | struct GNUNET_STATISTICS_Handle *h = cls; | 471 | struct GNUNET_STATISTICS_Handle *h = cls; |
472 | 472 | ||
473 | h->backoff_task = GNUNET_SCHEDULER_NO_TASK; | 473 | h->backoff_task = NULL; |
474 | schedule_action (h); | 474 | schedule_action (h); |
475 | } | 475 | } |
476 | 476 | ||
@@ -502,7 +502,7 @@ reconnect_later (struct GNUNET_STATISTICS_Handle *h) | |||
502 | int loss; | 502 | int loss; |
503 | struct GNUNET_STATISTICS_GetHandle *gh; | 503 | struct GNUNET_STATISTICS_GetHandle *gh; |
504 | 504 | ||
505 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == h->backoff_task); | 505 | GNUNET_assert (NULL == h->backoff_task); |
506 | if (GNUNET_YES == h->do_destroy) | 506 | if (GNUNET_YES == h->do_destroy) |
507 | { | 507 | { |
508 | /* So we are shutting down and the service is not reachable. | 508 | /* So we are shutting down and the service is not reachable. |
@@ -992,10 +992,10 @@ GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h, | |||
992 | if (NULL == h) | 992 | if (NULL == h) |
993 | return; | 993 | return; |
994 | GNUNET_assert (GNUNET_NO == h->do_destroy); // Don't call twice. | 994 | GNUNET_assert (GNUNET_NO == h->do_destroy); // Don't call twice. |
995 | if (GNUNET_SCHEDULER_NO_TASK != h->backoff_task) | 995 | if (NULL != h->backoff_task) |
996 | { | 996 | { |
997 | GNUNET_SCHEDULER_cancel (h->backoff_task); | 997 | GNUNET_SCHEDULER_cancel (h->backoff_task); |
998 | h->backoff_task = GNUNET_SCHEDULER_NO_TASK; | 998 | h->backoff_task = NULL; |
999 | } | 999 | } |
1000 | if (sync_first) | 1000 | if (sync_first) |
1001 | { | 1001 | { |
@@ -1117,7 +1117,7 @@ schedule_action (struct GNUNET_STATISTICS_Handle *h) | |||
1117 | struct GNUNET_TIME_Relative timeout; | 1117 | struct GNUNET_TIME_Relative timeout; |
1118 | 1118 | ||
1119 | if ( (NULL != h->th) || | 1119 | if ( (NULL != h->th) || |
1120 | (GNUNET_SCHEDULER_NO_TASK != h->backoff_task) ) | 1120 | (NULL != h->backoff_task) ) |
1121 | return; /* action already pending */ | 1121 | return; /* action already pending */ |
1122 | if (GNUNET_YES != try_connect (h)) | 1122 | if (GNUNET_YES != try_connect (h)) |
1123 | { | 1123 | { |
@@ -1172,7 +1172,7 @@ run_get_timeout (void *cls, | |||
1172 | GNUNET_STATISTICS_Callback cont = gh->cont; | 1172 | GNUNET_STATISTICS_Callback cont = gh->cont; |
1173 | void *cont_cls = gh->cls; | 1173 | void *cont_cls = gh->cls; |
1174 | 1174 | ||
1175 | gh->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 1175 | gh->timeout_task = NULL; |
1176 | GNUNET_STATISTICS_get_cancel (gh); | 1176 | GNUNET_STATISTICS_get_cancel (gh); |
1177 | cont (cont_cls, GNUNET_SYSERR); | 1177 | cont (cont_cls, GNUNET_SYSERR); |
1178 | } | 1178 | } |
@@ -1246,10 +1246,10 @@ GNUNET_STATISTICS_get_cancel (struct GNUNET_STATISTICS_GetHandle *gh) | |||
1246 | { | 1246 | { |
1247 | if (NULL == gh) | 1247 | if (NULL == gh) |
1248 | return; | 1248 | return; |
1249 | if (GNUNET_SCHEDULER_NO_TASK != gh->timeout_task) | 1249 | if (NULL != gh->timeout_task) |
1250 | { | 1250 | { |
1251 | GNUNET_SCHEDULER_cancel (gh->timeout_task); | 1251 | GNUNET_SCHEDULER_cancel (gh->timeout_task); |
1252 | gh->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 1252 | gh->timeout_task = NULL; |
1253 | } | 1253 | } |
1254 | gh->cont = NULL; | 1254 | gh->cont = NULL; |
1255 | if (gh->sh->current == gh) | 1255 | if (gh->sh->current == gh) |