diff options
Diffstat (limited to 'src/nse')
-rw-r--r-- | src/nse/gnunet-nse-profiler.c | 93 | ||||
-rw-r--r-- | src/nse/gnunet-nse.c | 4 | ||||
-rw-r--r-- | src/nse/gnunet-service-nse.c | 24 | ||||
-rw-r--r-- | src/nse/nse_api.c | 6 | ||||
-rw-r--r-- | src/nse/test_nse_multipeer.c | 3 |
5 files changed, 59 insertions, 71 deletions
diff --git a/src/nse/gnunet-nse-profiler.c b/src/nse/gnunet-nse-profiler.c index 5b893ae47..48afd9298 100644 --- a/src/nse/gnunet-nse-profiler.c +++ b/src/nse/gnunet-nse-profiler.c | |||
@@ -177,11 +177,6 @@ static struct GNUNET_TESTBED_Peer **daemons; | |||
177 | static struct GNUNET_CONFIGURATION_Handle *testing_cfg; | 177 | static struct GNUNET_CONFIGURATION_Handle *testing_cfg; |
178 | 178 | ||
179 | /** | 179 | /** |
180 | * The shutdown task | ||
181 | */ | ||
182 | static struct GNUNET_SCHEDULER_Task * shutdown_task_id; | ||
183 | |||
184 | /** | ||
185 | * Maximum number of connections to NSE services. | 180 | * Maximum number of connections to NSE services. |
186 | */ | 181 | */ |
187 | static unsigned int connection_limit; | 182 | static unsigned int connection_limit; |
@@ -228,9 +223,9 @@ static struct OpListEntry *oplist_head; | |||
228 | static struct OpListEntry *oplist_tail; | 223 | static struct OpListEntry *oplist_tail; |
229 | 224 | ||
230 | /** | 225 | /** |
231 | * Are we shutting down | 226 | * Task running each round of the experiment. |
232 | */ | 227 | */ |
233 | static int shutting_down; | 228 | static struct GNUNET_SCHEDULER_Task *round_task; |
234 | 229 | ||
235 | 230 | ||
236 | /** | 231 | /** |
@@ -269,12 +264,13 @@ close_monitor_connections () | |||
269 | static void | 264 | static void |
270 | shutdown_task (void *cls) | 265 | shutdown_task (void *cls) |
271 | { | 266 | { |
272 | shutdown_task_id = NULL; | ||
273 | if (GNUNET_YES == shutting_down) | ||
274 | return; | ||
275 | shutting_down = GNUNET_YES; | ||
276 | LOG_DEBUG ("Ending test.\n"); | 267 | LOG_DEBUG ("Ending test.\n"); |
277 | close_monitor_connections (); | 268 | close_monitor_connections (); |
269 | if (NULL != round_task) | ||
270 | { | ||
271 | GNUNET_SCHEDULER_cancel (round_task); | ||
272 | round_task = NULL; | ||
273 | } | ||
278 | if (NULL != data_file) | 274 | if (NULL != data_file) |
279 | { | 275 | { |
280 | GNUNET_DISK_file_close (data_file); | 276 | GNUNET_DISK_file_close (data_file); |
@@ -286,20 +282,10 @@ shutdown_task (void *cls) | |||
286 | output_file = NULL; | 282 | output_file = NULL; |
287 | } | 283 | } |
288 | if (NULL != testing_cfg) | 284 | if (NULL != testing_cfg) |
285 | { | ||
289 | GNUNET_CONFIGURATION_destroy (testing_cfg); | 286 | GNUNET_CONFIGURATION_destroy (testing_cfg); |
290 | testing_cfg = NULL; | 287 | testing_cfg = NULL; |
291 | } | 288 | } |
292 | |||
293 | |||
294 | /** | ||
295 | * Schedules shutdown task to be run now | ||
296 | */ | ||
297 | static void | ||
298 | shutdown_now () | ||
299 | { | ||
300 | if (NULL != shutdown_task_id) | ||
301 | GNUNET_SCHEDULER_cancel (shutdown_task_id); | ||
302 | shutdown_task_id = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | ||
303 | } | 289 | } |
304 | 290 | ||
305 | 291 | ||
@@ -556,14 +542,11 @@ next_round (void *cls); | |||
556 | static void | 542 | static void |
557 | finish_round (void *cls) | 543 | finish_round (void *cls) |
558 | { | 544 | { |
559 | const struct GNUNET_SCHEDULER_TaskContext *tc; | 545 | LOG (GNUNET_ERROR_TYPE_INFO, |
560 | 546 | "Have %u connections\n", | |
561 | tc = GNUNET_SCHEDULER_get_task_context (); | 547 | total_connections); |
562 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | ||
563 | return; | ||
564 | LOG (GNUNET_ERROR_TYPE_INFO, "Have %u connections\n", total_connections); | ||
565 | close_monitor_connections (); | 548 | close_monitor_connections (); |
566 | GNUNET_SCHEDULER_add_now (&next_round, NULL); | 549 | round_task = GNUNET_SCHEDULER_add_now (&next_round, NULL); |
567 | } | 550 | } |
568 | 551 | ||
569 | 552 | ||
@@ -575,7 +558,8 @@ finish_round (void *cls) | |||
575 | static void | 558 | static void |
576 | run_round () | 559 | run_round () |
577 | { | 560 | { |
578 | LOG_DEBUG ("Running round %u\n", current_round); | 561 | LOG_DEBUG ("Running round %u\n", |
562 | current_round); | ||
579 | connect_nse_service (); | 563 | connect_nse_service (); |
580 | GNUNET_SCHEDULER_add_delayed (wait_time, | 564 | GNUNET_SCHEDULER_add_delayed (wait_time, |
581 | &finish_round, | 565 | &finish_round, |
@@ -592,7 +576,9 @@ make_oplist_entry () | |||
592 | struct OpListEntry *entry; | 576 | struct OpListEntry *entry; |
593 | 577 | ||
594 | entry = GNUNET_new (struct OpListEntry); | 578 | entry = GNUNET_new (struct OpListEntry); |
595 | GNUNET_CONTAINER_DLL_insert_tail (oplist_head, oplist_tail, entry); | 579 | GNUNET_CONTAINER_DLL_insert_tail (oplist_head, |
580 | oplist_tail, | ||
581 | entry); | ||
596 | return entry; | 582 | return entry; |
597 | } | 583 | } |
598 | 584 | ||
@@ -605,7 +591,8 @@ make_oplist_entry () | |||
605 | * @param emsg NULL on success; otherwise an error description | 591 | * @param emsg NULL on success; otherwise an error description |
606 | */ | 592 | */ |
607 | static void | 593 | static void |
608 | manage_service_cb (void *cls, struct GNUNET_TESTBED_Operation *op, | 594 | manage_service_cb (void *cls, |
595 | struct GNUNET_TESTBED_Operation *op, | ||
609 | const char *emsg) | 596 | const char *emsg) |
610 | { | 597 | { |
611 | struct OpListEntry *entry = cls; | 598 | struct OpListEntry *entry = cls; |
@@ -619,7 +606,9 @@ manage_service_cb (void *cls, struct GNUNET_TESTBED_Operation *op, | |||
619 | } | 606 | } |
620 | GNUNET_assert (0 != entry->delta); | 607 | GNUNET_assert (0 != entry->delta); |
621 | peers_running += entry->delta; | 608 | peers_running += entry->delta; |
622 | GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry); | 609 | GNUNET_CONTAINER_DLL_remove (oplist_head, |
610 | oplist_tail, | ||
611 | entry); | ||
623 | GNUNET_free (entry); | 612 | GNUNET_free (entry); |
624 | if (num_peers_in_round[current_round] == peers_running) | 613 | if (num_peers_in_round[current_round] == peers_running) |
625 | run_round (); | 614 | run_round (); |
@@ -672,26 +661,22 @@ adjust_running_peers () | |||
672 | static void | 661 | static void |
673 | next_round (void *cls) | 662 | next_round (void *cls) |
674 | { | 663 | { |
675 | const struct GNUNET_SCHEDULER_TaskContext *tc; | 664 | round_task = NULL; |
676 | |||
677 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
678 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | ||
679 | return; | ||
680 | LOG_DEBUG ("Disconnecting nse service of peers\n"); | 665 | LOG_DEBUG ("Disconnecting nse service of peers\n"); |
681 | current_round++; | 666 | current_round++; |
682 | if (current_round == num_rounds) | 667 | if (current_round == num_rounds) |
683 | { | 668 | { |
684 | /* this was the last round, terminate */ | 669 | /* this was the last round, terminate */ |
685 | ok = 0; | 670 | ok = 0; |
686 | GNUNET_SCHEDULER_shutdown (); | 671 | GNUNET_SCHEDULER_shutdown (); |
687 | return; | 672 | return; |
688 | } | 673 | } |
689 | if (num_peers_in_round[current_round] == peers_running) | 674 | if (num_peers_in_round[current_round] == peers_running) |
690 | { | 675 | { |
691 | /* no need to churn, just run next round */ | 676 | /* no need to churn, just run next round */ |
692 | run_round (); | 677 | run_round (); |
693 | return; | 678 | return; |
694 | } | 679 | } |
695 | adjust_running_peers (); | 680 | adjust_running_peers (); |
696 | } | 681 | } |
697 | 682 | ||
@@ -744,7 +729,7 @@ test_master (void *cls, | |||
744 | { | 729 | { |
745 | if (NULL == peers) | 730 | if (NULL == peers) |
746 | { | 731 | { |
747 | shutdown_now (); | 732 | GNUNET_SCHEDULER_shutdown (); |
748 | return; | 733 | return; |
749 | } | 734 | } |
750 | daemons = peers; | 735 | daemons = peers; |
@@ -838,9 +823,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
838 | NULL, /* master_controller_cb cls */ | 823 | NULL, /* master_controller_cb cls */ |
839 | &test_master, | 824 | &test_master, |
840 | NULL); /* test_master cls */ | 825 | NULL); /* test_master cls */ |
841 | shutdown_task_id = | 826 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
842 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | ||
843 | &shutdown_task, NULL); | ||
844 | } | 827 | } |
845 | 828 | ||
846 | 829 | ||
diff --git a/src/nse/gnunet-nse.c b/src/nse/gnunet-nse.c index 97c3da29b..840b8e64d 100644 --- a/src/nse/gnunet-nse.c +++ b/src/nse/gnunet-nse.c | |||
@@ -143,8 +143,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
143 | GNUNET_TIME_UNIT_SECONDS, | 143 | GNUNET_TIME_UNIT_SECONDS, |
144 | nse_test_result, | 144 | nse_test_result, |
145 | NULL); | 145 | NULL); |
146 | shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 146 | shutdown_task = GNUNET_SCHEDULER_add_shutdown (&do_shutdown, |
147 | &do_shutdown, NULL); | 147 | NULL); |
148 | } | 148 | } |
149 | 149 | ||
150 | 150 | ||
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c index 608274ae1..d4098d1bc 100644 --- a/src/nse/gnunet-service-nse.c +++ b/src/nse/gnunet-service-nse.c | |||
@@ -784,7 +784,9 @@ schedule_current_round (void *cls, | |||
784 | delay = | 784 | delay = |
785 | get_transmit_delay ((peer_entry->previous_round == GNUNET_NO) ? -1 : 0); | 785 | get_transmit_delay ((peer_entry->previous_round == GNUNET_NO) ? -1 : 0); |
786 | peer_entry->transmit_task = | 786 | peer_entry->transmit_task = |
787 | GNUNET_SCHEDULER_add_delayed (delay, &transmit_task_cb, peer_entry); | 787 | GNUNET_SCHEDULER_add_delayed (delay, |
788 | &transmit_task_cb, | ||
789 | peer_entry); | ||
788 | return GNUNET_OK; | 790 | return GNUNET_OK; |
789 | } | 791 | } |
790 | 792 | ||
@@ -799,18 +801,15 @@ update_flood_message (void *cls) | |||
799 | { | 801 | { |
800 | struct GNUNET_TIME_Relative offset; | 802 | struct GNUNET_TIME_Relative offset; |
801 | unsigned int i; | 803 | unsigned int i; |
802 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
803 | 804 | ||
804 | flood_task = NULL; | 805 | flood_task = NULL; |
805 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
806 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
807 | return; | ||
808 | offset = GNUNET_TIME_absolute_get_remaining (next_timestamp); | 806 | offset = GNUNET_TIME_absolute_get_remaining (next_timestamp); |
809 | if (0 != offset.rel_value_us) | 807 | if (0 != offset.rel_value_us) |
810 | { | 808 | { |
811 | /* somehow run early, delay more */ | 809 | /* somehow run early, delay more */ |
812 | flood_task = | 810 | flood_task = |
813 | GNUNET_SCHEDULER_add_delayed (offset, &update_flood_message, NULL); | 811 | GNUNET_SCHEDULER_add_delayed (offset, |
812 | &update_flood_message, NULL); | ||
814 | return; | 813 | return; |
815 | } | 814 | } |
816 | estimate_index = (estimate_index + 1) % HISTORY_SIZE; | 815 | estimate_index = (estimate_index + 1) % HISTORY_SIZE; |
@@ -841,7 +840,8 @@ update_flood_message (void *cls) | |||
841 | NULL); | 840 | NULL); |
842 | flood_task = | 841 | flood_task = |
843 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining | 842 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining |
844 | (next_timestamp), &update_flood_message, | 843 | (next_timestamp), |
844 | &update_flood_message, | ||
845 | NULL); | 845 | NULL); |
846 | } | 846 | } |
847 | 847 | ||
@@ -1043,7 +1043,8 @@ update_flood_times (void *cls, | |||
1043 | } | 1043 | } |
1044 | delay = get_transmit_delay (0); | 1044 | delay = get_transmit_delay (0); |
1045 | peer_entry->transmit_task = | 1045 | peer_entry->transmit_task = |
1046 | GNUNET_SCHEDULER_add_delayed (delay, &transmit_task_cb, peer_entry); | 1046 | GNUNET_SCHEDULER_add_delayed (delay, |
1047 | &transmit_task_cb, peer_entry); | ||
1047 | return GNUNET_OK; | 1048 | return GNUNET_OK; |
1048 | } | 1049 | } |
1049 | 1050 | ||
@@ -1439,7 +1440,8 @@ core_init (void *cls, | |||
1439 | } | 1440 | } |
1440 | flood_task = | 1441 | flood_task = |
1441 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining | 1442 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining |
1442 | (next_timestamp), &update_flood_message, | 1443 | (next_timestamp), |
1444 | &update_flood_message, | ||
1443 | NULL); | 1445 | NULL); |
1444 | } | 1446 | } |
1445 | 1447 | ||
@@ -1560,8 +1562,8 @@ run (void *cls, | |||
1560 | } | 1562 | } |
1561 | #endif | 1563 | #endif |
1562 | 1564 | ||
1563 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 1565 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
1564 | NULL); | 1566 | NULL); |
1565 | pk = GNUNET_CRYPTO_eddsa_key_create_from_configuration (cfg); | 1567 | pk = GNUNET_CRYPTO_eddsa_key_create_from_configuration (cfg); |
1566 | GNUNET_assert (NULL != pk); | 1568 | GNUNET_assert (NULL != pk); |
1567 | my_private_key = pk; | 1569 | my_private_key = pk; |
diff --git a/src/nse/nse_api.c b/src/nse/nse_api.c index a42dcb369..1c260d537 100644 --- a/src/nse/nse_api.c +++ b/src/nse/nse_api.c | |||
@@ -94,7 +94,8 @@ reconnect (void *cls); | |||
94 | * @param msg message received, NULL on timeout or fatal error | 94 | * @param msg message received, NULL on timeout or fatal error |
95 | */ | 95 | */ |
96 | static void | 96 | static void |
97 | message_handler (void *cls, const struct GNUNET_MessageHeader *msg) | 97 | message_handler (void *cls, |
98 | const struct GNUNET_MessageHeader *msg) | ||
98 | { | 99 | { |
99 | struct GNUNET_NSE_Handle *h = cls; | 100 | struct GNUNET_NSE_Handle *h = cls; |
100 | const struct GNUNET_NSE_ClientMessage *client_msg; | 101 | const struct GNUNET_NSE_ClientMessage *client_msg; |
@@ -150,7 +151,8 @@ reschedule_connect (struct GNUNET_NSE_Handle *h) | |||
150 | GNUNET_STRINGS_relative_time_to_string (h->reconnect_delay, | 151 | GNUNET_STRINGS_relative_time_to_string (h->reconnect_delay, |
151 | GNUNET_YES)); | 152 | GNUNET_YES)); |
152 | h->reconnect_task = | 153 | h->reconnect_task = |
153 | GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h); | 154 | GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, |
155 | &reconnect, h); | ||
154 | h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay); | 156 | h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay); |
155 | } | 157 | } |
156 | 158 | ||
diff --git a/src/nse/test_nse_multipeer.c b/src/nse/test_nse_multipeer.c index 5e6c31e6c..d6d63778e 100644 --- a/src/nse/test_nse_multipeer.c +++ b/src/nse/test_nse_multipeer.c | |||
@@ -207,7 +207,8 @@ run (void *cls, | |||
207 | &nse_connect_adapter, | 207 | &nse_connect_adapter, |
208 | &nse_disconnect_adapter, | 208 | &nse_disconnect_adapter, |
209 | &nse_peers[i]); | 209 | &nse_peers[i]); |
210 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &shutdown_task, NULL); | 210 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
211 | &shutdown_task, NULL); | ||
211 | } | 212 | } |
212 | 213 | ||
213 | 214 | ||