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/transport/test_quota_compliance.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/transport/test_quota_compliance.c')
-rw-r--r-- | src/transport/test_quota_compliance.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c index ac43b8d05..250d3279f 100644 --- a/src/transport/test_quota_compliance.c +++ b/src/transport/test_quota_compliance.c | |||
@@ -47,9 +47,9 @@ static char *test_plugin; | |||
47 | 47 | ||
48 | static char *test_name; | 48 | static char *test_name; |
49 | 49 | ||
50 | static GNUNET_SCHEDULER_TaskIdentifier die_task; | 50 | static struct GNUNET_SCHEDULER_Task * die_task; |
51 | 51 | ||
52 | static GNUNET_SCHEDULER_TaskIdentifier measure_task; | 52 | static struct GNUNET_SCHEDULER_Task * measure_task; |
53 | 53 | ||
54 | struct PeerContext *p1; | 54 | struct PeerContext *p1; |
55 | 55 | ||
@@ -153,7 +153,7 @@ end () | |||
153 | datarate, quota_out_p1, quota_in_p2); | 153 | datarate, quota_out_p1, quota_in_p2); |
154 | } | 154 | } |
155 | 155 | ||
156 | if (die_task != GNUNET_SCHEDULER_NO_TASK) | 156 | if (die_task != NULL) |
157 | GNUNET_SCHEDULER_cancel (die_task); | 157 | GNUNET_SCHEDULER_cancel (die_task); |
158 | 158 | ||
159 | if (th != NULL) | 159 | if (th != NULL) |
@@ -171,10 +171,10 @@ end () | |||
171 | static void | 171 | static void |
172 | end_badly () | 172 | end_badly () |
173 | { | 173 | { |
174 | die_task = GNUNET_SCHEDULER_NO_TASK; | 174 | die_task = NULL; |
175 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Fail! Stopping peers\n"); | 175 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Fail! Stopping peers\n"); |
176 | 176 | ||
177 | if (measure_task != GNUNET_SCHEDULER_NO_TASK) | 177 | if (measure_task != NULL) |
178 | GNUNET_SCHEDULER_cancel (measure_task); | 178 | GNUNET_SCHEDULER_cancel (measure_task); |
179 | 179 | ||
180 | if (test_connected == GNUNET_YES) | 180 | if (test_connected == GNUNET_YES) |
@@ -244,7 +244,7 @@ notify_ready (void *cls, size_t size, void *buf) | |||
244 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 244 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
245 | "Timeout occurred while waiting for transmit_ready for message %u of %u\n", | 245 | "Timeout occurred while waiting for transmit_ready for message %u of %u\n", |
246 | msg_scheduled, TOTAL_MSGS); | 246 | msg_scheduled, TOTAL_MSGS); |
247 | if (GNUNET_SCHEDULER_NO_TASK != die_task) | 247 | if (NULL != die_task) |
248 | GNUNET_SCHEDULER_cancel (die_task); | 248 | GNUNET_SCHEDULER_cancel (die_task); |
249 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); | 249 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); |
250 | test_failed = 1; | 250 | test_failed = 1; |
@@ -348,7 +348,7 @@ measure (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
348 | { | 348 | { |
349 | static int counter; | 349 | static int counter; |
350 | 350 | ||
351 | measure_task = GNUNET_SCHEDULER_NO_TASK; | 351 | measure_task = NULL; |
352 | 352 | ||
353 | counter++; | 353 | counter++; |
354 | if ((DURATION.rel_value_us / 1000 / 1000LL) < counter) | 354 | if ((DURATION.rel_value_us / 1000 / 1000LL) < counter) |
@@ -472,7 +472,7 @@ run_measurement (unsigned long long p1_quota_in, | |||
472 | if ((p1 == NULL) || (p2 == NULL)) | 472 | if ((p1 == NULL) || (p2 == NULL)) |
473 | { | 473 | { |
474 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fail! Could not start peers!\n"); | 474 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fail! Could not start peers!\n"); |
475 | if (die_task != GNUNET_SCHEDULER_NO_TASK) | 475 | if (die_task != NULL) |
476 | GNUNET_SCHEDULER_cancel (die_task); | 476 | GNUNET_SCHEDULER_cancel (die_task); |
477 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); | 477 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); |
478 | return; | 478 | return; |