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/cadet/gnunet-cadet-profiler.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/cadet/gnunet-cadet-profiler.c')
-rw-r--r-- | src/cadet/gnunet-cadet-profiler.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/cadet/gnunet-cadet-profiler.c b/src/cadet/gnunet-cadet-profiler.c index c944caa75..2cfbfdaa4 100644 --- a/src/cadet/gnunet-cadet-profiler.c +++ b/src/cadet/gnunet-cadet-profiler.c | |||
@@ -147,7 +147,7 @@ struct CadetPeer | |||
147 | /** | 147 | /** |
148 | * Task to do the next ping. | 148 | * Task to do the next ping. |
149 | */ | 149 | */ |
150 | GNUNET_SCHEDULER_TaskIdentifier ping_task; | 150 | struct GNUNET_SCHEDULER_Task * ping_task; |
151 | 151 | ||
152 | float mean[number_rounds]; | 152 | float mean[number_rounds]; |
153 | float var[number_rounds]; | 153 | float var[number_rounds]; |
@@ -209,17 +209,17 @@ static struct GNUNET_CADET_TEST_Context *test_ctx; | |||
209 | /** | 209 | /** |
210 | * Task called to shutdown test. | 210 | * Task called to shutdown test. |
211 | */ | 211 | */ |
212 | static GNUNET_SCHEDULER_TaskIdentifier shutdown_handle; | 212 | static struct GNUNET_SCHEDULER_Task * shutdown_handle; |
213 | 213 | ||
214 | /** | 214 | /** |
215 | * Task called to disconnect peers, before shutdown. | 215 | * Task called to disconnect peers, before shutdown. |
216 | */ | 216 | */ |
217 | static GNUNET_SCHEDULER_TaskIdentifier disconnect_task; | 217 | static struct GNUNET_SCHEDULER_Task * disconnect_task; |
218 | 218 | ||
219 | /** | 219 | /** |
220 | * Task to perform tests | 220 | * Task to perform tests |
221 | */ | 221 | */ |
222 | static GNUNET_SCHEDULER_TaskIdentifier test_task; | 222 | static struct GNUNET_SCHEDULER_Task * test_task; |
223 | 223 | ||
224 | /** | 224 | /** |
225 | * Round number. | 225 | * Round number. |
@@ -320,7 +320,7 @@ static void | |||
320 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 320 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
321 | { | 321 | { |
322 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Ending test.\n"); | 322 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Ending test.\n"); |
323 | shutdown_handle = GNUNET_SCHEDULER_NO_TASK; | 323 | shutdown_handle = NULL; |
324 | } | 324 | } |
325 | 325 | ||
326 | 326 | ||
@@ -338,7 +338,7 @@ disconnect_cadet_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc | |||
338 | 338 | ||
339 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 339 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
340 | "disconnecting cadet service, called from line %ld\n", line); | 340 | "disconnecting cadet service, called from line %ld\n", line); |
341 | disconnect_task = GNUNET_SCHEDULER_NO_TASK; | 341 | disconnect_task = NULL; |
342 | for (i = 0; i < peers_total; i++) | 342 | for (i = 0; i < peers_total; i++) |
343 | { | 343 | { |
344 | if (NULL != peers[i].op) | 344 | if (NULL != peers[i].op) |
@@ -366,7 +366,7 @@ disconnect_cadet_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc | |||
366 | } | 366 | } |
367 | } | 367 | } |
368 | GNUNET_CADET_TEST_cleanup (test_ctx); | 368 | GNUNET_CADET_TEST_cleanup (test_ctx); |
369 | if (GNUNET_SCHEDULER_NO_TASK != shutdown_handle) | 369 | if (NULL != shutdown_handle) |
370 | { | 370 | { |
371 | GNUNET_SCHEDULER_cancel (shutdown_handle); | 371 | GNUNET_SCHEDULER_cancel (shutdown_handle); |
372 | } | 372 | } |
@@ -382,7 +382,7 @@ disconnect_cadet_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc | |||
382 | static void | 382 | static void |
383 | abort_test (long line) | 383 | abort_test (long line) |
384 | { | 384 | { |
385 | if (disconnect_task != GNUNET_SCHEDULER_NO_TASK) | 385 | if (disconnect_task != NULL) |
386 | { | 386 | { |
387 | GNUNET_SCHEDULER_cancel (disconnect_task); | 387 | GNUNET_SCHEDULER_cancel (disconnect_task); |
388 | disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers, | 388 | disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers, |
@@ -405,7 +405,7 @@ stats_cont (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg) | |||
405 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "... collecting statistics done.\n"); | 405 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "... collecting statistics done.\n"); |
406 | GNUNET_TESTBED_operation_done (stats_op); | 406 | GNUNET_TESTBED_operation_done (stats_op); |
407 | 407 | ||
408 | if (GNUNET_SCHEDULER_NO_TASK != disconnect_task) | 408 | if (NULL != disconnect_task) |
409 | GNUNET_SCHEDULER_cancel (disconnect_task); | 409 | GNUNET_SCHEDULER_cancel (disconnect_task); |
410 | disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers, | 410 | disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers, |
411 | (void *) __LINE__); | 411 | (void *) __LINE__); |
@@ -513,9 +513,9 @@ adjust_running_peers (unsigned int target) | |||
513 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "St%s peer %u: %s\n", | 513 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "St%s peer %u: %s\n", |
514 | run ? "arting" : "opping", r, GNUNET_i2s (&peers[r].id)); | 514 | run ? "arting" : "opping", r, GNUNET_i2s (&peers[r].id)); |
515 | 515 | ||
516 | if (GNUNET_SCHEDULER_NO_TASK != peers[r].ping_task) | 516 | if (NULL != peers[r].ping_task) |
517 | GNUNET_SCHEDULER_cancel (peers[r].ping_task); | 517 | GNUNET_SCHEDULER_cancel (peers[r].ping_task); |
518 | peers[r].ping_task = GNUNET_SCHEDULER_NO_TASK; | 518 | peers[r].ping_task = NULL; |
519 | 519 | ||
520 | peers[r].up = run; | 520 | peers[r].up = run; |
521 | 521 | ||
@@ -615,7 +615,7 @@ ping (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
615 | { | 615 | { |
616 | struct CadetPeer *peer = (struct CadetPeer *) cls; | 616 | struct CadetPeer *peer = (struct CadetPeer *) cls; |
617 | 617 | ||
618 | peer->ping_task = GNUNET_SCHEDULER_NO_TASK; | 618 | peer->ping_task = NULL; |
619 | 619 | ||
620 | if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0 | 620 | if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0 |
621 | || GNUNET_YES == test_finished) | 621 | || GNUNET_YES == test_finished) |
@@ -797,7 +797,7 @@ incoming_channel (void *cls, struct GNUNET_CADET_Channel *channel, | |||
797 | peers_warmup++; | 797 | peers_warmup++; |
798 | if (peers_warmup < peers_total) | 798 | if (peers_warmup < peers_total) |
799 | return NULL; | 799 | return NULL; |
800 | if (GNUNET_SCHEDULER_NO_TASK != test_task) | 800 | if (NULL != test_task) |
801 | { | 801 | { |
802 | GNUNET_SCHEDULER_cancel (test_task); | 802 | GNUNET_SCHEDULER_cancel (test_task); |
803 | test_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 803 | test_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
@@ -873,7 +873,7 @@ start_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
873 | enum GNUNET_CADET_ChannelOption flags; | 873 | enum GNUNET_CADET_ChannelOption flags; |
874 | unsigned long i; | 874 | unsigned long i; |
875 | 875 | ||
876 | test_task = GNUNET_SCHEDULER_NO_TASK; | 876 | test_task = NULL; |
877 | if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0) | 877 | if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0) |
878 | return; | 878 | return; |
879 | 879 | ||
@@ -898,7 +898,7 @@ start_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
898 | &ping, &peers[i]); | 898 | &ping, &peers[i]); |
899 | } | 899 | } |
900 | peers_running = peers_total; | 900 | peers_running = peers_total; |
901 | if (GNUNET_SCHEDULER_NO_TASK != disconnect_task) | 901 | if (NULL != disconnect_task) |
902 | GNUNET_SCHEDULER_cancel (disconnect_task); | 902 | GNUNET_SCHEDULER_cancel (disconnect_task); |
903 | disconnect_task = | 903 | disconnect_task = |
904 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(round_time, | 904 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(round_time, |