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_transport_api_blacklisting.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_transport_api_blacklisting.c')
-rw-r--r-- | src/transport/test_transport_api_blacklisting.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/transport/test_transport_api_blacklisting.c b/src/transport/test_transport_api_blacklisting.c index 2c3ab125a..09a12cef8 100644 --- a/src/transport/test_transport_api_blacklisting.c +++ b/src/transport/test_transport_api_blacklisting.c | |||
@@ -62,11 +62,11 @@ static struct GNUNET_TRANSPORT_Blacklist * blacklist_p1; | |||
62 | 62 | ||
63 | static struct GNUNET_TRANSPORT_Blacklist * blacklist_p2; | 63 | static struct GNUNET_TRANSPORT_Blacklist * blacklist_p2; |
64 | 64 | ||
65 | static GNUNET_SCHEDULER_TaskIdentifier die_task; | 65 | static struct GNUNET_SCHEDULER_Task * die_task; |
66 | 66 | ||
67 | static GNUNET_SCHEDULER_TaskIdentifier send_task; | 67 | static struct GNUNET_SCHEDULER_Task * send_task; |
68 | 68 | ||
69 | static GNUNET_SCHEDULER_TaskIdentifier shutdown_task; | 69 | static struct GNUNET_SCHEDULER_Task * shutdown_task; |
70 | 70 | ||
71 | #if VERBOSE | 71 | #if VERBOSE |
72 | #define OKPP do { ok++; FPRINTF (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0) | 72 | #define OKPP do { ok++; FPRINTF (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0) |
@@ -80,13 +80,13 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
80 | { | 80 | { |
81 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping\n"); | 81 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping\n"); |
82 | 82 | ||
83 | if (send_task != GNUNET_SCHEDULER_NO_TASK) | 83 | if (send_task != NULL) |
84 | GNUNET_SCHEDULER_cancel (send_task); | 84 | GNUNET_SCHEDULER_cancel (send_task); |
85 | 85 | ||
86 | if (die_task != GNUNET_SCHEDULER_NO_TASK) | 86 | if (die_task != NULL) |
87 | { | 87 | { |
88 | GNUNET_SCHEDULER_cancel (die_task); | 88 | GNUNET_SCHEDULER_cancel (die_task); |
89 | die_task = GNUNET_SCHEDULER_NO_TASK; | 89 | die_task = NULL; |
90 | } | 90 | } |
91 | 91 | ||
92 | if (cc != NULL) | 92 | if (cc != NULL) |
@@ -139,16 +139,16 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
139 | static void | 139 | static void |
140 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 140 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
141 | { | 141 | { |
142 | if (send_task != GNUNET_SCHEDULER_NO_TASK) | 142 | if (send_task != NULL) |
143 | { | 143 | { |
144 | GNUNET_SCHEDULER_cancel (send_task); | 144 | GNUNET_SCHEDULER_cancel (send_task); |
145 | send_task = GNUNET_SCHEDULER_NO_TASK; | 145 | send_task = NULL; |
146 | } | 146 | } |
147 | 147 | ||
148 | if (shutdown_task != GNUNET_SCHEDULER_NO_TASK) | 148 | if (shutdown_task != NULL) |
149 | { | 149 | { |
150 | GNUNET_SCHEDULER_cancel (shutdown_task); | 150 | GNUNET_SCHEDULER_cancel (shutdown_task); |
151 | shutdown_task = GNUNET_SCHEDULER_NO_TASK; | 151 | shutdown_task = NULL; |
152 | } | 152 | } |
153 | 153 | ||
154 | if (cc != NULL) | 154 | if (cc != NULL) |
@@ -225,10 +225,10 @@ notify_ready (void *cls, size_t size, void *buf) | |||
225 | { | 225 | { |
226 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 226 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
227 | "Timeout occurred while waiting for transmit_ready\n"); | 227 | "Timeout occurred while waiting for transmit_ready\n"); |
228 | if (GNUNET_SCHEDULER_NO_TASK != die_task) | 228 | if (NULL != die_task) |
229 | { | 229 | { |
230 | GNUNET_SCHEDULER_cancel (die_task); | 230 | GNUNET_SCHEDULER_cancel (die_task); |
231 | die_task = GNUNET_SCHEDULER_NO_TASK; | 231 | die_task = NULL; |
232 | } | 232 | } |
233 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); | 233 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); |
234 | ok = 42; | 234 | ok = 42; |
@@ -257,7 +257,7 @@ notify_ready (void *cls, size_t size, void *buf) | |||
257 | static void | 257 | static void |
258 | sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 258 | sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
259 | { | 259 | { |
260 | send_task = GNUNET_SCHEDULER_NO_TASK; | 260 | send_task = NULL; |
261 | 261 | ||
262 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | 262 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) |
263 | return; | 263 | return; |
@@ -359,7 +359,7 @@ blacklist_cb (void *cls, | |||
359 | res = GNUNET_SYSERR; | 359 | res = GNUNET_SYSERR; |
360 | } | 360 | } |
361 | 361 | ||
362 | if (((blacklist_request_p2 == GNUNET_YES) && (blacklist_request_p1 == GNUNET_YES)) && (shutdown_task == GNUNET_SCHEDULER_NO_TASK)) | 362 | if (((blacklist_request_p2 == GNUNET_YES) && (blacklist_request_p1 == GNUNET_YES)) && (shutdown_task == NULL)) |
363 | { | 363 | { |
364 | shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3), &end, NULL); | 364 | shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3), &end, NULL); |
365 | } | 365 | } |