diff options
Diffstat (limited to 'src')
233 files changed, 3082 insertions, 2939 deletions
diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c index c708f9150..5fb2a811a 100644 --- a/src/arm/arm_api.c +++ b/src/arm/arm_api.c | |||
@@ -241,7 +241,9 @@ reconnect_arm_later (struct GNUNET_ARM_Handle *h) | |||
241 | h->currently_down = GNUNET_YES; | 241 | h->currently_down = GNUNET_YES; |
242 | GNUNET_assert (NULL == h->reconnect_task); | 242 | GNUNET_assert (NULL == h->reconnect_task); |
243 | h->reconnect_task = | 243 | h->reconnect_task = |
244 | GNUNET_SCHEDULER_add_delayed (h->retry_backoff, &reconnect_arm_task, h); | 244 | GNUNET_SCHEDULER_add_delayed (h->retry_backoff, |
245 | &reconnect_arm_task, | ||
246 | h); | ||
245 | /* Don't clear pending messages on disconnection, deliver them later | 247 | /* Don't clear pending messages on disconnection, deliver them later |
246 | clear_pending_messages (h, GNUNET_ARM_REQUEST_DISCONNECTED); | 248 | clear_pending_messages (h, GNUNET_ARM_REQUEST_DISCONNECTED); |
247 | GNUNET_assert (NULL == h->control_pending_head); | 249 | GNUNET_assert (NULL == h->control_pending_head); |
@@ -635,7 +637,8 @@ reconnect_arm (struct GNUNET_ARM_Handle *h) | |||
635 | */ | 637 | */ |
636 | struct GNUNET_ARM_Handle * | 638 | struct GNUNET_ARM_Handle * |
637 | GNUNET_ARM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | 639 | GNUNET_ARM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, |
638 | GNUNET_ARM_ConnectionStatusCallback conn_status, void *cls) | 640 | GNUNET_ARM_ConnectionStatusCallback conn_status, |
641 | void *cls) | ||
639 | { | 642 | { |
640 | struct GNUNET_ARM_Handle *h; | 643 | struct GNUNET_ARM_Handle *h; |
641 | 644 | ||
@@ -942,7 +945,8 @@ change_service (struct GNUNET_ARM_Handle *h, const char *service_name, | |||
942 | h->control_pending_tail, cm); | 945 | h->control_pending_tail, cm); |
943 | cm->timeout_task_id = | 946 | cm->timeout_task_id = |
944 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining | 947 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining |
945 | (cm->timeout), &control_message_timeout, cm); | 948 | (cm->timeout), |
949 | &control_message_timeout, cm); | ||
946 | trigger_next_request (h, GNUNET_NO); | 950 | trigger_next_request (h, GNUNET_NO); |
947 | } | 951 | } |
948 | 952 | ||
@@ -1106,7 +1110,8 @@ GNUNET_ARM_request_service_list (struct GNUNET_ARM_Handle *h, | |||
1106 | h->control_pending_tail, cm); | 1110 | h->control_pending_tail, cm); |
1107 | cm->timeout_task_id = | 1111 | cm->timeout_task_id = |
1108 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining | 1112 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining |
1109 | (cm->timeout), &control_message_timeout, cm); | 1113 | (cm->timeout), |
1114 | &control_message_timeout, cm); | ||
1110 | trigger_next_request (h, GNUNET_NO); | 1115 | trigger_next_request (h, GNUNET_NO); |
1111 | } | 1116 | } |
1112 | 1117 | ||
diff --git a/src/arm/gnunet-arm.c b/src/arm/gnunet-arm.c index af85372d8..4501ed036 100644 --- a/src/arm/gnunet-arm.c +++ b/src/arm/gnunet-arm.c | |||
@@ -145,6 +145,11 @@ static unsigned int no_stdout; | |||
145 | */ | 145 | */ |
146 | static unsigned int no_stderr; | 146 | static unsigned int no_stderr; |
147 | 147 | ||
148 | /** | ||
149 | * Handle for the task running the #action_loop(). | ||
150 | */ | ||
151 | static struct GNUNET_SCHEDULER_Task *al_task; | ||
152 | |||
148 | 153 | ||
149 | /** | 154 | /** |
150 | * Attempts to delete configuration file and GNUNET_HOME | 155 | * Attempts to delete configuration file and GNUNET_HOME |
@@ -183,6 +188,11 @@ delete_files () | |||
183 | static void | 188 | static void |
184 | shutdown_task (void *cls) | 189 | shutdown_task (void *cls) |
185 | { | 190 | { |
191 | if (NULL != al_task) | ||
192 | { | ||
193 | GNUNET_SCHEDULER_cancel (al_task); | ||
194 | al_task = NULL; | ||
195 | } | ||
186 | if (NULL != h) | 196 | if (NULL != h) |
187 | { | 197 | { |
188 | GNUNET_ARM_disconnect_and_free (h); | 198 | GNUNET_ARM_disconnect_and_free (h); |
@@ -314,7 +324,8 @@ conn_status (void *cls, | |||
314 | */ | 324 | */ |
315 | static void | 325 | static void |
316 | start_callback (void *cls, | 326 | start_callback (void *cls, |
317 | enum GNUNET_ARM_RequestStatus rs, const char *service, | 327 | enum GNUNET_ARM_RequestStatus rs, |
328 | const char *service, | ||
318 | enum GNUNET_ARM_Result result) | 329 | enum GNUNET_ARM_Result result) |
319 | { | 330 | { |
320 | char *msg; | 331 | char *msg; |
@@ -336,9 +347,10 @@ start_callback (void *cls, | |||
336 | GNUNET_SCHEDULER_shutdown (); | 347 | GNUNET_SCHEDULER_shutdown (); |
337 | return; | 348 | return; |
338 | } | 349 | } |
339 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM service [re]start successful\n"); | 350 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
351 | "ARM service [re]start successful\n"); | ||
340 | start = 0; | 352 | start = 0; |
341 | GNUNET_SCHEDULER_add_now (action_loop, NULL); | 353 | al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL); |
342 | } | 354 | } |
343 | 355 | ||
344 | 356 | ||
@@ -356,7 +368,8 @@ start_callback (void *cls, | |||
356 | */ | 368 | */ |
357 | static void | 369 | static void |
358 | stop_callback (void *cls, | 370 | stop_callback (void *cls, |
359 | enum GNUNET_ARM_RequestStatus rs, const char *service, | 371 | enum GNUNET_ARM_RequestStatus rs, |
372 | const char *service, | ||
360 | enum GNUNET_ARM_Result result) | 373 | enum GNUNET_ARM_Result result) |
361 | { | 374 | { |
362 | char *msg; | 375 | char *msg; |
@@ -374,7 +387,8 @@ stop_callback (void *cls, | |||
374 | (GNUNET_ARM_RESULT_STOPPED != result) && | 387 | (GNUNET_ARM_RESULT_STOPPED != result) && |
375 | (GNUNET_ARM_RESULT_IS_STOPPED_ALREADY != result)) | 388 | (GNUNET_ARM_RESULT_IS_STOPPED_ALREADY != result)) |
376 | { | 389 | { |
377 | GNUNET_asprintf (&msg, "%s", _("Failed to stop the ARM service: %s\n")); | 390 | GNUNET_asprintf (&msg, "%s", |
391 | _("Failed to stop the ARM service: %s\n")); | ||
378 | FPRINTF (stdout, msg, ret_string (result)); | 392 | FPRINTF (stdout, msg, ret_string (result)); |
379 | GNUNET_free (msg); | 393 | GNUNET_free (msg); |
380 | GNUNET_SCHEDULER_shutdown (); | 394 | GNUNET_SCHEDULER_shutdown (); |
@@ -390,7 +404,7 @@ stop_callback (void *cls, | |||
390 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 404 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
391 | "Initiating an ARM restart\n"); | 405 | "Initiating an ARM restart\n"); |
392 | } | 406 | } |
393 | GNUNET_SCHEDULER_add_now (&action_loop, NULL); | 407 | al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL); |
394 | } | 408 | } |
395 | 409 | ||
396 | 410 | ||
@@ -408,7 +422,8 @@ stop_callback (void *cls, | |||
408 | */ | 422 | */ |
409 | static void | 423 | static void |
410 | init_callback (void *cls, | 424 | init_callback (void *cls, |
411 | enum GNUNET_ARM_RequestStatus rs, const char *service, | 425 | enum GNUNET_ARM_RequestStatus rs, |
426 | const char *service, | ||
412 | enum GNUNET_ARM_Result result) | 427 | enum GNUNET_ARM_Result result) |
413 | { | 428 | { |
414 | char *msg; | 429 | char *msg; |
@@ -438,7 +453,7 @@ init_callback (void *cls, | |||
438 | init); | 453 | init); |
439 | GNUNET_free (init); | 454 | GNUNET_free (init); |
440 | init = NULL; | 455 | init = NULL; |
441 | GNUNET_SCHEDULER_add_now (&action_loop, NULL); | 456 | al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL); |
442 | } | 457 | } |
443 | 458 | ||
444 | 459 | ||
@@ -456,7 +471,8 @@ init_callback (void *cls, | |||
456 | */ | 471 | */ |
457 | static void | 472 | static void |
458 | term_callback (void *cls, | 473 | term_callback (void *cls, |
459 | enum GNUNET_ARM_RequestStatus rs, const char *service, | 474 | enum GNUNET_ARM_RequestStatus rs, |
475 | const char *service, | ||
460 | enum GNUNET_ARM_Result result) | 476 | enum GNUNET_ARM_Result result) |
461 | { | 477 | { |
462 | char *msg; | 478 | char *msg; |
@@ -487,7 +503,7 @@ term_callback (void *cls, | |||
487 | term); | 503 | term); |
488 | GNUNET_free (term); | 504 | GNUNET_free (term); |
489 | term = NULL; | 505 | term = NULL; |
490 | GNUNET_SCHEDULER_add_now (&action_loop, NULL); | 506 | al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL); |
491 | } | 507 | } |
492 | 508 | ||
493 | 509 | ||
@@ -503,7 +519,8 @@ term_callback (void *cls, | |||
503 | */ | 519 | */ |
504 | static void | 520 | static void |
505 | list_callback (void *cls, | 521 | list_callback (void *cls, |
506 | enum GNUNET_ARM_RequestStatus rs, unsigned int count, | 522 | enum GNUNET_ARM_RequestStatus rs, |
523 | unsigned int count, | ||
507 | const char *const*list) | 524 | const char *const*list) |
508 | { | 525 | { |
509 | unsigned int i; | 526 | unsigned int i; |
@@ -512,7 +529,8 @@ list_callback (void *cls, | |||
512 | { | 529 | { |
513 | char *msg; | 530 | char *msg; |
514 | 531 | ||
515 | GNUNET_asprintf (&msg, "%s", _("Failed to request a list of services: %s\n")); | 532 | GNUNET_asprintf (&msg, "%s", |
533 | _("Failed to request a list of services: %s\n")); | ||
516 | FPRINTF (stdout, msg, req_string (rs)); | 534 | FPRINTF (stdout, msg, req_string (rs)); |
517 | GNUNET_free (msg); | 535 | GNUNET_free (msg); |
518 | ret = 3; | 536 | ret = 3; |
@@ -520,7 +538,8 @@ list_callback (void *cls, | |||
520 | } | 538 | } |
521 | if (NULL == list) | 539 | if (NULL == list) |
522 | { | 540 | { |
523 | FPRINTF (stderr, "%s", _("Error communicating with ARM. ARM not running?\n")); | 541 | FPRINTF (stderr, "%s", |
542 | _("Error communicating with ARM. ARM not running?\n")); | ||
524 | GNUNET_SCHEDULER_shutdown (); | 543 | GNUNET_SCHEDULER_shutdown (); |
525 | ret = 3; | 544 | ret = 3; |
526 | return; | 545 | return; |
@@ -528,7 +547,7 @@ list_callback (void *cls, | |||
528 | FPRINTF (stdout, "%s", _("Running services:\n")); | 547 | FPRINTF (stdout, "%s", _("Running services:\n")); |
529 | for (i = 0; i < count; i++) | 548 | for (i = 0; i < count; i++) |
530 | FPRINTF (stdout, "%s\n", list[i]); | 549 | FPRINTF (stdout, "%s\n", list[i]); |
531 | GNUNET_SCHEDULER_add_now (&action_loop, NULL); | 550 | al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL); |
532 | } | 551 | } |
533 | 552 | ||
534 | 553 | ||
@@ -541,12 +560,9 @@ list_callback (void *cls, | |||
541 | static void | 560 | static void |
542 | action_loop (void *cls) | 561 | action_loop (void *cls) |
543 | { | 562 | { |
544 | const struct GNUNET_SCHEDULER_TaskContext *tc; | 563 | al_task = NULL; |
545 | 564 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |
546 | tc = GNUNET_SCHEDULER_get_task_context (); | 565 | "Running requested actions\n"); |
547 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
548 | return; | ||
549 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Running requested actions\n"); | ||
550 | while (1) | 566 | while (1) |
551 | { | 567 | { |
552 | switch (phase++) | 568 | switch (phase++) |
@@ -554,7 +570,8 @@ action_loop (void *cls) | |||
554 | case 0: | 570 | case 0: |
555 | if (NULL != term) | 571 | if (NULL != term) |
556 | { | 572 | { |
557 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Termination action\n"); | 573 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
574 | "Termination action\n"); | ||
558 | GNUNET_ARM_request_service_stop (h, term, | 575 | GNUNET_ARM_request_service_stop (h, term, |
559 | (0 == timeout.rel_value_us) ? STOP_TIMEOUT : timeout, | 576 | (0 == timeout.rel_value_us) ? STOP_TIMEOUT : timeout, |
560 | &term_callback, NULL); | 577 | &term_callback, NULL); |
@@ -564,7 +581,8 @@ action_loop (void *cls) | |||
564 | case 1: | 581 | case 1: |
565 | if (end || restart) | 582 | if (end || restart) |
566 | { | 583 | { |
567 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "End action\n"); | 584 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
585 | "End action\n"); | ||
568 | GNUNET_ARM_request_service_stop (h, "arm", | 586 | GNUNET_ARM_request_service_stop (h, "arm", |
569 | (0 == timeout.rel_value_us) ? STOP_TIMEOUT_ARM : timeout, | 587 | (0 == timeout.rel_value_us) ? STOP_TIMEOUT_ARM : timeout, |
570 | &stop_callback, NULL); | 588 | &stop_callback, NULL); |
@@ -574,7 +592,8 @@ action_loop (void *cls) | |||
574 | case 2: | 592 | case 2: |
575 | if (start) | 593 | if (start) |
576 | { | 594 | { |
577 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start action\n"); | 595 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
596 | "Start action\n"); | ||
578 | GNUNET_ARM_request_service_start (h, "arm", | 597 | GNUNET_ARM_request_service_start (h, "arm", |
579 | (no_stdout ? 0 : GNUNET_OS_INHERIT_STD_OUT) | | 598 | (no_stdout ? 0 : GNUNET_OS_INHERIT_STD_OUT) | |
580 | (no_stderr ? 0 : GNUNET_OS_INHERIT_STD_ERR), | 599 | (no_stderr ? 0 : GNUNET_OS_INHERIT_STD_ERR), |
@@ -586,8 +605,10 @@ action_loop (void *cls) | |||
586 | case 3: | 605 | case 3: |
587 | if (NULL != init) | 606 | if (NULL != init) |
588 | { | 607 | { |
589 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initialization action\n"); | 608 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
590 | GNUNET_ARM_request_service_start (h, init, GNUNET_OS_INHERIT_STD_NONE, | 609 | "Initialization action\n"); |
610 | GNUNET_ARM_request_service_start (h, init, | ||
611 | GNUNET_OS_INHERIT_STD_NONE, | ||
591 | (0 == timeout.rel_value_us) ? STOP_TIMEOUT : timeout, | 612 | (0 == timeout.rel_value_us) ? STOP_TIMEOUT : timeout, |
592 | &init_callback, NULL); | 613 | &init_callback, NULL); |
593 | return; | 614 | return; |
@@ -631,7 +652,8 @@ action_loop (void *cls) | |||
631 | */ | 652 | */ |
632 | static void | 653 | static void |
633 | srv_status (void *cls, | 654 | srv_status (void *cls, |
634 | const char *service, enum GNUNET_ARM_ServiceStatus status) | 655 | const char *service, |
656 | enum GNUNET_ARM_ServiceStatus status) | ||
635 | { | 657 | { |
636 | const char *msg; | 658 | const char *msg; |
637 | 659 | ||
@@ -704,9 +726,8 @@ run (void *cls, | |||
704 | return; | 726 | return; |
705 | if (monitor) | 727 | if (monitor) |
706 | m = GNUNET_ARM_monitor (cfg, &srv_status, NULL); | 728 | m = GNUNET_ARM_monitor (cfg, &srv_status, NULL); |
707 | GNUNET_SCHEDULER_add_now (&action_loop, NULL); | 729 | al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL); |
708 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 730 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
709 | &shutdown_task, NULL); | ||
710 | } | 731 | } |
711 | 732 | ||
712 | 733 | ||
diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c index 9feb6e9c1..152a358fc 100644 --- a/src/arm/gnunet-service-arm.c +++ b/src/arm/gnunet-service-arm.c | |||
@@ -610,13 +610,9 @@ accept_connection (void *cls) | |||
610 | { | 610 | { |
611 | struct ServiceListeningInfo *sli = cls; | 611 | struct ServiceListeningInfo *sli = cls; |
612 | struct ServiceList *sl = sli->sl; | 612 | struct ServiceList *sl = sli->sl; |
613 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
614 | 613 | ||
615 | sli->accept_task = NULL; | 614 | sli->accept_task = NULL; |
616 | GNUNET_assert (GNUNET_NO == in_shutdown); | 615 | GNUNET_assert (GNUNET_NO == in_shutdown); |
617 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
618 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | ||
619 | return; | ||
620 | start_process (sl, NULL, 0); | 616 | start_process (sl, NULL, 0); |
621 | } | 617 | } |
622 | 618 | ||
@@ -734,7 +730,9 @@ create_listen_socket (struct sockaddr *sa, | |||
734 | sli->accept_task = | 730 | sli->accept_task = |
735 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, sock, | 731 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, sock, |
736 | &accept_connection, sli); | 732 | &accept_connection, sli); |
737 | GNUNET_CONTAINER_DLL_insert (sl->listen_head, sl->listen_tail, sli); | 733 | GNUNET_CONTAINER_DLL_insert (sl->listen_head, |
734 | sl->listen_tail, | ||
735 | sli); | ||
738 | } | 736 | } |
739 | 737 | ||
740 | 738 | ||
@@ -866,17 +864,24 @@ handle_stop (void *cls, | |||
866 | servicename); | 864 | servicename); |
867 | if (0 == strcasecmp (servicename, "arm")) | 865 | if (0 == strcasecmp (servicename, "arm")) |
868 | { | 866 | { |
869 | broadcast_status (servicename, GNUNET_ARM_SERVICE_STOPPING, NULL); | 867 | broadcast_status (servicename, |
870 | signal_result (client, servicename, request_id, GNUNET_ARM_RESULT_STOPPING); | 868 | GNUNET_ARM_SERVICE_STOPPING, NULL); |
869 | signal_result (client, | ||
870 | servicename, | ||
871 | request_id, | ||
872 | GNUNET_ARM_RESULT_STOPPING); | ||
871 | GNUNET_SERVER_client_persist_ (client); | 873 | GNUNET_SERVER_client_persist_ (client); |
872 | GNUNET_SCHEDULER_add_now (trigger_shutdown, NULL); | 874 | GNUNET_SCHEDULER_add_now (&trigger_shutdown, NULL); |
873 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 875 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
874 | return; | 876 | return; |
875 | } | 877 | } |
876 | sl = find_service (servicename); | 878 | sl = find_service (servicename); |
877 | if (sl == NULL) | 879 | if (sl == NULL) |
878 | { | 880 | { |
879 | signal_result (client, servicename, request_id, GNUNET_ARM_RESULT_IS_NOT_KNOWN); | 881 | signal_result (client, |
882 | servicename, | ||
883 | request_id, | ||
884 | GNUNET_ARM_RESULT_IS_NOT_KNOWN); | ||
880 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 885 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
881 | return; | 886 | return; |
882 | } | 887 | } |
@@ -884,14 +889,19 @@ handle_stop (void *cls, | |||
884 | if (GNUNET_YES == in_shutdown) | 889 | if (GNUNET_YES == in_shutdown) |
885 | { | 890 | { |
886 | /* shutdown in progress */ | 891 | /* shutdown in progress */ |
887 | signal_result (client, servicename, request_id, GNUNET_ARM_RESULT_IN_SHUTDOWN); | 892 | signal_result (client, |
893 | servicename, | ||
894 | request_id, | ||
895 | GNUNET_ARM_RESULT_IN_SHUTDOWN); | ||
888 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 896 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
889 | return; | 897 | return; |
890 | } | 898 | } |
891 | if (NULL != sl->killing_client) | 899 | if (NULL != sl->killing_client) |
892 | { | 900 | { |
893 | /* killing already in progress */ | 901 | /* killing already in progress */ |
894 | signal_result (client, servicename, request_id, | 902 | signal_result (client, |
903 | servicename, | ||
904 | request_id, | ||
895 | GNUNET_ARM_RESULT_IS_STOPPING_ALREADY); | 905 | GNUNET_ARM_RESULT_IS_STOPPING_ALREADY); |
896 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 906 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
897 | return; | 907 | return; |
@@ -899,7 +909,9 @@ handle_stop (void *cls, | |||
899 | if (NULL == sl->proc) | 909 | if (NULL == sl->proc) |
900 | { | 910 | { |
901 | /* process is down */ | 911 | /* process is down */ |
902 | signal_result (client, servicename, request_id, | 912 | signal_result (client, |
913 | servicename, | ||
914 | request_id, | ||
903 | GNUNET_ARM_RESULT_IS_STOPPED_ALREADY); | 915 | GNUNET_ARM_RESULT_IS_STOPPED_ALREADY); |
904 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 916 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
905 | return; | 917 | return; |
@@ -907,7 +919,9 @@ handle_stop (void *cls, | |||
907 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 919 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
908 | "Sending kill signal to service `%s', waiting for process to die.\n", | 920 | "Sending kill signal to service `%s', waiting for process to die.\n", |
909 | servicename); | 921 | servicename); |
910 | broadcast_status (servicename, GNUNET_ARM_SERVICE_STOPPING, NULL); | 922 | broadcast_status (servicename, |
923 | GNUNET_ARM_SERVICE_STOPPING, | ||
924 | NULL); | ||
911 | /* no signal_start - only when it's STOPPED */ | 925 | /* no signal_start - only when it's STOPPED */ |
912 | sl->killed_at = GNUNET_TIME_absolute_get (); | 926 | sl->killed_at = GNUNET_TIME_absolute_get (); |
913 | if (0 != GNUNET_OS_process_kill (sl->proc, GNUNET_TERM_SIG)) | 927 | if (0 != GNUNET_OS_process_kill (sl->proc, GNUNET_TERM_SIG)) |
@@ -1055,7 +1069,8 @@ shutdown_task (void *cls) | |||
1055 | while (NULL != (sli = pos->listen_head)) | 1069 | while (NULL != (sli = pos->listen_head)) |
1056 | { | 1070 | { |
1057 | GNUNET_CONTAINER_DLL_remove (pos->listen_head, | 1071 | GNUNET_CONTAINER_DLL_remove (pos->listen_head, |
1058 | pos->listen_tail, sli); | 1072 | pos->listen_tail, |
1073 | sli); | ||
1059 | if (NULL != sli->accept_task) | 1074 | if (NULL != sli->accept_task) |
1060 | { | 1075 | { |
1061 | GNUNET_SCHEDULER_cancel (sli->accept_task); | 1076 | GNUNET_SCHEDULER_cancel (sli->accept_task); |
@@ -1072,7 +1087,7 @@ shutdown_task (void *cls) | |||
1072 | while (NULL != (pos = nxt)) | 1087 | while (NULL != (pos = nxt)) |
1073 | { | 1088 | { |
1074 | nxt = pos->next; | 1089 | nxt = pos->next; |
1075 | if (pos->proc != NULL) | 1090 | if (NULL != pos->proc) |
1076 | { | 1091 | { |
1077 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1092 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1078 | "Stopping service `%s'\n", | 1093 | "Stopping service `%s'\n", |
@@ -1087,7 +1102,7 @@ shutdown_task (void *cls) | |||
1087 | } | 1102 | } |
1088 | } | 1103 | } |
1089 | /* finally, should all service processes be already gone, terminate for real */ | 1104 | /* finally, should all service processes be already gone, terminate for real */ |
1090 | if (running_head == NULL) | 1105 | if (NULL == running_head) |
1091 | do_shutdown (); | 1106 | do_shutdown (); |
1092 | else | 1107 | else |
1093 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1108 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1105,15 +1120,11 @@ static void | |||
1105 | delayed_restart_task (void *cls) | 1120 | delayed_restart_task (void *cls) |
1106 | 1121 | ||
1107 | { | 1122 | { |
1108 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
1109 | struct ServiceList *sl; | 1123 | struct ServiceList *sl; |
1110 | struct GNUNET_TIME_Relative lowestRestartDelay; | 1124 | struct GNUNET_TIME_Relative lowestRestartDelay; |
1111 | struct ServiceListeningInfo *sli; | 1125 | struct ServiceListeningInfo *sli; |
1112 | 1126 | ||
1113 | child_restart_task = NULL; | 1127 | child_restart_task = NULL; |
1114 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
1115 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
1116 | return; | ||
1117 | GNUNET_assert (GNUNET_NO == in_shutdown); | 1128 | GNUNET_assert (GNUNET_NO == in_shutdown); |
1118 | lowestRestartDelay = GNUNET_TIME_UNIT_FOREVER_REL; | 1129 | lowestRestartDelay = GNUNET_TIME_UNIT_FOREVER_REL; |
1119 | 1130 | ||
@@ -1144,7 +1155,8 @@ delayed_restart_task (void *cls) | |||
1144 | /* accept was actually paused, so start it again */ | 1155 | /* accept was actually paused, so start it again */ |
1145 | sli->accept_task = | 1156 | sli->accept_task = |
1146 | GNUNET_SCHEDULER_add_read_net | 1157 | GNUNET_SCHEDULER_add_read_net |
1147 | (GNUNET_TIME_UNIT_FOREVER_REL, sli->listen_socket, | 1158 | (GNUNET_TIME_UNIT_FOREVER_REL, |
1159 | sli->listen_socket, | ||
1148 | &accept_connection, sli); | 1160 | &accept_connection, sli); |
1149 | } | 1161 | } |
1150 | } | 1162 | } |
@@ -1180,7 +1192,6 @@ delayed_restart_task (void *cls) | |||
1180 | static void | 1192 | static void |
1181 | maint_child_death (void *cls) | 1193 | maint_child_death (void *cls) |
1182 | { | 1194 | { |
1183 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
1184 | struct ServiceList *pos; | 1195 | struct ServiceList *pos; |
1185 | struct ServiceList *next; | 1196 | struct ServiceList *next; |
1186 | struct ServiceListeningInfo *sli; | 1197 | struct ServiceListeningInfo *sli; |
@@ -1192,19 +1203,9 @@ maint_child_death (void *cls) | |||
1192 | unsigned long statusCode; | 1203 | unsigned long statusCode; |
1193 | const struct GNUNET_DISK_FileHandle *pr; | 1204 | const struct GNUNET_DISK_FileHandle *pr; |
1194 | 1205 | ||
1195 | pr = GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ); | 1206 | pr = GNUNET_DISK_pipe_handle (sigpipe, |
1207 | GNUNET_DISK_PIPE_END_READ); | ||
1196 | child_death_task = NULL; | 1208 | child_death_task = NULL; |
1197 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
1198 | if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) | ||
1199 | { | ||
1200 | /* shutdown scheduled us, ignore! */ | ||
1201 | child_death_task = | ||
1202 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | ||
1203 | pr, | ||
1204 | &maint_child_death, | ||
1205 | NULL); | ||
1206 | return; | ||
1207 | } | ||
1208 | /* consume the signal */ | 1209 | /* consume the signal */ |
1209 | GNUNET_break (0 < GNUNET_DISK_file_read (pr, &c, sizeof (c))); | 1210 | GNUNET_break (0 < GNUNET_DISK_file_read (pr, &c, sizeof (c))); |
1210 | 1211 | ||
@@ -1353,14 +1354,13 @@ maint_child_death (void *cls) | |||
1353 | } | 1354 | } |
1354 | else | 1355 | else |
1355 | { | 1356 | { |
1356 | if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 1357 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1357 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1358 | _("Service `%s' terminated with status %s/%d, will restart in %s\n"), |
1358 | _("Service `%s' terminated with status %s/%d, will restart in %s\n"), | 1359 | pos->name, |
1359 | pos->name, | 1360 | statstr, |
1360 | statstr, | 1361 | statcode, |
1361 | statcode, | 1362 | GNUNET_STRINGS_relative_time_to_string (pos->backoff, |
1362 | GNUNET_STRINGS_relative_time_to_string (pos->backoff, | 1363 | GNUNET_YES)); |
1363 | GNUNET_YES)); | ||
1364 | /* schedule restart */ | 1364 | /* schedule restart */ |
1365 | pos->restart_at = GNUNET_TIME_relative_to_absolute (pos->backoff); | 1365 | pos->restart_at = GNUNET_TIME_relative_to_absolute (pos->backoff); |
1366 | pos->backoff = GNUNET_TIME_STD_BACKOFF (pos->backoff); | 1366 | pos->backoff = GNUNET_TIME_STD_BACKOFF (pos->backoff); |
@@ -1601,9 +1601,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *serv, | |||
1601 | cfg = c; | 1601 | cfg = c; |
1602 | server = serv; | 1602 | server = serv; |
1603 | GNUNET_assert (NULL != serv); | 1603 | GNUNET_assert (NULL != serv); |
1604 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1604 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
1605 | &shutdown_task, | 1605 | NULL); |
1606 | NULL); | ||
1607 | child_death_task = | 1606 | child_death_task = |
1608 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | 1607 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
1609 | GNUNET_DISK_pipe_handle (sigpipe, | 1608 | GNUNET_DISK_pipe_handle (sigpipe, |
diff --git a/src/arm/test_arm_api.c b/src/arm/test_arm_api.c index 149ec46c4..f5283d714 100644 --- a/src/arm/test_arm_api.c +++ b/src/arm/test_arm_api.c | |||
@@ -157,7 +157,7 @@ arm_conn (void *cls, | |||
157 | ok = 3; | 157 | ok = 3; |
158 | else if (ok == 1) | 158 | else if (ok == 1) |
159 | ok = 0; | 159 | ok = 0; |
160 | GNUNET_SCHEDULER_add_now (trigger_disconnect, arm); | 160 | GNUNET_SCHEDULER_add_now (&trigger_disconnect, arm); |
161 | } | 161 | } |
162 | } | 162 | } |
163 | 163 | ||
diff --git a/src/arm/test_exponential_backoff.c b/src/arm/test_exponential_backoff.c index 1032a9010..3f33c91e6 100644 --- a/src/arm/test_exponential_backoff.c +++ b/src/arm/test_exponential_backoff.c | |||
@@ -90,7 +90,7 @@ struct ShutdownContext | |||
90 | /** | 90 | /** |
91 | * Task set up to cancel the shutdown request on timeout. | 91 | * Task set up to cancel the shutdown request on timeout. |
92 | */ | 92 | */ |
93 | struct GNUNET_SCHEDULER_Task * cancel_task; | 93 | struct GNUNET_SCHEDULER_Task *cancel_task; |
94 | 94 | ||
95 | /** | 95 | /** |
96 | * Task to call once shutdown complete | 96 | * Task to call once shutdown complete |
@@ -235,7 +235,7 @@ shutdown_cont (void *cls, int reason) | |||
235 | { | 235 | { |
236 | /* Re-try shutdown */ | 236 | /* Re-try shutdown */ |
237 | LOG ("do-nothing didn't die, trying again\n"); | 237 | LOG ("do-nothing didn't die, trying again\n"); |
238 | GNUNET_SCHEDULER_add_now (kill_task, NULL); | 238 | GNUNET_SCHEDULER_add_now (&kill_task, NULL); |
239 | return; | 239 | return; |
240 | } | 240 | } |
241 | startedWaitingAt = GNUNET_TIME_absolute_get (); | 241 | startedWaitingAt = GNUNET_TIME_absolute_get (); |
@@ -290,12 +290,15 @@ trigger_disconnect (void *cls) | |||
290 | 290 | ||
291 | 291 | ||
292 | static void | 292 | static void |
293 | arm_stop_cb (void *cls, enum GNUNET_ARM_RequestStatus status, const char *servicename, enum GNUNET_ARM_Result result) | 293 | arm_stop_cb (void *cls, |
294 | enum GNUNET_ARM_RequestStatus status, | ||
295 | const char *servicename, | ||
296 | enum GNUNET_ARM_Result result) | ||
294 | { | 297 | { |
295 | GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK); | 298 | GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK); |
296 | GNUNET_break (result == GNUNET_ARM_RESULT_STOPPED); | 299 | GNUNET_break (result == GNUNET_ARM_RESULT_STOPPED); |
297 | LOG ("ARM service stopped\n"); | 300 | LOG ("ARM service stopped\n"); |
298 | GNUNET_SCHEDULER_add_now (trigger_disconnect, NULL); | 301 | GNUNET_SCHEDULER_add_now (&trigger_disconnect, NULL); |
299 | } | 302 | } |
300 | 303 | ||
301 | 304 | ||
@@ -318,7 +321,8 @@ srv_status (void *cls, const char *service, enum GNUNET_ARM_ServiceStatus status | |||
318 | LOG ("do-nothing is starting\n"); | 321 | LOG ("do-nothing is starting\n"); |
319 | phase++; | 322 | phase++; |
320 | ok = 1; | 323 | ok = 1; |
321 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &kill_task, NULL); | 324 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
325 | &kill_task, NULL); | ||
322 | } | 326 | } |
323 | else if ((phase == 2) && (strcasecmp (SERVICE, service) == 0)) | 327 | else if ((phase == 2) && (strcasecmp (SERVICE, service) == 0)) |
324 | { | 328 | { |
@@ -328,7 +332,7 @@ srv_status (void *cls, const char *service, enum GNUNET_ARM_ServiceStatus status | |||
328 | if (status == GNUNET_ARM_SERVICE_STARTING) | 332 | if (status == GNUNET_ARM_SERVICE_STARTING) |
329 | { | 333 | { |
330 | LOG ("do-nothing is starting\n"); | 334 | LOG ("do-nothing is starting\n"); |
331 | GNUNET_SCHEDULER_add_now (kill_task, &ok); | 335 | GNUNET_SCHEDULER_add_now (&kill_task, &ok); |
332 | } | 336 | } |
333 | else if ((status == GNUNET_ARM_SERVICE_STOPPED) && (trialCount == 14)) | 337 | else if ((status == GNUNET_ARM_SERVICE_STOPPED) && (trialCount == 14)) |
334 | { | 338 | { |
diff --git a/src/ats-tests/ats-testing-log.c b/src/ats-tests/ats-testing-log.c index 650be29f3..5e22d4b47 100644 --- a/src/ats-tests/ats-testing-log.c +++ b/src/ats-tests/ats-testing-log.c | |||
@@ -804,13 +804,9 @@ static void | |||
804 | collect_log_task (void *cls) | 804 | collect_log_task (void *cls) |
805 | { | 805 | { |
806 | struct LoggingHandle *l = cls; | 806 | struct LoggingHandle *l = cls; |
807 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
808 | 807 | ||
809 | l->log_task = NULL; | 808 | l->log_task = NULL; |
810 | GNUNET_ATS_TEST_logging_now (l); | 809 | GNUNET_ATS_TEST_logging_now (l); |
811 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
812 | if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) | ||
813 | return; | ||
814 | l->log_task = GNUNET_SCHEDULER_add_delayed (l->frequency, | 810 | l->log_task = GNUNET_SCHEDULER_add_delayed (l->frequency, |
815 | &collect_log_task, | 811 | &collect_log_task, |
816 | l); | 812 | l); |
@@ -829,8 +825,10 @@ GNUNET_ATS_TEST_logging_stop (struct LoggingHandle *l) | |||
829 | return; | 825 | return; |
830 | 826 | ||
831 | if (NULL != l->log_task) | 827 | if (NULL != l->log_task) |
828 | { | ||
832 | GNUNET_SCHEDULER_cancel (l->log_task); | 829 | GNUNET_SCHEDULER_cancel (l->log_task); |
833 | l->log_task = NULL; | 830 | l->log_task = NULL; |
831 | } | ||
834 | l->running = GNUNET_NO; | 832 | l->running = GNUNET_NO; |
835 | 833 | ||
836 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 834 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
diff --git a/src/ats-tests/perf_ats_logging.c b/src/ats-tests/perf_ats_logging.c index 1e4b15432..d4c4f2cd9 100644 --- a/src/ats-tests/perf_ats_logging.c +++ b/src/ats-tests/perf_ats_logging.c | |||
@@ -639,15 +639,8 @@ collect_log_now (void) | |||
639 | static void | 639 | static void |
640 | collect_log_task (void *cls) | 640 | collect_log_task (void *cls) |
641 | { | 641 | { |
642 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
643 | |||
644 | log_task = NULL; | 642 | log_task = NULL; |
645 | 643 | collect_log_now (); | |
646 | collect_log_now(); | ||
647 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
648 | if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) | ||
649 | return; | ||
650 | |||
651 | log_task = GNUNET_SCHEDULER_add_delayed (frequency, | 644 | log_task = GNUNET_SCHEDULER_add_delayed (frequency, |
652 | &collect_log_task, NULL); | 645 | &collect_log_task, NULL); |
653 | } | 646 | } |
@@ -659,12 +652,14 @@ perf_logging_stop () | |||
659 | int c_m; | 652 | int c_m; |
660 | struct PeerLoggingTimestep *cur; | 653 | struct PeerLoggingTimestep *cur; |
661 | 654 | ||
662 | if (GNUNET_YES!= running) | 655 | if (GNUNET_YES != running) |
663 | return; | 656 | return; |
664 | 657 | ||
665 | if (NULL != log_task) | 658 | if (NULL != log_task) |
659 | { | ||
666 | GNUNET_SCHEDULER_cancel (log_task); | 660 | GNUNET_SCHEDULER_cancel (log_task); |
667 | log_task = NULL; | 661 | log_task = NULL; |
662 | } | ||
668 | collect_log_task (NULL); | 663 | collect_log_task (NULL); |
669 | 664 | ||
670 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 665 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
diff --git a/src/ats-tool/gnunet-ats.c b/src/ats-tool/gnunet-ats.c index a2ef80cef..5fc1d6e92 100644 --- a/src/ats-tool/gnunet-ats.c +++ b/src/ats-tool/gnunet-ats.c | |||
@@ -363,7 +363,7 @@ transport_addr_to_str_cb (void *cls, | |||
363 | /* All messages received and no resolutions pending*/ | 363 | /* All messages received and no resolutions pending*/ |
364 | if (shutdown_task != NULL) | 364 | if (shutdown_task != NULL) |
365 | GNUNET_SCHEDULER_cancel (shutdown_task); | 365 | GNUNET_SCHEDULER_cancel (shutdown_task); |
366 | shutdown_task = GNUNET_SCHEDULER_add_now (end, NULL); | 366 | shutdown_task = GNUNET_SCHEDULER_add_now (&end, NULL); |
367 | } | 367 | } |
368 | return; | 368 | return; |
369 | } | 369 | } |
@@ -604,7 +604,7 @@ ats_perf_cb (void *cls, | |||
604 | /* All messages received and no resolutions pending*/ | 604 | /* All messages received and no resolutions pending*/ |
605 | if (shutdown_task != NULL) | 605 | if (shutdown_task != NULL) |
606 | GNUNET_SCHEDULER_cancel (shutdown_task); | 606 | GNUNET_SCHEDULER_cancel (shutdown_task); |
607 | shutdown_task = GNUNET_SCHEDULER_add_now (end, NULL); | 607 | shutdown_task = GNUNET_SCHEDULER_add_now (&end, NULL); |
608 | } | 608 | } |
609 | return; | 609 | return; |
610 | } | 610 | } |
@@ -807,9 +807,8 @@ run (void *cls, | |||
807 | shutdown_task = GNUNET_SCHEDULER_add_now (&end, NULL); | 807 | shutdown_task = GNUNET_SCHEDULER_add_now (&end, NULL); |
808 | return; | 808 | return; |
809 | } | 809 | } |
810 | shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 810 | shutdown_task = GNUNET_SCHEDULER_add_shutdown (&end, |
811 | &end, | 811 | NULL); |
812 | NULL); | ||
813 | return; | 812 | return; |
814 | } | 813 | } |
815 | if (opt_list_used) | 814 | if (opt_list_used) |
@@ -834,9 +833,8 @@ run (void *cls, | |||
834 | shutdown_task = GNUNET_SCHEDULER_add_now (&end, NULL); | 833 | shutdown_task = GNUNET_SCHEDULER_add_now (&end, NULL); |
835 | return; | 834 | return; |
836 | } | 835 | } |
837 | shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 836 | shutdown_task = GNUNET_SCHEDULER_add_shutdown (&end, |
838 | &end, | 837 | NULL); |
839 | NULL); | ||
840 | return; | 838 | return; |
841 | } | 839 | } |
842 | if (opt_monitor) | 840 | if (opt_monitor) |
@@ -844,13 +842,15 @@ run (void *cls, | |||
844 | ph = GNUNET_ATS_performance_init (cfg, | 842 | ph = GNUNET_ATS_performance_init (cfg, |
845 | &ats_perf_mon_cb, | 843 | &ats_perf_mon_cb, |
846 | NULL); | 844 | NULL); |
845 | shutdown_task = GNUNET_SCHEDULER_add_shutdown (&end, | ||
846 | NULL); | ||
847 | if (NULL == ph) | 847 | if (NULL == ph) |
848 | { | ||
848 | FPRINTF (stderr, | 849 | FPRINTF (stderr, |
849 | "%s", | 850 | "%s", |
850 | _("Cannot connect to ATS service, exiting...\n")); | 851 | _("Cannot connect to ATS service, exiting...\n")); |
851 | shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 852 | GNUNET_SCHEDULER_shutdown (); |
852 | &end, | 853 | } |
853 | NULL); | ||
854 | return; | 854 | return; |
855 | } | 855 | } |
856 | if (opt_set_pref) | 856 | if (opt_set_pref) |
diff --git a/src/ats/gnunet-service-ats.c b/src/ats/gnunet-service-ats.c index 7b8dfe222..045a5bb67 100644 --- a/src/ats/gnunet-service-ats.c +++ b/src/ats/gnunet-service-ats.c | |||
@@ -138,9 +138,6 @@ cleanup_task (void *cls) | |||
138 | GAS_performance_done (); | 138 | GAS_performance_done (); |
139 | GAS_preference_done (); | 139 | GAS_preference_done (); |
140 | GAS_reservations_done (); | 140 | GAS_reservations_done (); |
141 | GNUNET_SERVER_disconnect_notify_cancel (GSA_server, | ||
142 | &client_disconnect_handler, | ||
143 | NULL); | ||
144 | if (NULL != GSA_stats) | 141 | if (NULL != GSA_stats) |
145 | { | 142 | { |
146 | GNUNET_STATISTICS_destroy (GSA_stats, GNUNET_NO); | 143 | GNUNET_STATISTICS_destroy (GSA_stats, GNUNET_NO); |
@@ -221,9 +218,8 @@ run (void *cls, | |||
221 | &client_disconnect_handler, | 218 | &client_disconnect_handler, |
222 | NULL); | 219 | NULL); |
223 | GNUNET_SERVER_add_handlers (server, handlers); | 220 | GNUNET_SERVER_add_handlers (server, handlers); |
224 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 221 | GNUNET_SCHEDULER_add_shutdown (&cleanup_task, |
225 | &cleanup_task, | 222 | NULL); |
226 | NULL); | ||
227 | } | 223 | } |
228 | 224 | ||
229 | 225 | ||
diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c index 6894d2482..d5b0688e6 100644 --- a/src/cadet/cadet_api.c +++ b/src/cadet/cadet_api.c | |||
@@ -1,20 +1,22 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2011 GNUnet e.V. | 3 | Copyright (C) 2011 GNUnet e.V. |
4 | |||
4 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
6 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation; either version 3, or (at your |
7 | option) any later version. | 8 | option) any later version. |
9 | |||
8 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
9 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
11 | General Public License for more details. | 13 | General Public License for more details. |
14 | |||
12 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
13 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with GNUnet; see the file COPYING. If not, write to the |
14 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
15 | Boston, MA 02110-1301, USA. | 18 | Boston, MA 02110-1301, USA. |
16 | */ | 19 | */ |
17 | |||
18 | /** | 20 | /** |
19 | * @file cadet/cadet_api.c | 21 | * @file cadet/cadet_api.c |
20 | * @brief cadet api: client implementation of new cadet service | 22 | * @brief cadet api: client implementation of new cadet service |
@@ -702,12 +704,8 @@ static void | |||
702 | reconnect_cbk (void *cls) | 704 | reconnect_cbk (void *cls) |
703 | { | 705 | { |
704 | struct GNUNET_CADET_Handle *h = cls; | 706 | struct GNUNET_CADET_Handle *h = cls; |
705 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
706 | 707 | ||
707 | h->reconnect_task = NULL; | 708 | h->reconnect_task = NULL; |
708 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
709 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
710 | return; | ||
711 | do_reconnect (h); | 709 | do_reconnect (h); |
712 | } | 710 | } |
713 | 711 | ||
@@ -718,7 +716,7 @@ reconnect_cbk (void *cls) | |||
718 | * | 716 | * |
719 | * @param h handle to the cadet | 717 | * @param h handle to the cadet |
720 | * | 718 | * |
721 | * @return GNUNET_YES in case of sucess, GNUNET_NO otherwise (service down...) | 719 | * @return #GNUNET_YES in case of sucess, #GNUNET_NO otherwise (service down...) |
722 | */ | 720 | */ |
723 | static void | 721 | static void |
724 | reconnect (struct GNUNET_CADET_Handle *h) | 722 | reconnect (struct GNUNET_CADET_Handle *h) |
diff --git a/src/cadet/cadet_path.c b/src/cadet/cadet_path.c index 47241292b..0358d64ca 100644 --- a/src/cadet/cadet_path.c +++ b/src/cadet/cadet_path.c | |||
@@ -33,10 +33,7 @@ | |||
33 | 33 | ||
34 | /** | 34 | /** |
35 | * @brief Destroy a path after some time has past. | 35 | * @brief Destroy a path after some time has past. |
36 | * | 36 | * Removes the path from the peer (must not be used for direct paths). |
37 | * If the path is returned from DHT again after a while, try again. | ||
38 | * | ||
39 | * Removes the path from the peer (except for direct paths). | ||
40 | * | 37 | * |
41 | * @param cls Closure (path to destroy). | 38 | * @param cls Closure (path to destroy). |
42 | */ | 39 | */ |
@@ -45,28 +42,17 @@ path_destroy_delayed (void *cls) | |||
45 | { | 42 | { |
46 | struct CadetPeerPath *path = cls; | 43 | struct CadetPeerPath *path = cls; |
47 | struct CadetPeer *peer; | 44 | struct CadetPeer *peer; |
48 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
49 | 45 | ||
50 | LOG (GNUNET_ERROR_TYPE_INFO, "Destroy delayed %p (%u)\n", path, path->length); | ||
51 | path->path_delete = NULL; | 46 | path->path_delete = NULL; |
52 | 47 | LOG (GNUNET_ERROR_TYPE_INFO, | |
53 | /* During shutdown, the peers peermap might not exist anymore. */ | 48 | "Destroy delayed %p (%u)\n", |
54 | tc = GNUNET_SCHEDULER_get_task_context (); | 49 | path, |
55 | if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) == 0) | 50 | path->length); |
56 | { | 51 | GNUNET_assert (2 < path->length); |
57 | if (2 >= path->length) | 52 | peer = GCP_get_short (path->peers[path->length - 1], |
58 | { | 53 | GNUNET_NO); |
59 | /* This is not the place to destroy direct paths, only core_disconnect | 54 | GNUNET_assert (NULL != peer); |
60 | * should do it and never delay it. | 55 | GCP_remove_path (peer, path); |
61 | */ | ||
62 | GNUNET_break (0); | ||
63 | } | ||
64 | peer = GCP_get_short (path->peers[path->length - 1], GNUNET_NO); | ||
65 | if (NULL != peer) | ||
66 | GCP_remove_path (peer, path); | ||
67 | } | ||
68 | else | ||
69 | path_destroy (path); | ||
70 | } | 56 | } |
71 | 57 | ||
72 | 58 | ||
@@ -74,7 +60,6 @@ path_destroy_delayed (void *cls) | |||
74 | * Create a new path | 60 | * Create a new path |
75 | * | 61 | * |
76 | * @param length How many hops will the path have. | 62 | * @param length How many hops will the path have. |
77 | * | ||
78 | * @return A newly allocated path with a peer array of the specified length. | 63 | * @return A newly allocated path with a peer array of the specified length. |
79 | */ | 64 | */ |
80 | struct CadetPeerPath * | 65 | struct CadetPeerPath * |
@@ -125,7 +110,9 @@ path_duplicate (const struct CadetPeerPath *path) | |||
125 | unsigned int i; | 110 | unsigned int i; |
126 | 111 | ||
127 | aux = path_new (path->length); | 112 | aux = path_new (path->length); |
128 | memcpy (aux->peers, path->peers, path->length * sizeof (GNUNET_PEER_Id)); | 113 | memcpy (aux->peers, |
114 | path->peers, | ||
115 | path->length * sizeof (GNUNET_PEER_Id)); | ||
129 | for (i = 0; i < aux->length; i++) | 116 | for (i = 0; i < aux->length; i++) |
130 | GNUNET_PEER_change_rc (aux->peers[i], 1); | 117 | GNUNET_PEER_change_rc (aux->peers[i], 1); |
131 | return aux; | 118 | return aux; |
@@ -167,9 +154,13 @@ path_invalidate (struct CadetPeerPath *p) | |||
167 | if (NULL != p->path_delete) | 154 | if (NULL != p->path_delete) |
168 | return; | 155 | return; |
169 | 156 | ||
170 | LOG (GNUNET_ERROR_TYPE_INFO, "Invalidating path %p (%u)\n", p, p->length); | 157 | LOG (GNUNET_ERROR_TYPE_INFO, |
171 | p->path_delete = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, | 158 | "Invalidating path %p (%u)\n", |
172 | &path_destroy_delayed, p); | 159 | p, |
160 | p->length); | ||
161 | p->path_delete | ||
162 | = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, | ||
163 | &path_destroy_delayed, p); | ||
173 | } | 164 | } |
174 | 165 | ||
175 | 166 | ||
@@ -242,8 +233,8 @@ path_build_from_peer_ids (struct GNUNET_PeerIdentity *peers, | |||
242 | * @param p1 First path | 233 | * @param p1 First path |
243 | * @param p2 Second path | 234 | * @param p2 Second path |
244 | * | 235 | * |
245 | * @return GNUNET_YES if both paths are equivalent | 236 | * @return #GNUNET_YES if both paths are equivalent |
246 | * GNUNET_NO otherwise | 237 | * #GNUNET_NO otherwise |
247 | */ | 238 | */ |
248 | int | 239 | int |
249 | path_equivalent (const struct CadetPeerPath *p1, | 240 | path_equivalent (const struct CadetPeerPath *p1, |
@@ -293,7 +284,7 @@ path_is_valid (const struct CadetPeerPath *path) | |||
293 | * | 284 | * |
294 | * @param p the path to destroy | 285 | * @param p the path to destroy |
295 | * | 286 | * |
296 | * @return GNUNET_OK on success | 287 | * @return #GNUNET_OK on success |
297 | */ | 288 | */ |
298 | int | 289 | int |
299 | path_destroy (struct CadetPeerPath *p) | 290 | path_destroy (struct CadetPeerPath *p) |
@@ -301,7 +292,10 @@ path_destroy (struct CadetPeerPath *p) | |||
301 | if (NULL == p) | 292 | if (NULL == p) |
302 | return GNUNET_OK; | 293 | return GNUNET_OK; |
303 | 294 | ||
304 | LOG (GNUNET_ERROR_TYPE_INFO, "destroying path %p (%u)\n", p, p->length); | 295 | LOG (GNUNET_ERROR_TYPE_INFO, |
296 | "destroying path %p (%u)\n", | ||
297 | p, | ||
298 | p->length); | ||
305 | GNUNET_PEER_decrement_rcs (p->peers, p->length); | 299 | GNUNET_PEER_decrement_rcs (p->peers, p->length); |
306 | GNUNET_free_non_null (p->peers); | 300 | GNUNET_free_non_null (p->peers); |
307 | if (NULL != p->path_delete) | 301 | if (NULL != p->path_delete) |
@@ -322,7 +316,8 @@ path_destroy (struct CadetPeerPath *p) | |||
322 | * 0 if they are identical. | 316 | * 0 if they are identical. |
323 | */ | 317 | */ |
324 | int | 318 | int |
325 | path_cmp (const struct CadetPeerPath *p1, const struct CadetPeerPath *p2) | 319 | path_cmp (const struct CadetPeerPath *p1, |
320 | const struct CadetPeerPath *p2) | ||
326 | { | 321 | { |
327 | if (p1->length > p2->length) | 322 | if (p1->length > p2->length) |
328 | return 1; | 323 | return 1; |
@@ -330,7 +325,9 @@ path_cmp (const struct CadetPeerPath *p1, const struct CadetPeerPath *p2) | |||
330 | if (p1->length < p2->length) | 325 | if (p1->length < p2->length) |
331 | return -1; | 326 | return -1; |
332 | 327 | ||
333 | return memcmp (p1->peers, p2->peers, sizeof (GNUNET_PEER_Id) * p1->length); | 328 | return memcmp (p1->peers, |
329 | p2->peers, | ||
330 | sizeof (GNUNET_PEER_Id) * p1->length); | ||
334 | } | 331 | } |
335 | 332 | ||
336 | 333 | ||
diff --git a/src/cadet/gnunet-cadet-profiler.c b/src/cadet/gnunet-cadet-profiler.c index ffa993f8e..b2a07cb0c 100644 --- a/src/cadet/gnunet-cadet-profiler.c +++ b/src/cadet/gnunet-cadet-profiler.c | |||
@@ -147,7 +147,12 @@ struct CadetPeer | |||
147 | /** | 147 | /** |
148 | * Task to do the next ping. | 148 | * Task to do the next ping. |
149 | */ | 149 | */ |
150 | struct GNUNET_SCHEDULER_Task * ping_task; | 150 | struct GNUNET_SCHEDULER_Task *ping_task; |
151 | |||
152 | /** | ||
153 | * NTR operation for the next ping. | ||
154 | */ | ||
155 | struct GNUNET_CADET_TransmitHandle *ping_ntr; | ||
151 | 156 | ||
152 | float mean[number_rounds]; | 157 | float mean[number_rounds]; |
153 | float var[number_rounds]; | 158 | float var[number_rounds]; |
@@ -179,7 +184,7 @@ static struct GNUNET_TESTBED_Operation *stats_op; | |||
179 | /** | 184 | /** |
180 | * Operation to get peer ids. | 185 | * Operation to get peer ids. |
181 | */ | 186 | */ |
182 | struct CadetPeer *peers; | 187 | static struct CadetPeer *peers; |
183 | 188 | ||
184 | /** | 189 | /** |
185 | * Peer ids counter. | 190 | * Peer ids counter. |
@@ -207,19 +212,14 @@ static unsigned long long peers_pinging; | |||
207 | static struct GNUNET_CADET_TEST_Context *test_ctx; | 212 | static struct GNUNET_CADET_TEST_Context *test_ctx; |
208 | 213 | ||
209 | /** | 214 | /** |
210 | * Task called to shutdown test. | ||
211 | */ | ||
212 | static struct GNUNET_SCHEDULER_Task * shutdown_handle; | ||
213 | |||
214 | /** | ||
215 | * Task called to disconnect peers, before shutdown. | 215 | * Task called to disconnect peers, before shutdown. |
216 | */ | 216 | */ |
217 | static struct GNUNET_SCHEDULER_Task * 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 struct GNUNET_SCHEDULER_Task * test_task; | 222 | static struct GNUNET_SCHEDULER_Task *test_task; |
223 | 223 | ||
224 | /** | 224 | /** |
225 | * Round number. | 225 | * Round number. |
@@ -241,6 +241,11 @@ static unsigned int peers_warmup; | |||
241 | */ | 241 | */ |
242 | static int test_finished; | 242 | static int test_finished; |
243 | 243 | ||
244 | /** | ||
245 | * Task running each round of the benchmark. | ||
246 | */ | ||
247 | static struct GNUNET_SCHEDULER_Task *round_task; | ||
248 | |||
244 | 249 | ||
245 | /** | 250 | /** |
246 | * START THE TEST ITSELF, AS WE ARE CONNECTED TO THE CADET SERVICES. | 251 | * START THE TEST ITSELF, AS WE ARE CONNECTED TO THE CADET SERVICES. |
@@ -310,19 +315,6 @@ show_end_data (void) | |||
310 | 315 | ||
311 | 316 | ||
312 | /** | 317 | /** |
313 | * Shut down peergroup, clean up. | ||
314 | * | ||
315 | * @param cls Closure (unused). | ||
316 | */ | ||
317 | static void | ||
318 | shutdown_task (void *cls) | ||
319 | { | ||
320 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Ending test.\n"); | ||
321 | shutdown_handle = NULL; | ||
322 | } | ||
323 | |||
324 | |||
325 | /** | ||
326 | * Disconnect from cadet services af all peers, call shutdown. | 318 | * Disconnect from cadet services af all peers, call shutdown. |
327 | * | 319 | * |
328 | * @param cls Closure (unused). | 320 | * @param cls Closure (unused). |
@@ -334,7 +326,8 @@ disconnect_cadet_peers (void *cls) | |||
334 | unsigned int i; | 326 | unsigned int i; |
335 | 327 | ||
336 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 328 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
337 | "disconnecting cadet service, called from line %ld\n", line); | 329 | "disconnecting cadet service, called from line %ld\n", |
330 | line); | ||
338 | disconnect_task = NULL; | 331 | disconnect_task = NULL; |
339 | for (i = 0; i < peers_total; i++) | 332 | for (i = 0; i < peers_total; i++) |
340 | { | 333 | { |
@@ -346,28 +339,56 @@ disconnect_cadet_peers (void *cls) | |||
346 | 339 | ||
347 | if (NULL != peers[i].ch) | 340 | if (NULL != peers[i].ch) |
348 | { | 341 | { |
349 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u: channel %p\n", i, peers[i].ch); | 342 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
343 | "%u: channel %p\n", i, peers[i].ch); | ||
350 | GNUNET_CADET_channel_destroy (peers[i].ch); | 344 | GNUNET_CADET_channel_destroy (peers[i].ch); |
351 | } | 345 | } |
352 | if (NULL != peers[i].warmup_ch) | 346 | if (NULL != peers[i].warmup_ch) |
353 | { | 347 | { |
354 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u: warmup channel %p\n", | 348 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
349 | "%u: warmup channel %p\n", | ||
355 | i, peers[i].warmup_ch); | 350 | i, peers[i].warmup_ch); |
356 | GNUNET_CADET_channel_destroy (peers[i].warmup_ch); | 351 | GNUNET_CADET_channel_destroy (peers[i].warmup_ch); |
357 | } | 352 | } |
358 | if (NULL != peers[i].incoming_ch) | 353 | if (NULL != peers[i].incoming_ch) |
359 | { | 354 | { |
360 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u: incoming channel %p\n", | 355 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
356 | "%u: incoming channel %p\n", | ||
361 | i, peers[i].incoming_ch); | 357 | i, peers[i].incoming_ch); |
362 | GNUNET_CADET_channel_destroy (peers[i].incoming_ch); | 358 | GNUNET_CADET_channel_destroy (peers[i].incoming_ch); |
363 | } | 359 | } |
364 | } | 360 | } |
365 | GNUNET_CADET_TEST_cleanup (test_ctx); | 361 | GNUNET_CADET_TEST_cleanup (test_ctx); |
366 | if (NULL != shutdown_handle) | 362 | GNUNET_SCHEDULER_shutdown (); |
363 | } | ||
364 | |||
365 | |||
366 | /** | ||
367 | * Shut down peergroup, clean up. | ||
368 | * | ||
369 | * @param cls Closure (unused). | ||
370 | */ | ||
371 | static void | ||
372 | shutdown_task (void *cls) | ||
373 | { | ||
374 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
375 | "Ending test.\n"); | ||
376 | if (NULL != disconnect_task) | ||
367 | { | 377 | { |
368 | GNUNET_SCHEDULER_cancel (shutdown_handle); | 378 | GNUNET_SCHEDULER_cancel (disconnect_task); |
379 | disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers, | ||
380 | (void *) __LINE__); | ||
381 | } | ||
382 | if (NULL != round_task) | ||
383 | { | ||
384 | GNUNET_SCHEDULER_cancel (round_task); | ||
385 | round_task = NULL; | ||
386 | } | ||
387 | if (NULL != test_task) | ||
388 | { | ||
389 | GNUNET_SCHEDULER_cancel (test_task); | ||
390 | test_task = NULL; | ||
369 | } | 391 | } |
370 | shutdown_handle = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | ||
371 | } | 392 | } |
372 | 393 | ||
373 | 394 | ||
@@ -418,13 +439,16 @@ stats_cont (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg) | |||
418 | * @param subsystem name of subsystem that created the statistic | 439 | * @param subsystem name of subsystem that created the statistic |
419 | * @param name the name of the datum | 440 | * @param name the name of the datum |
420 | * @param value the current value | 441 | * @param value the current value |
421 | * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not | 442 | * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not |
422 | * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration | 443 | * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration |
423 | */ | 444 | */ |
424 | static int | 445 | static int |
425 | stats_iterator (void *cls, const struct GNUNET_TESTBED_Peer *peer, | 446 | stats_iterator (void *cls, |
426 | const char *subsystem, const char *name, | 447 | const struct GNUNET_TESTBED_Peer *peer, |
427 | uint64_t value, int is_persistent) | 448 | const char *subsystem, |
449 | const char *name, | ||
450 | uint64_t value, | ||
451 | int is_persistent) | ||
428 | { | 452 | { |
429 | uint32_t i; | 453 | uint32_t i; |
430 | 454 | ||
@@ -444,16 +468,13 @@ stats_iterator (void *cls, const struct GNUNET_TESTBED_Peer *peer, | |||
444 | static void | 468 | static void |
445 | collect_stats (void *cls) | 469 | collect_stats (void *cls) |
446 | { | 470 | { |
447 | const struct GNUNET_SCHEDULER_TaskContext *tc; | 471 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
448 | 472 | "Start collecting statistics...\n"); | |
449 | tc = GNUNET_SCHEDULER_get_task_context (); | 473 | stats_op = GNUNET_TESTBED_get_statistics (peers_total, |
450 | if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0) | 474 | testbed_handles, |
451 | return; | ||
452 | |||
453 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start collecting statistics...\n"); | ||
454 | stats_op = GNUNET_TESTBED_get_statistics (peers_total, testbed_handles, | ||
455 | NULL, NULL, | 475 | NULL, NULL, |
456 | stats_iterator, stats_cont, NULL); | 476 | &stats_iterator, |
477 | &stats_cont, NULL); | ||
457 | } | 478 | } |
458 | 479 | ||
459 | 480 | ||
@@ -465,17 +486,12 @@ collect_stats (void *cls) | |||
465 | static void | 486 | static void |
466 | finish_profiler (void *cls) | 487 | finish_profiler (void *cls) |
467 | { | 488 | { |
468 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
469 | |||
470 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
471 | if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0) | ||
472 | return; | ||
473 | |||
474 | test_finished = GNUNET_YES; | 489 | test_finished = GNUNET_YES; |
475 | show_end_data(); | 490 | show_end_data (); |
476 | GNUNET_SCHEDULER_add_now (&collect_stats, NULL); | 491 | GNUNET_SCHEDULER_add_now (&collect_stats, NULL); |
477 | } | 492 | } |
478 | 493 | ||
494 | |||
479 | /** | 495 | /** |
480 | * Set the total number of running peers. | 496 | * Set the total number of running peers. |
481 | * | 497 | * |
@@ -515,9 +531,15 @@ adjust_running_peers (unsigned int target) | |||
515 | run ? "arting" : "opping", r, GNUNET_i2s (&peers[r].id)); | 531 | run ? "arting" : "opping", r, GNUNET_i2s (&peers[r].id)); |
516 | 532 | ||
517 | if (NULL != peers[r].ping_task) | 533 | if (NULL != peers[r].ping_task) |
534 | { | ||
518 | GNUNET_SCHEDULER_cancel (peers[r].ping_task); | 535 | GNUNET_SCHEDULER_cancel (peers[r].ping_task); |
519 | peers[r].ping_task = NULL; | 536 | peers[r].ping_task = NULL; |
520 | 537 | } | |
538 | if (NULL != peers[r].ping_ntr) | ||
539 | { | ||
540 | GNUNET_CADET_notify_transmit_ready_cancel (peers[r].ping_ntr); | ||
541 | peers[r].ping_ntr = NULL; | ||
542 | } | ||
521 | peers[r].up = run; | 543 | peers[r].up = run; |
522 | 544 | ||
523 | if (NULL != peers[r].ch) | 545 | if (NULL != peers[r].ch) |
@@ -547,12 +569,6 @@ adjust_running_peers (unsigned int target) | |||
547 | static void | 569 | static void |
548 | next_rnd (void *cls) | 570 | next_rnd (void *cls) |
549 | { | 571 | { |
550 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
551 | |||
552 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
553 | if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0) | ||
554 | return; | ||
555 | |||
556 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "ROUND %ld\n", current_round); | 572 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "ROUND %ld\n", current_round); |
557 | if (0.0 == rounds[current_round]) | 573 | if (0.0 == rounds[current_round]) |
558 | { | 574 | { |
@@ -563,7 +579,9 @@ next_rnd (void *cls) | |||
563 | adjust_running_peers (rounds[current_round] * peers_total); | 579 | adjust_running_peers (rounds[current_round] * peers_total); |
564 | current_round++; | 580 | current_round++; |
565 | 581 | ||
566 | GNUNET_SCHEDULER_add_delayed (round_time, &next_rnd, NULL); | 582 | round_task = GNUNET_SCHEDULER_add_delayed (round_time, |
583 | &next_rnd, | ||
584 | NULL); | ||
567 | } | 585 | } |
568 | 586 | ||
569 | 587 | ||
@@ -616,21 +634,19 @@ static void | |||
616 | ping (void *cls) | 634 | ping (void *cls) |
617 | { | 635 | { |
618 | struct CadetPeer *peer = cls; | 636 | struct CadetPeer *peer = cls; |
619 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
620 | 637 | ||
621 | peer->ping_task = NULL; | 638 | peer->ping_task = NULL; |
622 | tc = GNUNET_SCHEDULER_get_task_context (); | 639 | if (GNUNET_YES == test_finished) |
623 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) | ||
624 | || GNUNET_YES == test_finished) | ||
625 | return; | 640 | return; |
626 | 641 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | |
627 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u -> %u (%u)\n", | 642 | "%u -> %u (%u)\n", |
628 | get_index (peer), get_index (peer->dest), peer->data_sent); | 643 | get_index (peer), |
629 | 644 | get_index (peer->dest), | |
630 | GNUNET_CADET_notify_transmit_ready (peer->ch, GNUNET_NO, | 645 | peer->data_sent); |
631 | GNUNET_TIME_UNIT_FOREVER_REL, | 646 | peer->ping_ntr = GNUNET_CADET_notify_transmit_ready (peer->ch, GNUNET_NO, |
632 | sizeof (struct CadetPingMessage), | 647 | GNUNET_TIME_UNIT_FOREVER_REL, |
633 | &tmt_rdy_ping, peer); | 648 | sizeof (struct CadetPingMessage), |
649 | &tmt_rdy_ping, peer); | ||
634 | } | 650 | } |
635 | 651 | ||
636 | /** | 652 | /** |
@@ -640,12 +656,13 @@ ping (void *cls) | |||
640 | * @param tc Task context. | 656 | * @param tc Task context. |
641 | */ | 657 | */ |
642 | static void | 658 | static void |
643 | pong (struct GNUNET_CADET_Channel *channel, const struct CadetPingMessage *ping) | 659 | pong (struct GNUNET_CADET_Channel *channel, |
660 | const struct CadetPingMessage *ping) | ||
644 | { | 661 | { |
645 | struct CadetPingMessage *copy; | 662 | struct CadetPingMessage *copy; |
646 | 663 | ||
647 | copy = GNUNET_new (struct CadetPingMessage); | 664 | copy = GNUNET_new (struct CadetPingMessage); |
648 | memcpy (copy, ping, sizeof (*ping)); | 665 | *copy = *ping; |
649 | GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO, | 666 | GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO, |
650 | GNUNET_TIME_UNIT_FOREVER_REL, | 667 | GNUNET_TIME_UNIT_FOREVER_REL, |
651 | sizeof (struct CadetPingMessage), | 668 | sizeof (struct CadetPingMessage), |
@@ -666,7 +683,9 @@ tmt_rdy_ping (void *cls, size_t size, void *buf) | |||
666 | struct CadetPeer *peer = (struct CadetPeer *) cls; | 683 | struct CadetPeer *peer = (struct CadetPeer *) cls; |
667 | struct CadetPingMessage *msg = buf; | 684 | struct CadetPingMessage *msg = buf; |
668 | 685 | ||
669 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "tmt_rdy called, filling buffer\n"); | 686 | peer->ping_ntr = NULL; |
687 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
688 | "tmt_rdy called, filling buffer\n"); | ||
670 | if (size < sizeof (struct CadetPingMessage) || NULL == buf) | 689 | if (size < sizeof (struct CadetPingMessage) || NULL == buf) |
671 | { | 690 | { |
672 | GNUNET_break (GNUNET_YES == test_finished); | 691 | GNUNET_break (GNUNET_YES == test_finished); |
@@ -827,7 +846,8 @@ incoming_channel (void *cls, struct GNUNET_CADET_Channel *channel, | |||
827 | * with the channel is stored | 846 | * with the channel is stored |
828 | */ | 847 | */ |
829 | static void | 848 | static void |
830 | channel_cleaner (void *cls, const struct GNUNET_CADET_Channel *channel, | 849 | channel_cleaner (void *cls, |
850 | const struct GNUNET_CADET_Channel *channel, | ||
831 | void *channel_ctx) | 851 | void *channel_ctx) |
832 | { | 852 | { |
833 | long n = (long) cls; | 853 | long n = (long) cls; |
@@ -874,13 +894,8 @@ start_test (void *cls) | |||
874 | { | 894 | { |
875 | enum GNUNET_CADET_ChannelOption flags; | 895 | enum GNUNET_CADET_ChannelOption flags; |
876 | unsigned long i; | 896 | unsigned long i; |
877 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
878 | 897 | ||
879 | test_task = NULL; | 898 | test_task = NULL; |
880 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
881 | if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0) | ||
882 | return; | ||
883 | |||
884 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start profiler\n"); | 899 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start profiler\n"); |
885 | 900 | ||
886 | flags = GNUNET_CADET_OPTION_DEFAULT; | 901 | flags = GNUNET_CADET_OPTION_DEFAULT; |
@@ -909,7 +924,9 @@ start_test (void *cls) | |||
909 | number_rounds + 1), | 924 | number_rounds + 1), |
910 | &disconnect_cadet_peers, | 925 | &disconnect_cadet_peers, |
911 | (void *) __LINE__); | 926 | (void *) __LINE__); |
912 | GNUNET_SCHEDULER_add_delayed (round_time, &next_rnd, NULL); | 927 | round_task = GNUNET_SCHEDULER_add_delayed (round_time, |
928 | &next_rnd, | ||
929 | NULL); | ||
913 | } | 930 | } |
914 | 931 | ||
915 | 932 | ||
@@ -939,6 +956,7 @@ warmup (void) | |||
939 | } | 956 | } |
940 | } | 957 | } |
941 | 958 | ||
959 | |||
942 | /** | 960 | /** |
943 | * Callback to be called when the requested peer information is available | 961 | * Callback to be called when the requested peer information is available |
944 | * | 962 | * |
@@ -950,9 +968,9 @@ warmup (void) | |||
950 | */ | 968 | */ |
951 | static void | 969 | static void |
952 | peer_id_cb (void *cls, | 970 | peer_id_cb (void *cls, |
953 | struct GNUNET_TESTBED_Operation *op, | 971 | struct GNUNET_TESTBED_Operation *op, |
954 | const struct GNUNET_TESTBED_PeerInformation *pinfo, | 972 | const struct GNUNET_TESTBED_PeerInformation *pinfo, |
955 | const char *emsg) | 973 | const char *emsg) |
956 | { | 974 | { |
957 | long n = (long) cls; | 975 | long n = (long) cls; |
958 | 976 | ||
@@ -991,6 +1009,7 @@ peer_id_cb (void *cls, | |||
991 | &start_test, NULL); | 1009 | &start_test, NULL); |
992 | } | 1010 | } |
993 | 1011 | ||
1012 | |||
994 | /** | 1013 | /** |
995 | * test main: start test when all peers are connected | 1014 | * test main: start test when all peers are connected |
996 | * | 1015 | * |
@@ -1009,7 +1028,8 @@ tmain (void *cls, | |||
1009 | { | 1028 | { |
1010 | unsigned long i; | 1029 | unsigned long i; |
1011 | 1030 | ||
1012 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test main\n"); | 1031 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1032 | "test main\n"); | ||
1013 | test_ctx = ctx; | 1033 | test_ctx = ctx; |
1014 | GNUNET_assert (peers_total == num_peers); | 1034 | GNUNET_assert (peers_total == num_peers); |
1015 | peers_running = num_peers; | 1035 | peers_running = num_peers; |
@@ -1017,11 +1037,12 @@ tmain (void *cls, | |||
1017 | disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME, | 1037 | disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME, |
1018 | &disconnect_cadet_peers, | 1038 | &disconnect_cadet_peers, |
1019 | (void *) __LINE__); | 1039 | (void *) __LINE__); |
1020 | shutdown_handle = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1040 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
1021 | &shutdown_task, NULL); | ||
1022 | for (i = 0; i < peers_total; i++) | 1041 | for (i = 0; i < peers_total; i++) |
1023 | { | 1042 | { |
1024 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requesting id %ld\n", i); | 1043 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1044 | "requesting id %ld\n", | ||
1045 | i); | ||
1025 | peers[i].up = GNUNET_YES; | 1046 | peers[i].up = GNUNET_YES; |
1026 | peers[i].cadet = cadetes[i]; | 1047 | peers[i].cadet = cadetes[i]; |
1027 | peers[i].op = | 1048 | peers[i].op = |
@@ -1047,25 +1068,35 @@ main (int argc, char *argv[]) | |||
1047 | 1068 | ||
1048 | if (4 > argc) | 1069 | if (4 > argc) |
1049 | { | 1070 | { |
1050 | fprintf (stderr, "usage: %s ROUND_TIME PEERS PINGS [DO_WARMUP]\n", argv[0]); | 1071 | fprintf (stderr, |
1051 | fprintf (stderr, "example: %s 30s 16 1 Y\n", argv[0]); | 1072 | "usage: %s ROUND_TIME PEERS PINGS [DO_WARMUP]\n", |
1073 | argv[0]); | ||
1074 | fprintf (stderr, | ||
1075 | "example: %s 30s 16 1 Y\n", | ||
1076 | argv[0]); | ||
1052 | return 1; | 1077 | return 1; |
1053 | } | 1078 | } |
1054 | 1079 | ||
1055 | if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative (argv[1], &round_time)) | 1080 | if (GNUNET_OK != |
1081 | GNUNET_STRINGS_fancy_time_to_relative (argv[1], | ||
1082 | &round_time)) | ||
1056 | { | 1083 | { |
1057 | fprintf (stderr, "%s is not a valid time\n", argv[1]); | 1084 | fprintf (stderr, |
1085 | "%s is not a valid time\n", | ||
1086 | argv[1]); | ||
1058 | return 1; | 1087 | return 1; |
1059 | } | 1088 | } |
1060 | 1089 | ||
1061 | peers_total = atoll (argv[2]); | 1090 | peers_total = atoll (argv[2]); |
1062 | if (2 > peers_total) | 1091 | if (2 > peers_total) |
1063 | { | 1092 | { |
1064 | fprintf (stderr, "%s peers is not valid (> 2)\n", argv[1]); | 1093 | fprintf (stderr, |
1094 | "%s peers is not valid (> 2)\n", | ||
1095 | argv[1]); | ||
1065 | return 1; | 1096 | return 1; |
1066 | } | 1097 | } |
1067 | peers = GNUNET_malloc (sizeof (struct CadetPeer) * peers_total); | 1098 | peers = GNUNET_new_array (peers_total, |
1068 | 1099 | struct CadetPeer); | |
1069 | peers_pinging = atoll (argv[3]); | 1100 | peers_pinging = atoll (argv[3]); |
1070 | 1101 | ||
1071 | if (peers_total < 2 * peers_pinging) | 1102 | if (peers_total < 2 * peers_pinging) |
@@ -1077,7 +1108,8 @@ main (int argc, char *argv[]) | |||
1077 | 1108 | ||
1078 | do_warmup = (5 > argc || argv[4][0] != 'N'); | 1109 | do_warmup = (5 > argc || argv[4][0] != 'N'); |
1079 | 1110 | ||
1080 | ids = GNUNET_CONTAINER_multipeermap_create (2 * peers_total, GNUNET_YES); | 1111 | ids = GNUNET_CONTAINER_multipeermap_create (2 * peers_total, |
1112 | GNUNET_YES); | ||
1081 | GNUNET_assert (NULL != ids); | 1113 | GNUNET_assert (NULL != ids); |
1082 | p_ids = 0; | 1114 | p_ids = 0; |
1083 | test_finished = GNUNET_NO; | 1115 | test_finished = GNUNET_NO; |
diff --git a/src/cadet/gnunet-cadet.c b/src/cadet/gnunet-cadet.c index 14b499aae..6453392d8 100644 --- a/src/cadet/gnunet-cadet.c +++ b/src/cadet/gnunet-cadet.c | |||
@@ -72,22 +72,22 @@ static uint32_t listen_port; | |||
72 | /** | 72 | /** |
73 | * Request echo service | 73 | * Request echo service |
74 | */ | 74 | */ |
75 | int echo; | 75 | static int echo; |
76 | 76 | ||
77 | /** | 77 | /** |
78 | * Request a debug dump | 78 | * Request a debug dump |
79 | */ | 79 | */ |
80 | int dump; | 80 | static int dump; |
81 | 81 | ||
82 | /** | 82 | /** |
83 | * Time of last echo request. | 83 | * Time of last echo request. |
84 | */ | 84 | */ |
85 | struct GNUNET_TIME_Absolute echo_time; | 85 | static struct GNUNET_TIME_Absolute echo_time; |
86 | 86 | ||
87 | /** | 87 | /** |
88 | * Task for next echo request. | 88 | * Task for next echo request. |
89 | */ | 89 | */ |
90 | struct GNUNET_SCHEDULER_Task * echo_task; | 90 | static struct GNUNET_SCHEDULER_Task *echo_task; |
91 | 91 | ||
92 | /** | 92 | /** |
93 | * Peer to connect to. | 93 | * Peer to connect to. |
@@ -102,8 +102,7 @@ static uint32_t target_port; | |||
102 | /** | 102 | /** |
103 | * Data pending in netcat mode. | 103 | * Data pending in netcat mode. |
104 | */ | 104 | */ |
105 | size_t data_size; | 105 | static size_t data_size; |
106 | |||
107 | 106 | ||
108 | /** | 107 | /** |
109 | * Cadet handle. | 108 | * Cadet handle. |
@@ -123,8 +122,17 @@ static struct GNUNET_CADET_TransmitHandle *th; | |||
123 | /** | 122 | /** |
124 | * Shutdown task handle. | 123 | * Shutdown task handle. |
125 | */ | 124 | */ |
126 | struct GNUNET_SCHEDULER_Task * sd; | 125 | static struct GNUNET_SCHEDULER_Task *sd; |
127 | 126 | ||
127 | /** | ||
128 | * Task for reading from stdin. | ||
129 | */ | ||
130 | static struct GNUNET_SCHEDULER_Task *rd_task; | ||
131 | |||
132 | /** | ||
133 | * Task for main job. | ||
134 | */ | ||
135 | static struct GNUNET_SCHEDULER_Task *job; | ||
128 | 136 | ||
129 | 137 | ||
130 | static void | 138 | static void |
@@ -195,7 +203,8 @@ conn_2s (uint16_t status) | |||
195 | static void | 203 | static void |
196 | shutdown_task (void *cls) | 204 | shutdown_task (void *cls) |
197 | { | 205 | { |
198 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown\n"); | 206 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
207 | "Shutdown\n"); | ||
199 | if (NULL != th) | 208 | if (NULL != th) |
200 | { | 209 | { |
201 | GNUNET_CADET_notify_transmit_ready_cancel (th); | 210 | GNUNET_CADET_notify_transmit_ready_cancel (th); |
@@ -209,7 +218,22 @@ shutdown_task (void *cls) | |||
209 | if (NULL != mh) | 218 | if (NULL != mh) |
210 | { | 219 | { |
211 | GNUNET_CADET_disconnect (mh); | 220 | GNUNET_CADET_disconnect (mh); |
212 | mh = NULL; | 221 | mh = NULL; |
222 | } | ||
223 | if (NULL != rd_task) | ||
224 | { | ||
225 | GNUNET_SCHEDULER_cancel (rd_task); | ||
226 | rd_task = NULL; | ||
227 | } | ||
228 | if (NULL != echo_task) | ||
229 | { | ||
230 | GNUNET_SCHEDULER_cancel (echo_task); | ||
231 | echo_task = NULL; | ||
232 | } | ||
233 | if (NULL != job) | ||
234 | { | ||
235 | GNUNET_SCHEDULER_cancel (job); | ||
236 | job = NULL; | ||
213 | } | 237 | } |
214 | } | 238 | } |
215 | 239 | ||
@@ -227,7 +251,7 @@ shutdown_task (void *cls) | |||
227 | * @param buf where the callee should write the message | 251 | * @param buf where the callee should write the message |
228 | * @return number of bytes written to buf | 252 | * @return number of bytes written to buf |
229 | */ | 253 | */ |
230 | size_t | 254 | static size_t |
231 | data_ready (void *cls, size_t size, void *buf) | 255 | data_ready (void *cls, size_t size, void *buf) |
232 | { | 256 | { |
233 | struct GNUNET_MessageHeader *msg; | 257 | struct GNUNET_MessageHeader *msg; |
@@ -271,13 +295,6 @@ static void | |||
271 | read_stdio (void *cls) | 295 | read_stdio (void *cls) |
272 | { | 296 | { |
273 | static char buf[60000]; | 297 | static char buf[60000]; |
274 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
275 | |||
276 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
277 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
278 | { | ||
279 | return; | ||
280 | } | ||
281 | 298 | ||
282 | data_size = read (0, buf, 60000); | 299 | data_size = read (0, buf, 60000); |
283 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "stdio read %u bytes\n", data_size); | 300 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "stdio read %u bytes\n", data_size); |
@@ -305,10 +322,10 @@ listen_stdio (void) | |||
305 | 322 | ||
306 | rs = GNUNET_NETWORK_fdset_create (); | 323 | rs = GNUNET_NETWORK_fdset_create (); |
307 | GNUNET_NETWORK_fdset_set_native (rs, 0); | 324 | GNUNET_NETWORK_fdset_set_native (rs, 0); |
308 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, | 325 | rd_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
309 | GNUNET_TIME_UNIT_FOREVER_REL, | 326 | GNUNET_TIME_UNIT_FOREVER_REL, |
310 | rs, NULL, | 327 | rs, NULL, |
311 | &read_stdio, NULL); | 328 | &read_stdio, NULL); |
312 | GNUNET_NETWORK_fdset_destroy (rs); | 329 | GNUNET_NETWORK_fdset_destroy (rs); |
313 | } | 330 | } |
314 | 331 | ||
@@ -408,12 +425,8 @@ channel_incoming (void *cls, | |||
408 | static void | 425 | static void |
409 | send_echo (void *cls) | 426 | send_echo (void *cls) |
410 | { | 427 | { |
411 | const struct GNUNET_SCHEDULER_TaskContext *tc; | 428 | if (NULL == ch) |
412 | |||
413 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
414 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) || NULL == ch) | ||
415 | return; | 429 | return; |
416 | |||
417 | GNUNET_assert (NULL == th); | 430 | GNUNET_assert (NULL == th); |
418 | th = GNUNET_CADET_notify_transmit_ready (ch, GNUNET_NO, | 431 | th = GNUNET_CADET_notify_transmit_ready (ch, GNUNET_NO, |
419 | GNUNET_TIME_UNIT_FOREVER_REL, | 432 | GNUNET_TIME_UNIT_FOREVER_REL, |
@@ -432,7 +445,8 @@ request_dump (void *cls) | |||
432 | { | 445 | { |
433 | GNUNET_CADET_request_dump (mh); | 446 | GNUNET_CADET_request_dump (mh); |
434 | GNUNET_SCHEDULER_cancel (sd); | 447 | GNUNET_SCHEDULER_cancel (sd); |
435 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &shutdown_task, NULL); | 448 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
449 | &shutdown_task, NULL); | ||
436 | } | 450 | } |
437 | 451 | ||
438 | 452 | ||
@@ -466,7 +480,7 @@ create_channel (void *cls) | |||
466 | if (GNUNET_NO == echo) | 480 | if (GNUNET_NO == echo) |
467 | listen_stdio (); | 481 | listen_stdio (); |
468 | else | 482 | else |
469 | GNUNET_SCHEDULER_add_now (send_echo, NULL); | 483 | echo_task = GNUNET_SCHEDULER_add_now (&send_echo, NULL); |
470 | } | 484 | } |
471 | 485 | ||
472 | 486 | ||
@@ -561,8 +575,11 @@ data_callback (void *cls, | |||
561 | * (0 = unknown, 1 = ourselves, 2 = neighbor) | 575 | * (0 = unknown, 1 = ourselves, 2 = neighbor) |
562 | */ | 576 | */ |
563 | static void | 577 | static void |
564 | peers_callback (void *cls, const struct GNUNET_PeerIdentity *peer, | 578 | peers_callback (void *cls, |
565 | int tunnel, unsigned int n_paths, unsigned int best_path) | 579 | const struct GNUNET_PeerIdentity *peer, |
580 | int tunnel, | ||
581 | unsigned int n_paths, | ||
582 | unsigned int best_path) | ||
566 | { | 583 | { |
567 | if (NULL == peer) | 584 | if (NULL == peer) |
568 | { | 585 | { |
@@ -589,7 +606,7 @@ peers_callback (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
589 | * Each path starts with the local peer. | 606 | * Each path starts with the local peer. |
590 | * Each path ends with the destination peer (given in @c peer). | 607 | * Each path ends with the destination peer (given in @c peer). |
591 | */ | 608 | */ |
592 | void | 609 | static void |
593 | peer_callback (void *cls, | 610 | peer_callback (void *cls, |
594 | const struct GNUNET_PeerIdentity *peer, | 611 | const struct GNUNET_PeerIdentity *peer, |
595 | int tunnel, | 612 | int tunnel, |
@@ -629,7 +646,7 @@ peer_callback (void *cls, | |||
629 | * @param estate Encryption state. | 646 | * @param estate Encryption state. |
630 | * @param cstate Connectivity state. | 647 | * @param cstate Connectivity state. |
631 | */ | 648 | */ |
632 | void | 649 | static void |
633 | tunnels_callback (void *cls, | 650 | tunnels_callback (void *cls, |
634 | const struct GNUNET_PeerIdentity *peer, | 651 | const struct GNUNET_PeerIdentity *peer, |
635 | unsigned int channels, | 652 | unsigned int channels, |
@@ -665,7 +682,7 @@ tunnels_callback (void *cls, | |||
665 | * @param estate Encryption status. | 682 | * @param estate Encryption status. |
666 | * @param cstate Connectivity status. | 683 | * @param cstate Connectivity status. |
667 | */ | 684 | */ |
668 | void | 685 | static void |
669 | tunnel_callback (void *cls, | 686 | tunnel_callback (void *cls, |
670 | const struct GNUNET_PeerIdentity *peer, | 687 | const struct GNUNET_PeerIdentity *peer, |
671 | unsigned int n_channels, | 688 | unsigned int n_channels, |
@@ -691,7 +708,7 @@ tunnel_callback (void *cls, | |||
691 | } | 708 | } |
692 | if (GNUNET_YES != monitor_mode) | 709 | if (GNUNET_YES != monitor_mode) |
693 | { | 710 | { |
694 | GNUNET_SCHEDULER_shutdown(); | 711 | GNUNET_SCHEDULER_shutdown (); |
695 | } | 712 | } |
696 | return; | 713 | return; |
697 | } | 714 | } |
@@ -705,14 +722,7 @@ tunnel_callback (void *cls, | |||
705 | static void | 722 | static void |
706 | get_peers (void *cls) | 723 | get_peers (void *cls) |
707 | { | 724 | { |
708 | const struct GNUNET_SCHEDULER_TaskContext *tc; | 725 | job = NULL; |
709 | |||
710 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
711 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
712 | { | ||
713 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown\n"); | ||
714 | return; | ||
715 | } | ||
716 | GNUNET_CADET_get_peers (mh, &peers_callback, NULL); | 726 | GNUNET_CADET_get_peers (mh, &peers_callback, NULL); |
717 | } | 727 | } |
718 | 728 | ||
@@ -727,6 +737,7 @@ show_peer (void *cls) | |||
727 | { | 737 | { |
728 | struct GNUNET_PeerIdentity pid; | 738 | struct GNUNET_PeerIdentity pid; |
729 | 739 | ||
740 | job = NULL; | ||
730 | if (GNUNET_OK != | 741 | if (GNUNET_OK != |
731 | GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id, | 742 | GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id, |
732 | strlen (peer_id), | 743 | strlen (peer_id), |
@@ -741,6 +752,7 @@ show_peer (void *cls) | |||
741 | GNUNET_CADET_get_peer (mh, &pid, peer_callback, NULL); | 752 | GNUNET_CADET_get_peer (mh, &pid, peer_callback, NULL); |
742 | } | 753 | } |
743 | 754 | ||
755 | |||
744 | /** | 756 | /** |
745 | * Call CADET's meta API, get all tunnels known to a peer. | 757 | * Call CADET's meta API, get all tunnels known to a peer. |
746 | * | 758 | * |
@@ -749,14 +761,7 @@ show_peer (void *cls) | |||
749 | static void | 761 | static void |
750 | get_tunnels (void *cls) | 762 | get_tunnels (void *cls) |
751 | { | 763 | { |
752 | const struct GNUNET_SCHEDULER_TaskContext *tc; | 764 | job = NULL; |
753 | |||
754 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
755 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
756 | { | ||
757 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown\n"); | ||
758 | return; | ||
759 | } | ||
760 | GNUNET_CADET_get_tunnels (mh, &tunnels_callback, NULL); | 765 | GNUNET_CADET_get_tunnels (mh, &tunnels_callback, NULL); |
761 | } | 766 | } |
762 | 767 | ||
@@ -779,7 +784,7 @@ show_tunnel (void *cls) | |||
779 | fprintf (stderr, | 784 | fprintf (stderr, |
780 | _("Invalid tunnel owner `%s'\n"), | 785 | _("Invalid tunnel owner `%s'\n"), |
781 | tunnel_id); | 786 | tunnel_id); |
782 | GNUNET_SCHEDULER_shutdown(); | 787 | GNUNET_SCHEDULER_shutdown (); |
783 | return; | 788 | return; |
784 | } | 789 | } |
785 | GNUNET_CADET_get_tunnel (mh, &pid, tunnel_callback, NULL); | 790 | GNUNET_CADET_get_tunnel (mh, &pid, tunnel_callback, NULL); |
@@ -794,7 +799,8 @@ show_tunnel (void *cls) | |||
794 | static void | 799 | static void |
795 | show_channel (void *cls) | 800 | show_channel (void *cls) |
796 | { | 801 | { |
797 | 802 | job = NULL; | |
803 | GNUNET_break (0); | ||
798 | } | 804 | } |
799 | 805 | ||
800 | 806 | ||
@@ -806,7 +812,8 @@ show_channel (void *cls) | |||
806 | static void | 812 | static void |
807 | show_connection (void *cls) | 813 | show_connection (void *cls) |
808 | { | 814 | { |
809 | 815 | job = NULL; | |
816 | GNUNET_break (0); | ||
810 | } | 817 | } |
811 | 818 | ||
812 | 819 | ||
@@ -819,7 +826,9 @@ show_connection (void *cls) | |||
819 | * @param cfg configuration | 826 | * @param cfg configuration |
820 | */ | 827 | */ |
821 | static void | 828 | static void |
822 | run (void *cls, char *const *args, const char *cfgfile, | 829 | run (void *cls, |
830 | char *const *args, | ||
831 | const char *cfgfile, | ||
823 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 832 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
824 | { | 833 | { |
825 | GNUNET_CADET_InboundChannelNotificationHandler *newch = NULL; | 834 | GNUNET_CADET_InboundChannelNotificationHandler *newch = NULL; |
@@ -871,32 +880,32 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
871 | else if (NULL != peer_id) | 880 | else if (NULL != peer_id) |
872 | { | 881 | { |
873 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show peer\n"); | 882 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show peer\n"); |
874 | GNUNET_SCHEDULER_add_now (&show_peer, NULL); | 883 | job = GNUNET_SCHEDULER_add_now (&show_peer, NULL); |
875 | } | 884 | } |
876 | else if (NULL != tunnel_id) | 885 | else if (NULL != tunnel_id) |
877 | { | 886 | { |
878 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show tunnel\n"); | 887 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show tunnel\n"); |
879 | GNUNET_SCHEDULER_add_now (&show_tunnel, NULL); | 888 | job = GNUNET_SCHEDULER_add_now (&show_tunnel, NULL); |
880 | } | 889 | } |
881 | else if (NULL != channel_id) | 890 | else if (NULL != channel_id) |
882 | { | 891 | { |
883 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show channel\n"); | 892 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show channel\n"); |
884 | GNUNET_SCHEDULER_add_now (&show_channel, NULL); | 893 | job = GNUNET_SCHEDULER_add_now (&show_channel, NULL); |
885 | } | 894 | } |
886 | else if (NULL != conn_id) | 895 | else if (NULL != conn_id) |
887 | { | 896 | { |
888 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show connection\n"); | 897 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show connection\n"); |
889 | GNUNET_SCHEDULER_add_now (&show_connection, NULL); | 898 | job = GNUNET_SCHEDULER_add_now (&show_connection, NULL); |
890 | } | 899 | } |
891 | else if (GNUNET_YES == request_peers) | 900 | else if (GNUNET_YES == request_peers) |
892 | { | 901 | { |
893 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show all peers\n"); | 902 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show all peers\n"); |
894 | GNUNET_SCHEDULER_add_now (&get_peers, NULL); | 903 | job = GNUNET_SCHEDULER_add_now (&get_peers, NULL); |
895 | } | 904 | } |
896 | else if (GNUNET_YES == request_tunnels) | 905 | else if (GNUNET_YES == request_tunnels) |
897 | { | 906 | { |
898 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show all tunnels\n"); | 907 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show all tunnels\n"); |
899 | GNUNET_SCHEDULER_add_now (&get_tunnels, NULL); | 908 | job = GNUNET_SCHEDULER_add_now (&get_tunnels, NULL); |
900 | } | 909 | } |
901 | else | 910 | else |
902 | { | 911 | { |
@@ -913,11 +922,9 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
913 | ports); | 922 | ports); |
914 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Done\n"); | 923 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Done\n"); |
915 | if (NULL == mh) | 924 | if (NULL == mh) |
916 | GNUNET_SCHEDULER_add_now (shutdown_task, NULL); | 925 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); |
917 | else | 926 | else |
918 | sd = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 927 | sd = GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
919 | shutdown_task, NULL); | ||
920 | |||
921 | } | 928 | } |
922 | 929 | ||
923 | 930 | ||
diff --git a/src/cadet/gnunet-service-cadet.c b/src/cadet/gnunet-service-cadet.c index a2e00300b..3a07f0ee5 100644 --- a/src/cadet/gnunet-service-cadet.c +++ b/src/cadet/gnunet-service-cadet.c | |||
@@ -135,8 +135,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
135 | stats = GNUNET_STATISTICS_create ("cadet", c); | 135 | stats = GNUNET_STATISTICS_create ("cadet", c); |
136 | 136 | ||
137 | /* Scheduled the task to clean up when shutdown is called */ | 137 | /* Scheduled the task to clean up when shutdown is called */ |
138 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 138 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
139 | NULL); | 139 | NULL); |
140 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "reading key\n"); | 140 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "reading key\n"); |
141 | my_private_key = GNUNET_CRYPTO_eddsa_key_create_from_configuration (c); | 141 | my_private_key = GNUNET_CRYPTO_eddsa_key_create_from_configuration (c); |
142 | GNUNET_assert (NULL != my_private_key); | 142 | GNUNET_assert (NULL != my_private_key); |
diff --git a/src/cadet/gnunet-service-cadet_channel.c b/src/cadet/gnunet-service-cadet_channel.c index debae7d77..d4f9754da 100644 --- a/src/cadet/gnunet-service-cadet_channel.c +++ b/src/cadet/gnunet-service-cadet_channel.c | |||
@@ -730,13 +730,8 @@ channel_retransmit_message (void *cls) | |||
730 | struct CadetChannel *ch; | 730 | struct CadetChannel *ch; |
731 | struct GNUNET_CADET_Data *payload; | 731 | struct GNUNET_CADET_Data *payload; |
732 | int fwd; | 732 | int fwd; |
733 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
734 | 733 | ||
735 | rel->retry_task = NULL; | 734 | rel->retry_task = NULL; |
736 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
737 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
738 | return; | ||
739 | |||
740 | ch = rel->ch; | 735 | ch = rel->ch; |
741 | copy = rel->head_sent; | 736 | copy = rel->head_sent; |
742 | if (NULL == copy) | 737 | if (NULL == copy) |
@@ -765,15 +760,11 @@ static void | |||
765 | channel_recreate (void *cls) | 760 | channel_recreate (void *cls) |
766 | { | 761 | { |
767 | struct CadetChannelReliability *rel = cls; | 762 | struct CadetChannelReliability *rel = cls; |
768 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
769 | 763 | ||
770 | rel->retry_task = NULL; | 764 | rel->retry_task = NULL; |
771 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
772 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
773 | return; | ||
774 | |||
775 | LOG (GNUNET_ERROR_TYPE_DEBUG, "RE-CREATE\n"); | 765 | LOG (GNUNET_ERROR_TYPE_DEBUG, "RE-CREATE\n"); |
776 | GNUNET_STATISTICS_update (stats, "# data retransmitted", 1, GNUNET_NO); | 766 | GNUNET_STATISTICS_update (stats, |
767 | "# data retransmitted", 1, GNUNET_NO); | ||
777 | 768 | ||
778 | if (rel == rel->ch->root_rel) | 769 | if (rel == rel->ch->root_rel) |
779 | { | 770 | { |
@@ -787,7 +778,6 @@ channel_recreate (void *cls) | |||
787 | { | 778 | { |
788 | GNUNET_break (0); | 779 | GNUNET_break (0); |
789 | } | 780 | } |
790 | |||
791 | } | 781 | } |
792 | 782 | ||
793 | 783 | ||
diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c index d11368a79..188041feb 100644 --- a/src/cadet/gnunet-service-cadet_connection.c +++ b/src/cadet/gnunet-service-cadet_connection.c | |||
@@ -1192,11 +1192,10 @@ connection_maintain (struct CadetConnection *c, int fwd) | |||
1192 | * | 1192 | * |
1193 | * @param c Connection to keep alive. | 1193 | * @param c Connection to keep alive. |
1194 | * @param fwd Direction. | 1194 | * @param fwd Direction. |
1195 | * @param shutdown Are we shutting down? (Don't send traffic) | ||
1196 | * Non-zero value for true, not necessarily GNUNET_YES. | ||
1197 | */ | 1195 | */ |
1198 | static void | 1196 | static void |
1199 | connection_keepalive (struct CadetConnection *c, int fwd, int shutdown) | 1197 | connection_keepalive (struct CadetConnection *c, |
1198 | int fwd) | ||
1200 | { | 1199 | { |
1201 | GCC_check_connections (); | 1200 | GCC_check_connections (); |
1202 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1201 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1207,10 +1206,6 @@ connection_keepalive (struct CadetConnection *c, int fwd, int shutdown) | |||
1207 | c->fwd_maintenance_task = NULL; | 1206 | c->fwd_maintenance_task = NULL; |
1208 | else | 1207 | else |
1209 | c->bck_maintenance_task = NULL; | 1208 | c->bck_maintenance_task = NULL; |
1210 | |||
1211 | if (GNUNET_NO != shutdown) | ||
1212 | return; | ||
1213 | |||
1214 | connection_maintain (c, fwd); | 1209 | connection_maintain (c, fwd); |
1215 | GCC_check_connections (); | 1210 | GCC_check_connections (); |
1216 | /* Next execution will be scheduled by message_sent or _maintain*/ | 1211 | /* Next execution will be scheduled by message_sent or _maintain*/ |
@@ -1225,13 +1220,11 @@ connection_keepalive (struct CadetConnection *c, int fwd, int shutdown) | |||
1225 | static void | 1220 | static void |
1226 | connection_fwd_keepalive (void *cls) | 1221 | connection_fwd_keepalive (void *cls) |
1227 | { | 1222 | { |
1228 | const struct GNUNET_SCHEDULER_TaskContext *tc; | 1223 | struct CadetConnection *c = cls; |
1229 | 1224 | ||
1230 | GCC_check_connections (); | 1225 | GCC_check_connections (); |
1231 | tc = GNUNET_SCHEDULER_get_task_context (); | 1226 | connection_keepalive (c, |
1232 | connection_keepalive ((struct CadetConnection *) cls, | 1227 | GNUNET_YES); |
1233 | GNUNET_YES, | ||
1234 | tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN); | ||
1235 | GCC_check_connections (); | 1228 | GCC_check_connections (); |
1236 | } | 1229 | } |
1237 | 1230 | ||
@@ -1244,13 +1237,11 @@ connection_fwd_keepalive (void *cls) | |||
1244 | static void | 1237 | static void |
1245 | connection_bck_keepalive (void *cls) | 1238 | connection_bck_keepalive (void *cls) |
1246 | { | 1239 | { |
1247 | const struct GNUNET_SCHEDULER_TaskContext *tc; | 1240 | struct CadetConnection *c = cls; |
1248 | 1241 | ||
1249 | GCC_check_connections (); | 1242 | GCC_check_connections (); |
1250 | tc = GNUNET_SCHEDULER_get_task_context (); | 1243 | connection_keepalive (c, |
1251 | connection_keepalive ((struct CadetConnection *) cls, | 1244 | GNUNET_NO); |
1252 | GNUNET_NO, | ||
1253 | tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN); | ||
1254 | GCC_check_connections (); | 1245 | GCC_check_connections (); |
1255 | } | 1246 | } |
1256 | 1247 | ||
@@ -1461,16 +1452,9 @@ connection_poll (void *cls) | |||
1461 | struct GNUNET_CADET_Poll msg; | 1452 | struct GNUNET_CADET_Poll msg; |
1462 | struct CadetConnection *c; | 1453 | struct CadetConnection *c; |
1463 | int fwd; | 1454 | int fwd; |
1464 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
1465 | 1455 | ||
1466 | fc->poll_task = NULL; | 1456 | fc->poll_task = NULL; |
1467 | GCC_check_connections (); | 1457 | GCC_check_connections (); |
1468 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
1469 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
1470 | { | ||
1471 | return; | ||
1472 | } | ||
1473 | |||
1474 | c = fc->c; | 1458 | c = fc->c; |
1475 | fwd = fc == &c->fwd_fc; | 1459 | fwd = fc == &c->fwd_fc; |
1476 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Polling connection %s %s\n", | 1460 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Polling connection %s %s\n", |
@@ -1592,12 +1576,8 @@ static void | |||
1592 | connection_fwd_timeout (void *cls) | 1576 | connection_fwd_timeout (void *cls) |
1593 | { | 1577 | { |
1594 | struct CadetConnection *c = cls; | 1578 | struct CadetConnection *c = cls; |
1595 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
1596 | 1579 | ||
1597 | c->fwd_maintenance_task = NULL; | 1580 | c->fwd_maintenance_task = NULL; |
1598 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
1599 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
1600 | return; | ||
1601 | GCC_check_connections (); | 1581 | GCC_check_connections (); |
1602 | connection_timeout (c, GNUNET_YES); | 1582 | connection_timeout (c, GNUNET_YES); |
1603 | GCC_check_connections (); | 1583 | GCC_check_connections (); |
@@ -1614,12 +1594,8 @@ static void | |||
1614 | connection_bck_timeout (void *cls) | 1594 | connection_bck_timeout (void *cls) |
1615 | { | 1595 | { |
1616 | struct CadetConnection *c = cls; | 1596 | struct CadetConnection *c = cls; |
1617 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
1618 | 1597 | ||
1619 | c->bck_maintenance_task = NULL; | 1598 | c->bck_maintenance_task = NULL; |
1620 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
1621 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
1622 | return; | ||
1623 | GCC_check_connections (); | 1599 | GCC_check_connections (); |
1624 | connection_timeout (c, GNUNET_NO); | 1600 | connection_timeout (c, GNUNET_NO); |
1625 | GCC_check_connections (); | 1601 | GCC_check_connections (); |
@@ -1767,13 +1743,8 @@ static void | |||
1767 | check_duplicates (void *cls) | 1743 | check_duplicates (void *cls) |
1768 | { | 1744 | { |
1769 | struct CadetConnection *c = cls; | 1745 | struct CadetConnection *c = cls; |
1770 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
1771 | 1746 | ||
1772 | c->check_duplicates_task = NULL; | 1747 | c->check_duplicates_task = NULL; |
1773 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
1774 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
1775 | return; | ||
1776 | |||
1777 | if (GNUNET_YES == does_connection_exist (c)) | 1748 | if (GNUNET_YES == does_connection_exist (c)) |
1778 | { | 1749 | { |
1779 | GCT_debug (c->t, GNUNET_ERROR_TYPE_DEBUG); | 1750 | GCT_debug (c->t, GNUNET_ERROR_TYPE_DEBUG); |
@@ -1783,7 +1754,6 @@ check_duplicates (void *cls) | |||
1783 | } | 1754 | } |
1784 | 1755 | ||
1785 | 1756 | ||
1786 | |||
1787 | /** | 1757 | /** |
1788 | * Wait for enough time to let any dead connections time out and check for | 1758 | * Wait for enough time to let any dead connections time out and check for |
1789 | * any remaining duplicates. | 1759 | * any remaining duplicates. |
@@ -1797,7 +1767,6 @@ schedule_check_duplicates (struct CadetConnection *c) | |||
1797 | 1767 | ||
1798 | if (NULL != c->check_duplicates_task) | 1768 | if (NULL != c->check_duplicates_task) |
1799 | return; | 1769 | return; |
1800 | |||
1801 | delay = GNUNET_TIME_relative_multiply (refresh_connection_time, 5); | 1770 | delay = GNUNET_TIME_relative_multiply (refresh_connection_time, 5); |
1802 | c->check_duplicates_task = GNUNET_SCHEDULER_add_delayed (delay, | 1771 | c->check_duplicates_task = GNUNET_SCHEDULER_add_delayed (delay, |
1803 | &check_duplicates, | 1772 | &check_duplicates, |
@@ -1805,7 +1774,6 @@ schedule_check_duplicates (struct CadetConnection *c) | |||
1805 | } | 1774 | } |
1806 | 1775 | ||
1807 | 1776 | ||
1808 | |||
1809 | /** | 1777 | /** |
1810 | * Add the connection to the list of both neighbors. | 1778 | * Add the connection to the list of both neighbors. |
1811 | * | 1779 | * |
@@ -1903,7 +1871,8 @@ unregister_neighbors (struct CadetConnection *c) | |||
1903 | * @param disconnected Peer that disconnected. | 1871 | * @param disconnected Peer that disconnected. |
1904 | */ | 1872 | */ |
1905 | static void | 1873 | static void |
1906 | invalidate_paths (struct CadetConnection *c, struct CadetPeer *disconnected) | 1874 | invalidate_paths (struct CadetConnection *c, |
1875 | struct CadetPeer *disconnected) | ||
1907 | { | 1876 | { |
1908 | struct CadetPeer *peer; | 1877 | struct CadetPeer *peer; |
1909 | unsigned int i; | 1878 | unsigned int i; |
diff --git a/src/cadet/gnunet-service-cadet_dht.c b/src/cadet/gnunet-service-cadet_dht.c index 088d40eac..88a601b52 100644 --- a/src/cadet/gnunet-service-cadet_dht.c +++ b/src/cadet/gnunet-service-cadet_dht.c | |||
@@ -215,14 +215,8 @@ announce_id (void *cls) | |||
215 | size_t size; | 215 | size_t size; |
216 | struct GNUNET_TIME_Absolute expiration; | 216 | struct GNUNET_TIME_Absolute expiration; |
217 | struct GNUNET_TIME_Relative retry_time; | 217 | struct GNUNET_TIME_Relative retry_time; |
218 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
219 | 218 | ||
220 | tc = GNUNET_SCHEDULER_get_task_context (); | 219 | announce_id_task = NULL; |
221 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
222 | { | ||
223 | announce_id_task = NULL; | ||
224 | return; | ||
225 | } | ||
226 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Announce ID\n"); | 220 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Announce ID\n"); |
227 | /* TODO | 221 | /* TODO |
228 | * - Set data expiration in function of X | 222 | * - Set data expiration in function of X |
diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c index 51af04527..46961250b 100644 --- a/src/cadet/gnunet-service-cadet_peer.c +++ b/src/cadet/gnunet-service-cadet_peer.c | |||
@@ -387,7 +387,6 @@ notify_broken (void *cls, | |||
387 | * Remove the direct path to the peer. | 387 | * Remove the direct path to the peer. |
388 | * | 388 | * |
389 | * @param peer Peer to remove the direct path from. | 389 | * @param peer Peer to remove the direct path from. |
390 | * | ||
391 | */ | 390 | */ |
392 | static struct CadetPeerPath * | 391 | static struct CadetPeerPath * |
393 | pop_direct_path (struct CadetPeer *peer) | 392 | pop_direct_path (struct CadetPeer *peer) |
@@ -398,7 +397,9 @@ pop_direct_path (struct CadetPeer *peer) | |||
398 | { | 397 | { |
399 | if (2 >= iter->length) | 398 | if (2 >= iter->length) |
400 | { | 399 | { |
401 | GNUNET_CONTAINER_DLL_remove (peer->path_head, peer->path_tail, iter); | 400 | GNUNET_CONTAINER_DLL_remove (peer->path_head, |
401 | peer->path_tail, | ||
402 | iter); | ||
402 | return iter; | 403 | return iter; |
403 | } | 404 | } |
404 | } | 405 | } |
@@ -750,7 +751,8 @@ peer_destroy (struct CadetPeer *peer) | |||
750 | "destroying peer %s\n", | 751 | "destroying peer %s\n", |
751 | GNUNET_i2s (&id)); | 752 | GNUNET_i2s (&id)); |
752 | 753 | ||
753 | if (GNUNET_YES != GNUNET_CONTAINER_multipeermap_remove (peers, &id, peer)) | 754 | if (GNUNET_YES != |
755 | GNUNET_CONTAINER_multipeermap_remove (peers, &id, peer)) | ||
754 | { | 756 | { |
755 | GNUNET_break (0); | 757 | GNUNET_break (0); |
756 | LOG (GNUNET_ERROR_TYPE_WARNING, " peer not in peermap!!\n"); | 758 | LOG (GNUNET_ERROR_TYPE_WARNING, " peer not in peermap!!\n"); |
@@ -846,12 +848,8 @@ static void | |||
846 | delayed_search (void *cls) | 848 | delayed_search (void *cls) |
847 | { | 849 | { |
848 | struct CadetPeer *peer = cls; | 850 | struct CadetPeer *peer = cls; |
849 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
850 | 851 | ||
851 | peer->search_delayed = NULL; | 852 | peer->search_delayed = NULL; |
852 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
853 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | ||
854 | return; | ||
855 | GCC_check_connections (); | 853 | GCC_check_connections (); |
856 | GCP_start_search (peer); | 854 | GCP_start_search (peer); |
857 | GCC_check_connections (); | 855 | GCC_check_connections (); |
@@ -1934,8 +1932,9 @@ GCP_get (const struct GNUNET_PeerIdentity *peer_id, int create) | |||
1934 | 1932 | ||
1935 | 1933 | ||
1936 | /** | 1934 | /** |
1937 | * Retrieve the CadetPeer stucture associated with the peer. Optionally create | 1935 | * Retrieve the CadetPeer stucture associated with the |
1938 | * one and insert it in the appropriate structures if the peer is not known yet. | 1936 | * peer. Optionally create one and insert it in the appropriate |
1937 | * structures if the peer is not known yet. | ||
1939 | * | 1938 | * |
1940 | * @param peer Short identity of the peer. | 1939 | * @param peer Short identity of the peer. |
1941 | * @param create #GNUNET_YES if a new peer should be created if unknown. | 1940 | * @param create #GNUNET_YES if a new peer should be created if unknown. |
@@ -2223,7 +2222,8 @@ GCP_add_path (struct CadetPeer *peer, | |||
2223 | } | 2222 | } |
2224 | } | 2223 | } |
2225 | } | 2224 | } |
2226 | GNUNET_CONTAINER_DLL_insert_tail (peer->path_head, peer->path_tail, | 2225 | GNUNET_CONTAINER_DLL_insert_tail (peer->path_head, |
2226 | peer->path_tail, | ||
2227 | path); | 2227 | path); |
2228 | LOG (GNUNET_ERROR_TYPE_DEBUG, " added last\n"); | 2228 | LOG (GNUNET_ERROR_TYPE_DEBUG, " added last\n"); |
2229 | 2229 | ||
@@ -2300,7 +2300,8 @@ GCP_add_path_to_all (const struct CadetPeerPath *p, int confirmed) | |||
2300 | * @param path Path to remove. Is always destroyed . | 2300 | * @param path Path to remove. Is always destroyed . |
2301 | */ | 2301 | */ |
2302 | void | 2302 | void |
2303 | GCP_remove_path (struct CadetPeer *peer, struct CadetPeerPath *path) | 2303 | GCP_remove_path (struct CadetPeer *peer, |
2304 | struct CadetPeerPath *path) | ||
2304 | { | 2305 | { |
2305 | struct CadetPeerPath *iter; | 2306 | struct CadetPeerPath *iter; |
2306 | struct CadetPeerPath *next; | 2307 | struct CadetPeerPath *next; |
@@ -2309,7 +2310,8 @@ GCP_remove_path (struct CadetPeer *peer, struct CadetPeerPath *path) | |||
2309 | GNUNET_assert (myid == path->peers[0]); | 2310 | GNUNET_assert (myid == path->peers[0]); |
2310 | GNUNET_assert (peer->id == path->peers[path->length - 1]); | 2311 | GNUNET_assert (peer->id == path->peers[path->length - 1]); |
2311 | 2312 | ||
2312 | LOG (GNUNET_ERROR_TYPE_INFO, "Removing path %p (%u) from %s\n", | 2313 | LOG (GNUNET_ERROR_TYPE_INFO, |
2314 | "Removing path %p (%u) from %s\n", | ||
2313 | path, path->length, GCP_2s (peer)); | 2315 | path, path->length, GCP_2s (peer)); |
2314 | 2316 | ||
2315 | for (iter = peer->path_head; NULL != iter; iter = next) | 2317 | for (iter = peer->path_head; NULL != iter; iter = next) |
@@ -2317,7 +2319,9 @@ GCP_remove_path (struct CadetPeer *peer, struct CadetPeerPath *path) | |||
2317 | next = iter->next; | 2319 | next = iter->next; |
2318 | if (0 == path_cmp (path, iter)) | 2320 | if (0 == path_cmp (path, iter)) |
2319 | { | 2321 | { |
2320 | GNUNET_CONTAINER_DLL_remove (peer->path_head, peer->path_tail, iter); | 2322 | GNUNET_CONTAINER_DLL_remove (peer->path_head, |
2323 | peer->path_tail, | ||
2324 | iter); | ||
2321 | if (iter != path) | 2325 | if (iter != path) |
2322 | path_destroy (iter); | 2326 | path_destroy (iter); |
2323 | } | 2327 | } |
@@ -2512,7 +2516,8 @@ GCP_get_tunnel (const struct CadetPeer *peer) | |||
2512 | * @param hello Hello message. | 2516 | * @param hello Hello message. |
2513 | */ | 2517 | */ |
2514 | void | 2518 | void |
2515 | GCP_set_hello (struct CadetPeer *peer, const struct GNUNET_HELLO_Message *hello) | 2519 | GCP_set_hello (struct CadetPeer *peer, |
2520 | const struct GNUNET_HELLO_Message *hello) | ||
2516 | { | 2521 | { |
2517 | struct GNUNET_HELLO_Message *old; | 2522 | struct GNUNET_HELLO_Message *old; |
2518 | size_t size; | 2523 | size_t size; |
diff --git a/src/cadet/gnunet-service-cadet_tunnel.c b/src/cadet/gnunet-service-cadet_tunnel.c index 73bd28643..b9f0e1fa2 100644 --- a/src/cadet/gnunet-service-cadet_tunnel.c +++ b/src/cadet/gnunet-service-cadet_tunnel.c | |||
@@ -1735,16 +1735,8 @@ static void | |||
1735 | finish_kx (void *cls) | 1735 | finish_kx (void *cls) |
1736 | { | 1736 | { |
1737 | struct CadetTunnel *t = cls; | 1737 | struct CadetTunnel *t = cls; |
1738 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
1739 | 1738 | ||
1740 | LOG (GNUNET_ERROR_TYPE_INFO, "finish KX for %s\n", GCT_2s (t)); | 1739 | LOG (GNUNET_ERROR_TYPE_INFO, "finish KX for %s\n", GCT_2s (t)); |
1741 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
1742 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
1743 | { | ||
1744 | LOG (GNUNET_ERROR_TYPE_INFO, " shutdown\n"); | ||
1745 | return; | ||
1746 | } | ||
1747 | |||
1748 | GNUNET_free (t->kx_ctx); | 1740 | GNUNET_free (t->kx_ctx); |
1749 | t->kx_ctx = NULL; | 1741 | t->kx_ctx = NULL; |
1750 | } | 1742 | } |
@@ -1767,14 +1759,15 @@ destroy_kx_ctx (struct CadetTunnel *t) | |||
1767 | 1759 | ||
1768 | if (is_key_null (&t->kx_ctx->e_key_old)) | 1760 | if (is_key_null (&t->kx_ctx->e_key_old)) |
1769 | { | 1761 | { |
1770 | t->kx_ctx->finish_task = GNUNET_SCHEDULER_add_now (finish_kx, t); | 1762 | t->kx_ctx->finish_task = GNUNET_SCHEDULER_add_now (&finish_kx, t); |
1771 | return; | 1763 | return; |
1772 | } | 1764 | } |
1773 | 1765 | ||
1774 | delay = GNUNET_TIME_relative_divide (rekey_period, 4); | 1766 | delay = GNUNET_TIME_relative_divide (rekey_period, 4); |
1775 | delay = GNUNET_TIME_relative_min (delay, GNUNET_TIME_UNIT_MINUTES); | 1767 | delay = GNUNET_TIME_relative_min (delay, GNUNET_TIME_UNIT_MINUTES); |
1776 | 1768 | ||
1777 | t->kx_ctx->finish_task = GNUNET_SCHEDULER_add_delayed (delay, finish_kx, t); | 1769 | t->kx_ctx->finish_task = GNUNET_SCHEDULER_add_delayed (delay, |
1770 | &finish_kx, t); | ||
1778 | } | 1771 | } |
1779 | 1772 | ||
1780 | 1773 | ||
@@ -2103,13 +2096,8 @@ static void | |||
2103 | ax_kx_resend (void *cls) | 2096 | ax_kx_resend (void *cls) |
2104 | { | 2097 | { |
2105 | struct CadetTunnel *t = cls; | 2098 | struct CadetTunnel *t = cls; |
2106 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
2107 | 2099 | ||
2108 | t->rekey_task = NULL; | 2100 | t->rekey_task = NULL; |
2109 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
2110 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
2111 | return; | ||
2112 | |||
2113 | if (CADET_TUNNEL_KEY_OK == t->estate) | 2101 | if (CADET_TUNNEL_KEY_OK == t->estate) |
2114 | { | 2102 | { |
2115 | /* Should have been canceled on estate change */ | 2103 | /* Should have been canceled on estate change */ |
@@ -2333,14 +2321,9 @@ static void | |||
2333 | rekey_tunnel (void *cls) | 2321 | rekey_tunnel (void *cls) |
2334 | { | 2322 | { |
2335 | struct CadetTunnel *t = cls; | 2323 | struct CadetTunnel *t = cls; |
2336 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
2337 | 2324 | ||
2338 | t->rekey_task = NULL; | 2325 | t->rekey_task = NULL; |
2339 | LOG (GNUNET_ERROR_TYPE_INFO, "Re-key Tunnel %s\n", GCT_2s (t)); | 2326 | LOG (GNUNET_ERROR_TYPE_INFO, "Re-key Tunnel %s\n", GCT_2s (t)); |
2340 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
2341 | if (NULL != tc && 0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | ||
2342 | return; | ||
2343 | |||
2344 | GNUNET_assert (NULL != t->kx_ctx); | 2327 | GNUNET_assert (NULL != t->kx_ctx); |
2345 | struct GNUNET_TIME_Relative duration; | 2328 | struct GNUNET_TIME_Relative duration; |
2346 | 2329 | ||
@@ -2453,13 +2436,8 @@ global_otr_rekey (void *cls) | |||
2453 | { | 2436 | { |
2454 | struct GNUNET_TIME_Absolute time; | 2437 | struct GNUNET_TIME_Absolute time; |
2455 | long n; | 2438 | long n; |
2456 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
2457 | 2439 | ||
2458 | rekey_task = NULL; | 2440 | rekey_task = NULL; |
2459 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
2460 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | ||
2461 | return; | ||
2462 | |||
2463 | GNUNET_free_non_null (otr_ephemeral_key); | 2441 | GNUNET_free_non_null (otr_ephemeral_key); |
2464 | otr_ephemeral_key = GNUNET_CRYPTO_ecdhe_key_create (); | 2442 | otr_ephemeral_key = GNUNET_CRYPTO_ecdhe_key_create (); |
2465 | 2443 | ||
@@ -2501,7 +2479,8 @@ destroy_iterator (void *cls, | |||
2501 | { | 2479 | { |
2502 | struct CadetTunnel *t = value; | 2480 | struct CadetTunnel *t = value; |
2503 | 2481 | ||
2504 | LOG (GNUNET_ERROR_TYPE_DEBUG, "GCT_shutdown destroying tunnel at %p\n", t); | 2482 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2483 | "GCT_shutdown destroying tunnel at %p\n", t); | ||
2505 | GCT_destroy (t); | 2484 | GCT_destroy (t); |
2506 | return GNUNET_YES; | 2485 | return GNUNET_YES; |
2507 | } | 2486 | } |
@@ -3472,13 +3451,8 @@ static void | |||
3472 | trim_connections (void *cls) | 3451 | trim_connections (void *cls) |
3473 | { | 3452 | { |
3474 | struct CadetTunnel *t = cls; | 3453 | struct CadetTunnel *t = cls; |
3475 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
3476 | 3454 | ||
3477 | t->trim_connections_task = NULL; | 3455 | t->trim_connections_task = NULL; |
3478 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
3479 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
3480 | return; | ||
3481 | |||
3482 | if (GCT_count_connections (t) > 2 * CONNECTIONS_PER_TUNNEL) | 3456 | if (GCT_count_connections (t) > 2 * CONNECTIONS_PER_TUNNEL) |
3483 | { | 3457 | { |
3484 | struct CadetTConnection *iter; | 3458 | struct CadetTConnection *iter; |
@@ -3624,8 +3598,11 @@ GCT_add_channel (struct CadetTunnel *t, struct CadetChannel *ch) | |||
3624 | 3598 | ||
3625 | aux = GNUNET_new (struct CadetTChannel); | 3599 | aux = GNUNET_new (struct CadetTChannel); |
3626 | aux->ch = ch; | 3600 | aux->ch = ch; |
3627 | LOG (GNUNET_ERROR_TYPE_DEBUG, " adding %p to %p\n", aux, t->channel_head); | 3601 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
3628 | GNUNET_CONTAINER_DLL_insert_tail (t->channel_head, t->channel_tail, aux); | 3602 | " adding %p to %p\n", aux, t->channel_head); |
3603 | GNUNET_CONTAINER_DLL_insert_tail (t->channel_head, | ||
3604 | t->channel_tail, | ||
3605 | aux); | ||
3629 | 3606 | ||
3630 | if (NULL != t->destroy_task) | 3607 | if (NULL != t->destroy_task) |
3631 | { | 3608 | { |
@@ -3653,7 +3630,9 @@ GCT_remove_channel (struct CadetTunnel *t, struct CadetChannel *ch) | |||
3653 | if (aux->ch == ch) | 3630 | if (aux->ch == ch) |
3654 | { | 3631 | { |
3655 | LOG (GNUNET_ERROR_TYPE_DEBUG, " found! %s\n", GCCH_2s (ch)); | 3632 | LOG (GNUNET_ERROR_TYPE_DEBUG, " found! %s\n", GCCH_2s (ch)); |
3656 | GNUNET_CONTAINER_DLL_remove (t->channel_head, t->channel_tail, aux); | 3633 | GNUNET_CONTAINER_DLL_remove (t->channel_head, |
3634 | t->channel_tail, | ||
3635 | aux); | ||
3657 | GNUNET_free (aux); | 3636 | GNUNET_free (aux); |
3658 | return; | 3637 | return; |
3659 | } | 3638 | } |
@@ -3701,20 +3680,12 @@ delayed_destroy (void *cls) | |||
3701 | { | 3680 | { |
3702 | struct CadetTunnel *t = cls; | 3681 | struct CadetTunnel *t = cls; |
3703 | struct CadetTConnection *iter; | 3682 | struct CadetTConnection *iter; |
3704 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
3705 | 3683 | ||
3706 | LOG (GNUNET_ERROR_TYPE_DEBUG, "delayed destroying tunnel %p\n", t); | ||
3707 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
3708 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | ||
3709 | { | ||
3710 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
3711 | "Not destroying tunnel, due to shutdown. " | ||
3712 | "Tunnel at %p should have been freed by GCT_shutdown\n", t); | ||
3713 | return; | ||
3714 | } | ||
3715 | t->destroy_task = NULL; | 3684 | t->destroy_task = NULL; |
3685 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
3686 | "delayed destroying tunnel %p\n", | ||
3687 | t); | ||
3716 | t->cstate = CADET_TUNNEL_SHUTDOWN; | 3688 | t->cstate = CADET_TUNNEL_SHUTDOWN; |
3717 | |||
3718 | for (iter = t->connection_head; NULL != iter; iter = iter->next) | 3689 | for (iter = t->connection_head; NULL != iter; iter = iter->next) |
3719 | { | 3690 | { |
3720 | GCC_send_destroy (iter->c); | 3691 | GCC_send_destroy (iter->c); |
@@ -3800,8 +3771,9 @@ GCT_destroy (struct CadetTunnel *t) | |||
3800 | if (NULL == t) | 3771 | if (NULL == t) |
3801 | return; | 3772 | return; |
3802 | 3773 | ||
3803 | LOG (GNUNET_ERROR_TYPE_DEBUG, "destroying tunnel %s\n", GCP_2s (t->peer)); | 3774 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
3804 | 3775 | "destroying tunnel %s\n", | |
3776 | GCP_2s (t->peer)); | ||
3805 | GNUNET_break (GNUNET_YES == | 3777 | GNUNET_break (GNUNET_YES == |
3806 | GNUNET_CONTAINER_multipeermap_remove (tunnels, | 3778 | GNUNET_CONTAINER_multipeermap_remove (tunnels, |
3807 | GCP_get_id (t->peer), t)); | 3779 | GCP_get_id (t->peer), t)); |
@@ -3850,7 +3822,9 @@ GCT_destroy (struct CadetTunnel *t) | |||
3850 | 3822 | ||
3851 | if (NULL != t->destroy_task) | 3823 | if (NULL != t->destroy_task) |
3852 | { | 3824 | { |
3853 | LOG (GNUNET_ERROR_TYPE_DEBUG, "cancelling dest: %p\n", t->destroy_task); | 3825 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
3826 | "cancelling dest: %p\n", | ||
3827 | t->destroy_task); | ||
3854 | GNUNET_SCHEDULER_cancel (t->destroy_task); | 3828 | GNUNET_SCHEDULER_cancel (t->destroy_task); |
3855 | t->destroy_task = NULL; | 3829 | t->destroy_task = NULL; |
3856 | } | 3830 | } |
diff --git a/src/cadet/test_cadet.c b/src/cadet/test_cadet.c index 39bfc5fed..b3ded1bdf 100644 --- a/src/cadet/test_cadet.c +++ b/src/cadet/test_cadet.c | |||
@@ -144,17 +144,17 @@ struct GNUNET_CADET_TEST_Context *test_ctx; | |||
144 | /** | 144 | /** |
145 | * Task called to disconnect peers. | 145 | * Task called to disconnect peers. |
146 | */ | 146 | */ |
147 | static struct GNUNET_SCHEDULER_Task * disconnect_task; | 147 | static struct GNUNET_SCHEDULER_Task *disconnect_task; |
148 | 148 | ||
149 | /** | 149 | /** |
150 | * Task To perform tests | 150 | * Task To perform tests |
151 | */ | 151 | */ |
152 | static struct GNUNET_SCHEDULER_Task * test_task; | 152 | static struct GNUNET_SCHEDULER_Task *test_task; |
153 | 153 | ||
154 | /** | 154 | /** |
155 | * Task called to shutdown test. | 155 | * Task runnining #data_task(). |
156 | */ | 156 | */ |
157 | static struct GNUNET_SCHEDULER_Task * shutdown_handle; | 157 | static struct GNUNET_SCHEDULER_Task *data_job; |
158 | 158 | ||
159 | /** | 159 | /** |
160 | * Cadet handle for the root peer | 160 | * Cadet handle for the root peer |
@@ -230,6 +230,7 @@ get_expected_target () | |||
230 | return peers_requested - 1; | 230 | return peers_requested - 1; |
231 | } | 231 | } |
232 | 232 | ||
233 | |||
233 | /** | 234 | /** |
234 | * Show the results of the test (banwidth acheived) and log them to GAUGER | 235 | * Show the results of the test (banwidth acheived) and log them to GAUGER |
235 | */ | 236 | */ |
@@ -256,20 +257,6 @@ show_end_data (void) | |||
256 | 257 | ||
257 | 258 | ||
258 | /** | 259 | /** |
259 | * Shut down peergroup, clean up. | ||
260 | * | ||
261 | * @param cls Closure (unused). | ||
262 | * @param tc Task Context. | ||
263 | */ | ||
264 | static void | ||
265 | shutdown_task (void *cls) | ||
266 | { | ||
267 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending test.\n"); | ||
268 | shutdown_handle = NULL; | ||
269 | } | ||
270 | |||
271 | |||
272 | /** | ||
273 | * Disconnect from cadet services af all peers, call shutdown. | 260 | * Disconnect from cadet services af all peers, call shutdown. |
274 | * | 261 | * |
275 | * @param cls Closure (line number from which termination was requested). | 262 | * @param cls Closure (line number from which termination was requested). |
@@ -280,18 +267,11 @@ disconnect_cadet_peers (void *cls) | |||
280 | { | 267 | { |
281 | long line = (long) cls; | 268 | long line = (long) cls; |
282 | unsigned int i; | 269 | unsigned int i; |
283 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
284 | 270 | ||
285 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
286 | if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0) | ||
287 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
288 | "disconnecting cadet peers due to SHUTDOWN! called from %ld\n", | ||
289 | line); | ||
290 | else | ||
291 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
292 | "disconnecting cadet service of peers, called from line %ld\n", | ||
293 | line); | ||
294 | disconnect_task = NULL; | 271 | disconnect_task = NULL; |
272 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
273 | "disconnecting cadet service of peers, called from line %ld\n", | ||
274 | line); | ||
295 | for (i = 0; i < 2; i++) | 275 | for (i = 0; i < 2; i++) |
296 | { | 276 | { |
297 | GNUNET_TESTBED_operation_done (t_op[i]); | 277 | GNUNET_TESTBED_operation_done (t_op[i]); |
@@ -317,15 +297,39 @@ disconnect_cadet_peers (void *cls) | |||
317 | incoming_ch = NULL; | 297 | incoming_ch = NULL; |
318 | } | 298 | } |
319 | GNUNET_CADET_TEST_cleanup (test_ctx); | 299 | GNUNET_CADET_TEST_cleanup (test_ctx); |
320 | if (NULL != shutdown_handle) | 300 | GNUNET_SCHEDULER_shutdown (); |
301 | } | ||
302 | |||
303 | |||
304 | /** | ||
305 | * Shut down peergroup, clean up. | ||
306 | * | ||
307 | * @param cls Closure (unused). | ||
308 | * @param tc Task Context. | ||
309 | */ | ||
310 | static void | ||
311 | shutdown_task (void *cls) | ||
312 | { | ||
313 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending test.\n"); | ||
314 | if (NULL != data_job) | ||
321 | { | 315 | { |
322 | GNUNET_SCHEDULER_cancel (shutdown_handle); | 316 | GNUNET_SCHEDULER_cancel (data_job); |
317 | data_job = NULL; | ||
318 | } | ||
319 | if (NULL != test_task) | ||
320 | { | ||
321 | GNUNET_SCHEDULER_cancel (test_task); | ||
322 | test_task = NULL; | ||
323 | } | ||
324 | if (NULL != disconnect_task) | ||
325 | { | ||
326 | GNUNET_SCHEDULER_cancel (disconnect_task); | ||
327 | disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers, | ||
328 | (void *) __LINE__); | ||
323 | } | 329 | } |
324 | shutdown_handle = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | ||
325 | } | 330 | } |
326 | 331 | ||
327 | 332 | ||
328 | |||
329 | /** | 333 | /** |
330 | * Stats callback. Finish the stats testbed operation and when all stats have | 334 | * Stats callback. Finish the stats testbed operation and when all stats have |
331 | * been iterated, shutdown the test. | 335 | * been iterated, shutdown the test. |
@@ -346,8 +350,8 @@ stats_cont (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg) | |||
346 | 350 | ||
347 | if (NULL != disconnect_task) | 351 | if (NULL != disconnect_task) |
348 | GNUNET_SCHEDULER_cancel (disconnect_task); | 352 | GNUNET_SCHEDULER_cancel (disconnect_task); |
349 | disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers, cls); | 353 | disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers, |
350 | 354 | cls); | |
351 | } | 355 | } |
352 | 356 | ||
353 | 357 | ||
@@ -393,19 +397,11 @@ static void | |||
393 | gather_stats_and_exit (void *cls) | 397 | gather_stats_and_exit (void *cls) |
394 | { | 398 | { |
395 | long l = (long) cls; | 399 | long l = (long) cls; |
396 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
397 | 400 | ||
398 | disconnect_task = NULL; | 401 | disconnect_task = NULL; |
399 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "gathering statistics from line %d\n", l); | 402 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
400 | tc = GNUNET_SCHEDULER_get_task_context (); | 403 | "gathering statistics from line %d\n", |
401 | if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0) | 404 | l); |
402 | { | ||
403 | disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers, | ||
404 | (void *) __LINE__); | ||
405 | return; | ||
406 | } | ||
407 | |||
408 | |||
409 | if (NULL != ch) | 405 | if (NULL != ch) |
410 | { | 406 | { |
411 | if (NULL != th) | 407 | if (NULL != th) |
@@ -463,14 +459,10 @@ data_task (void *cls) | |||
463 | { | 459 | { |
464 | struct GNUNET_CADET_Channel *channel; | 460 | struct GNUNET_CADET_Channel *channel; |
465 | static struct GNUNET_CADET_TransmitHandle **pth; | 461 | static struct GNUNET_CADET_TransmitHandle **pth; |
466 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
467 | long src; | 462 | long src; |
468 | 463 | ||
464 | data_job = NULL; | ||
469 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Data task\n"); | 465 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Data task\n"); |
470 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
471 | if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0) | ||
472 | return; | ||
473 | |||
474 | if (GNUNET_YES == test_backwards) | 466 | if (GNUNET_YES == test_backwards) |
475 | { | 467 | { |
476 | channel = incoming_ch; | 468 | channel = incoming_ch; |
@@ -499,17 +491,16 @@ data_task (void *cls) | |||
499 | if (0 == i) | 491 | if (0 == i) |
500 | { | 492 | { |
501 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, " in 1 ms\n"); | 493 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, " in 1 ms\n"); |
502 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS, | 494 | data_job = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS, |
503 | &data_task, (void *) 1L); | 495 | &data_task, (void *) 1L); |
504 | } | 496 | } |
505 | else | 497 | else |
506 | { | 498 | { |
507 | i++; | 499 | i++; |
508 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "in %u ms\n", i); | 500 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "in %u ms\n", i); |
509 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply ( | 501 | data_job = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, |
510 | GNUNET_TIME_UNIT_MILLISECONDS, | 502 | i), |
511 | i), | 503 | &data_task, (void *) i); |
512 | &data_task, (void *) i); | ||
513 | } | 504 | } |
514 | } | 505 | } |
515 | } | 506 | } |
@@ -574,7 +565,7 @@ tmt_rdy (void *cls, size_t size, void *buf) | |||
574 | { | 565 | { |
575 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Scheduling message %d\n", | 566 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Scheduling message %d\n", |
576 | counter + 1); | 567 | counter + 1); |
577 | GNUNET_SCHEDULER_add_now (&data_task, NULL); | 568 | data_job = GNUNET_SCHEDULER_add_now (&data_task, NULL); |
578 | } | 569 | } |
579 | } | 570 | } |
580 | 571 | ||
@@ -661,7 +652,7 @@ data_callback (void *cls, struct GNUNET_CADET_Channel *channel, | |||
661 | if (SPEED == test) | 652 | if (SPEED == test) |
662 | { | 653 | { |
663 | GNUNET_assert (peers_requested - 1 == client); | 654 | GNUNET_assert (peers_requested - 1 == client); |
664 | GNUNET_SCHEDULER_add_now (&data_task, NULL); | 655 | data_job = GNUNET_SCHEDULER_add_now (&data_task, NULL); |
665 | return GNUNET_OK; | 656 | return GNUNET_OK; |
666 | } | 657 | } |
667 | } | 658 | } |
@@ -842,17 +833,14 @@ static void | |||
842 | do_test (void *cls) | 833 | do_test (void *cls) |
843 | { | 834 | { |
844 | enum GNUNET_CADET_ChannelOption flags; | 835 | enum GNUNET_CADET_ChannelOption flags; |
845 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
846 | |||
847 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
848 | if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0) | ||
849 | return; | ||
850 | 836 | ||
837 | test_task = NULL; | ||
851 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "do_test\n"); | 838 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "do_test\n"); |
852 | 839 | ||
853 | if (NULL != disconnect_task) | 840 | if (NULL != disconnect_task) |
854 | { | 841 | { |
855 | GNUNET_SCHEDULER_cancel (disconnect_task); | 842 | GNUNET_SCHEDULER_cancel (disconnect_task); |
843 | disconnect_task = NULL; | ||
856 | } | 844 | } |
857 | 845 | ||
858 | flags = GNUNET_CADET_OPTION_DEFAULT; | 846 | flags = GNUNET_CADET_OPTION_DEFAULT; |
@@ -880,6 +868,7 @@ do_test (void *cls) | |||
880 | &tmt_rdy, (void *) 0L); | 868 | &tmt_rdy, (void *) 0L); |
881 | } | 869 | } |
882 | 870 | ||
871 | |||
883 | /** | 872 | /** |
884 | * Callback to be called when the requested peer information is available | 873 | * Callback to be called when the requested peer information is available |
885 | * | 874 | * |
@@ -942,8 +931,7 @@ tmain (void *cls, | |||
942 | disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME, | 931 | disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME, |
943 | &disconnect_cadet_peers, | 932 | &disconnect_cadet_peers, |
944 | (void *) __LINE__); | 933 | (void *) __LINE__); |
945 | shutdown_handle = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 934 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
946 | &shutdown_task, NULL); | ||
947 | t_op[0] = GNUNET_TESTBED_peer_get_information (peers[0], | 935 | t_op[0] = GNUNET_TESTBED_peer_get_information (peers[0], |
948 | GNUNET_TESTBED_PIT_IDENTITY, | 936 | GNUNET_TESTBED_PIT_IDENTITY, |
949 | &pi_cb, (void *) 0L); | 937 | &pi_cb, (void *) 0L); |
diff --git a/src/cadet/test_cadet_local.c b/src/cadet/test_cadet_local.c index 42663b146..a17d8f1ab 100644 --- a/src/cadet/test_cadet_local.c +++ b/src/cadet/test_cadet_local.c | |||
@@ -42,9 +42,9 @@ static int result = GNUNET_OK; | |||
42 | 42 | ||
43 | static int got_data = GNUNET_NO; | 43 | static int got_data = GNUNET_NO; |
44 | 44 | ||
45 | static struct GNUNET_SCHEDULER_Task * abort_task; | 45 | static struct GNUNET_SCHEDULER_Task *abort_task; |
46 | 46 | ||
47 | static struct GNUNET_SCHEDULER_Task * shutdown_task; | 47 | static struct GNUNET_SCHEDULER_Task *connect_task; |
48 | 48 | ||
49 | static struct GNUNET_CADET_TransmitHandle *mth; | 49 | static struct GNUNET_CADET_TransmitHandle *mth; |
50 | 50 | ||
@@ -68,20 +68,29 @@ do_shutdown (void *cls) | |||
68 | if (NULL != abort_task) | 68 | if (NULL != abort_task) |
69 | { | 69 | { |
70 | GNUNET_SCHEDULER_cancel (abort_task); | 70 | GNUNET_SCHEDULER_cancel (abort_task); |
71 | abort_task = NULL; | ||
72 | } | ||
73 | if (NULL != connect_task) | ||
74 | { | ||
75 | GNUNET_SCHEDULER_cancel (connect_task); | ||
76 | connect_task = NULL; | ||
71 | } | 77 | } |
72 | if (NULL != ch) | 78 | if (NULL != ch) |
73 | { | 79 | { |
74 | GNUNET_CADET_channel_destroy (ch); | 80 | GNUNET_CADET_channel_destroy (ch); |
81 | ch = NULL; | ||
75 | } | 82 | } |
76 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnect client 1\n"); | 83 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnect client 1\n"); |
77 | if (NULL != cadet_peer_1) | 84 | if (NULL != cadet_peer_1) |
78 | { | 85 | { |
79 | GNUNET_CADET_disconnect (cadet_peer_1); | 86 | GNUNET_CADET_disconnect (cadet_peer_1); |
87 | cadet_peer_1 = NULL; | ||
80 | } | 88 | } |
81 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnect client 2\n"); | 89 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnect client 2\n"); |
82 | if (NULL != cadet_peer_2) | 90 | if (NULL != cadet_peer_2) |
83 | { | 91 | { |
84 | GNUNET_CADET_disconnect (cadet_peer_2); | 92 | GNUNET_CADET_disconnect (cadet_peer_2); |
93 | cadet_peer_2 = NULL; | ||
85 | } | 94 | } |
86 | } | 95 | } |
87 | 96 | ||
@@ -95,12 +104,7 @@ do_abort (void *cls) | |||
95 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ABORT\n"); | 104 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ABORT\n"); |
96 | result = GNUNET_SYSERR; | 105 | result = GNUNET_SYSERR; |
97 | abort_task = NULL; | 106 | abort_task = NULL; |
98 | if (NULL != shutdown_task) | 107 | GNUNET_SCHEDULER_shutdown (); |
99 | { | ||
100 | GNUNET_SCHEDULER_cancel (shutdown_task); | ||
101 | shutdown_task = NULL; | ||
102 | } | ||
103 | do_shutdown (cls); | ||
104 | } | 108 | } |
105 | 109 | ||
106 | 110 | ||
@@ -120,14 +124,10 @@ data_callback (void *cls, struct GNUNET_CADET_Channel *channel, | |||
120 | void **channel_ctx, | 124 | void **channel_ctx, |
121 | const struct GNUNET_MessageHeader *message) | 125 | const struct GNUNET_MessageHeader *message) |
122 | { | 126 | { |
123 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Data callback! Shutting down.\n"); | 127 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
128 | "Data callback! Shutting down.\n"); | ||
124 | got_data = GNUNET_YES; | 129 | got_data = GNUNET_YES; |
125 | if (NULL != shutdown_task) | 130 | GNUNET_SCHEDULER_shutdown (); |
126 | GNUNET_SCHEDULER_cancel (shutdown_task); | ||
127 | shutdown_task = | ||
128 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | ||
129 | &do_shutdown, | ||
130 | NULL); | ||
131 | GNUNET_CADET_receive_done (channel); | 131 | GNUNET_CADET_receive_done (channel); |
132 | return GNUNET_OK; | 132 | return GNUNET_OK; |
133 | } | 133 | } |
@@ -254,12 +254,8 @@ static void | |||
254 | do_connect (void *cls) | 254 | do_connect (void *cls) |
255 | { | 255 | { |
256 | struct GNUNET_PeerIdentity id; | 256 | struct GNUNET_PeerIdentity id; |
257 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
258 | |||
259 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
260 | if (NULL != tc && 0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | ||
261 | return; | ||
262 | 257 | ||
258 | connect_task = NULL; | ||
263 | GNUNET_TESTING_peer_get_identity (me, &id); | 259 | GNUNET_TESTING_peer_get_identity (me, &id); |
264 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CONNECT BY PORT\n"); | 260 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CONNECT BY PORT\n"); |
265 | ch = GNUNET_CADET_channel_create (cadet_peer_1, NULL, &id, 1, | 261 | ch = GNUNET_CADET_channel_create (cadet_peer_1, NULL, &id, 1, |
@@ -286,9 +282,11 @@ run (void *cls, | |||
286 | static uint32_t ports[] = {1, 0}; | 282 | static uint32_t ports[] = {1, 0}; |
287 | 283 | ||
288 | me = peer; | 284 | me = peer; |
285 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); | ||
289 | abort_task = | 286 | abort_task = |
290 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 287 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
291 | (GNUNET_TIME_UNIT_SECONDS, 15), &do_abort, | 288 | (GNUNET_TIME_UNIT_SECONDS, 15), |
289 | &do_abort, | ||
292 | NULL); | 290 | NULL); |
293 | cadet_peer_1 = GNUNET_CADET_connect (cfg, /* configuration */ | 291 | cadet_peer_1 = GNUNET_CADET_connect (cfg, /* configuration */ |
294 | (void *) 1L, /* cls */ | 292 | (void *) 1L, /* cls */ |
@@ -305,14 +303,12 @@ run (void *cls, | |||
305 | ports); /* ports offered */ | 303 | ports); /* ports offered */ |
306 | if (NULL == cadet_peer_1 || NULL == cadet_peer_2) | 304 | if (NULL == cadet_peer_1 || NULL == cadet_peer_2) |
307 | { | 305 | { |
308 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Couldn't connect to cadet :(\n"); | 306 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
307 | "Couldn't connect to cadet :(\n"); | ||
309 | result = GNUNET_SYSERR; | 308 | result = GNUNET_SYSERR; |
309 | GNUNET_SCHEDULER_shutdown (); | ||
310 | return; | 310 | return; |
311 | } | 311 | } |
312 | else | ||
313 | { | ||
314 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "YAY! CONNECTED TO CADET :D\n"); | ||
315 | } | ||
316 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply ( | 312 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply ( |
317 | GNUNET_TIME_UNIT_SECONDS, | 313 | GNUNET_TIME_UNIT_SECONDS, |
318 | 2), | 314 | 2), |
diff --git a/src/cadet/test_cadet_single.c b/src/cadet/test_cadet_single.c index 93a50c02c..b9ab7e23a 100644 --- a/src/cadet/test_cadet_single.c +++ b/src/cadet/test_cadet_single.c | |||
@@ -43,9 +43,9 @@ static struct GNUNET_CADET_Channel *ch2; | |||
43 | 43 | ||
44 | static int result; | 44 | static int result; |
45 | 45 | ||
46 | static struct GNUNET_SCHEDULER_Task * abort_task; | 46 | static struct GNUNET_SCHEDULER_Task *abort_task; |
47 | 47 | ||
48 | static struct GNUNET_SCHEDULER_Task * shutdown_task; | 48 | static struct GNUNET_SCHEDULER_Task *connect_task; |
49 | 49 | ||
50 | static unsigned int repetition; | 50 | static unsigned int repetition; |
51 | 51 | ||
@@ -65,10 +65,17 @@ do_shutdown (void *cls) | |||
65 | if (NULL != abort_task) | 65 | if (NULL != abort_task) |
66 | { | 66 | { |
67 | GNUNET_SCHEDULER_cancel (abort_task); | 67 | GNUNET_SCHEDULER_cancel (abort_task); |
68 | abort_task = NULL; | ||
69 | } | ||
70 | if (NULL != connect_task) | ||
71 | { | ||
72 | GNUNET_SCHEDULER_cancel (connect_task); | ||
73 | connect_task = NULL; | ||
68 | } | 74 | } |
69 | if (NULL != ch1) | 75 | if (NULL != ch1) |
70 | { | 76 | { |
71 | GNUNET_CADET_channel_destroy (ch1); | 77 | GNUNET_CADET_channel_destroy (ch1); |
78 | ch1 = NULL; | ||
72 | } | 79 | } |
73 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnect client 1\n"); | 80 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnect client 1\n"); |
74 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnect client 2\n"); | 81 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnect client 2\n"); |
@@ -93,22 +100,7 @@ do_abort (void *cls) | |||
93 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ABORT\n"); | 100 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ABORT\n"); |
94 | result = GNUNET_SYSERR; | 101 | result = GNUNET_SYSERR; |
95 | abort_task = NULL; | 102 | abort_task = NULL; |
96 | if (NULL != shutdown_task) | 103 | GNUNET_SCHEDULER_shutdown (); |
97 | { | ||
98 | GNUNET_SCHEDULER_cancel (shutdown_task); | ||
99 | shutdown_task = NULL; | ||
100 | } | ||
101 | do_shutdown (cls); | ||
102 | } | ||
103 | |||
104 | |||
105 | static void | ||
106 | finish (void) | ||
107 | { | ||
108 | if (NULL != shutdown_task) | ||
109 | GNUNET_SCHEDULER_cancel (shutdown_task); | ||
110 | shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | ||
111 | &do_shutdown, NULL); | ||
112 | } | 104 | } |
113 | 105 | ||
114 | 106 | ||
@@ -202,7 +194,7 @@ channel_end (void *cls, const struct GNUNET_CADET_Channel *channel, | |||
202 | ch2 = NULL; | 194 | ch2 = NULL; |
203 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "everything fine! finishing!\n"); | 195 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "everything fine! finishing!\n"); |
204 | result = GNUNET_OK; | 196 | result = GNUNET_OK; |
205 | finish (); | 197 | GNUNET_SCHEDULER_shutdown (); |
206 | } | 198 | } |
207 | } | 199 | } |
208 | 200 | ||
@@ -253,12 +245,8 @@ do_connect (void *cls) | |||
253 | { | 245 | { |
254 | struct GNUNET_PeerIdentity id; | 246 | struct GNUNET_PeerIdentity id; |
255 | size_t size = sizeof (struct GNUNET_MessageHeader) + DATA_SIZE; | 247 | size_t size = sizeof (struct GNUNET_MessageHeader) + DATA_SIZE; |
256 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
257 | |||
258 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
259 | if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0) | ||
260 | return; | ||
261 | 248 | ||
249 | connect_task = NULL; | ||
262 | GNUNET_TESTING_peer_get_identity (me, &id); | 250 | GNUNET_TESTING_peer_get_identity (me, &id); |
263 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CONNECT BY PORT\n"); | 251 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CONNECT BY PORT\n"); |
264 | ch1 = GNUNET_CADET_channel_create (cadet, NULL, &id, 1, | 252 | ch1 = GNUNET_CADET_channel_create (cadet, NULL, &id, 1, |
@@ -284,6 +272,7 @@ run (void *cls, | |||
284 | static uint32_t ports[] = {1, 0}; | 272 | static uint32_t ports[] = {1, 0}; |
285 | 273 | ||
286 | me = peer; | 274 | me = peer; |
275 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); | ||
287 | abort_task = | 276 | abort_task = |
288 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 277 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
289 | (GNUNET_TIME_UNIT_SECONDS, 15), &do_abort, | 278 | (GNUNET_TIME_UNIT_SECONDS, 15), &do_abort, |
@@ -301,11 +290,10 @@ run (void *cls, | |||
301 | result = GNUNET_SYSERR; | 290 | result = GNUNET_SYSERR; |
302 | return; | 291 | return; |
303 | } | 292 | } |
304 | else | 293 | connect_task |
305 | { | 294 | = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
306 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "YAY! CONNECTED TO CADET :D\n"); | 295 | &do_connect, |
307 | } | 296 | NULL); |
308 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &do_connect, NULL); | ||
309 | } | 297 | } |
310 | 298 | ||
311 | 299 | ||
diff --git a/src/consensus/gnunet-service-consensus.c b/src/consensus/gnunet-service-consensus.c index 82b05d136..99e7aca97 100644 --- a/src/consensus/gnunet-service-consensus.c +++ b/src/consensus/gnunet-service-consensus.c | |||
@@ -3231,7 +3231,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
3231 | } | 3231 | } |
3232 | statistics = GNUNET_STATISTICS_create ("consensus", cfg); | 3232 | statistics = GNUNET_STATISTICS_create ("consensus", cfg); |
3233 | GNUNET_SERVER_add_handlers (server, server_handlers); | 3233 | GNUNET_SERVER_add_handlers (server, server_handlers); |
3234 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); | 3234 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
3235 | GNUNET_SERVER_disconnect_notify (server, handle_client_disconnect, NULL); | 3235 | GNUNET_SERVER_disconnect_notify (server, handle_client_disconnect, NULL); |
3236 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "consensus running\n"); | 3236 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "consensus running\n"); |
3237 | } | 3237 | } |
diff --git a/src/consensus/test_consensus_api.c b/src/consensus/test_consensus_api.c index 0073267f8..85707eed1 100644 --- a/src/consensus/test_consensus_api.c +++ b/src/consensus/test_consensus_api.c | |||
@@ -92,10 +92,7 @@ run (void *cls, | |||
92 | GNUNET_log_setup ("test_consensus_api", | 92 | GNUNET_log_setup ("test_consensus_api", |
93 | "INFO", | 93 | "INFO", |
94 | NULL); | 94 | NULL); |
95 | 95 | GNUNET_SCHEDULER_add_shutdown (&on_shutdown, NULL); | |
96 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "testing consensus api\n"); | ||
97 | |||
98 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &on_shutdown, NULL); | ||
99 | 96 | ||
100 | GNUNET_CRYPTO_hash (str, strlen (str), &session_id); | 97 | GNUNET_CRYPTO_hash (str, strlen (str), &session_id); |
101 | consensus = GNUNET_CONSENSUS_create (cfg, 0, NULL, &session_id, | 98 | consensus = GNUNET_CONSENSUS_create (cfg, 0, NULL, &session_id, |
@@ -112,10 +109,7 @@ run (void *cls, | |||
112 | int | 109 | int |
113 | main (int argc, char **argv) | 110 | main (int argc, char **argv) |
114 | { | 111 | { |
115 | int ret; | 112 | return GNUNET_TESTING_peer_run ("test_consensus_api", |
116 | 113 | "test_consensus.conf", | |
117 | ret = GNUNET_TESTING_peer_run ("test_consensus_api", | 114 | &run, NULL); |
118 | "test_consensus.conf", | ||
119 | &run, NULL); | ||
120 | return ret; | ||
121 | } | 115 | } |
diff --git a/src/conversation/gnunet-conversation-test.c b/src/conversation/gnunet-conversation-test.c index fe6eae925..815c7ef11 100644 --- a/src/conversation/gnunet-conversation-test.c +++ b/src/conversation/gnunet-conversation-test.c | |||
@@ -204,9 +204,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
204 | switch_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 204 | switch_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
205 | &switch_to_speaker, | 205 | &switch_to_speaker, |
206 | NULL); | 206 | NULL); |
207 | st = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 207 | st = GNUNET_SCHEDULER_add_shutdown (&do_shutdown, |
208 | &do_shutdown, | 208 | NULL); |
209 | NULL); | ||
210 | fprintf (stderr, | 209 | fprintf (stderr, |
211 | _("We will now be recording you for %s. After that time, the recording will be played back to you..."), | 210 | _("We will now be recording you for %s. After that time, the recording will be played back to you..."), |
212 | GNUNET_STRINGS_relative_time_to_string (TIMEOUT, GNUNET_YES)); | 211 | GNUNET_STRINGS_relative_time_to_string (TIMEOUT, GNUNET_YES)); |
diff --git a/src/conversation/gnunet-conversation.c b/src/conversation/gnunet-conversation.c index 9000bcf3f..d899ee5ca 100644 --- a/src/conversation/gnunet-conversation.c +++ b/src/conversation/gnunet-conversation.c | |||
@@ -1249,8 +1249,8 @@ run (void *cls, | |||
1249 | handle_cmd_task = | 1249 | handle_cmd_task = |
1250 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_UI, | 1250 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_UI, |
1251 | &handle_command, NULL); | 1251 | &handle_command, NULL); |
1252 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &do_stop_task, | 1252 | GNUNET_SCHEDULER_add_shutdown (&do_stop_task, |
1253 | NULL); | 1253 | NULL); |
1254 | } | 1254 | } |
1255 | 1255 | ||
1256 | 1256 | ||
diff --git a/src/conversation/gnunet-service-conversation.c b/src/conversation/gnunet-service-conversation.c index fdaa2999c..10f169105 100644 --- a/src/conversation/gnunet-service-conversation.c +++ b/src/conversation/gnunet-service-conversation.c | |||
@@ -1574,10 +1574,11 @@ run (void *cls, | |||
1574 | } | 1574 | } |
1575 | nc = GNUNET_SERVER_notification_context_create (server, 16); | 1575 | nc = GNUNET_SERVER_notification_context_create (server, 16); |
1576 | GNUNET_SERVER_add_handlers (server, server_handlers); | 1576 | GNUNET_SERVER_add_handlers (server, server_handlers); |
1577 | GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); | 1577 | GNUNET_SERVER_disconnect_notify (server, |
1578 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1578 | &handle_client_disconnect, |
1579 | &do_shutdown, | 1579 | NULL); |
1580 | NULL); | 1580 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, |
1581 | NULL); | ||
1581 | } | 1582 | } |
1582 | 1583 | ||
1583 | 1584 | ||
diff --git a/src/core/gnunet-core.c b/src/core/gnunet-core.c index 968072e22..d91dc304d 100644 --- a/src/core/gnunet-core.c +++ b/src/core/gnunet-core.c | |||
@@ -155,8 +155,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
155 | _("Failed to connect to CORE service!\n")); | 155 | _("Failed to connect to CORE service!\n")); |
156 | return; | 156 | return; |
157 | } | 157 | } |
158 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 158 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
159 | &shutdown_task, NULL); | ||
160 | } | 159 | } |
161 | 160 | ||
162 | 161 | ||
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index 1d9de8666..70b83b24c 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c | |||
@@ -106,9 +106,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
106 | return; | 106 | return; |
107 | } | 107 | } |
108 | GSC_stats = GNUNET_STATISTICS_create ("core", GSC_cfg); | 108 | GSC_stats = GNUNET_STATISTICS_create ("core", GSC_cfg); |
109 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 109 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
110 | &shutdown_task, | 110 | NULL); |
111 | NULL); | ||
112 | GNUNET_SERVER_suspend (server); | 111 | GNUNET_SERVER_suspend (server); |
113 | GSC_TYPEMAP_init (); | 112 | GSC_TYPEMAP_init (); |
114 | pk = GNUNET_CRYPTO_eddsa_key_create_from_file (keyfile); | 113 | pk = GNUNET_CRYPTO_eddsa_key_create_from_file (keyfile); |
diff --git a/src/core/gnunet-service-core_kx.c b/src/core/gnunet-service-core_kx.c index 8250bcc6f..9bb5af100 100644 --- a/src/core/gnunet-service-core_kx.c +++ b/src/core/gnunet-service-core_kx.c | |||
@@ -745,9 +745,10 @@ GSC_KX_start (const struct GNUNET_PeerIdentity *pid) | |||
745 | { | 745 | { |
746 | /* peer with "higher" identity starts a delayed KX, if the "lower" peer | 746 | /* peer with "higher" identity starts a delayed KX, if the "lower" peer |
747 | * does not start a KX since he sees no reasons to do so */ | 747 | * does not start a KX since he sees no reasons to do so */ |
748 | kx->retry_set_key_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 748 | kx->retry_set_key_task |
749 | &set_key_retry_task, | 749 | = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
750 | kx); | 750 | &set_key_retry_task, |
751 | kx); | ||
751 | } | 752 | } |
752 | return kx; | 753 | return kx; |
753 | } | 754 | } |
diff --git a/src/core/test_core_api_mq.c b/src/core/test_core_api_mq.c index a82465e74..8ece78e58 100644 --- a/src/core/test_core_api_mq.c +++ b/src/core/test_core_api_mq.c | |||
@@ -29,15 +29,15 @@ | |||
29 | /** | 29 | /** |
30 | * Has the test been successful? | 30 | * Has the test been successful? |
31 | */ | 31 | */ |
32 | int result; | 32 | static int result; |
33 | 33 | ||
34 | unsigned int num_received; | 34 | static unsigned int num_received; |
35 | 35 | ||
36 | struct GNUNET_CORE_Handle *core; | 36 | static struct GNUNET_CORE_Handle *core; |
37 | 37 | ||
38 | struct GNUNET_MQ_Handle *mq; | 38 | static struct GNUNET_MQ_Handle *mq; |
39 | 39 | ||
40 | struct GNUNET_PeerIdentity myself; | 40 | static struct GNUNET_PeerIdentity myself; |
41 | 41 | ||
42 | 42 | ||
43 | static void | 43 | static void |
@@ -55,15 +55,19 @@ init_cb (void *cls, | |||
55 | 55 | ||
56 | 56 | ||
57 | static void | 57 | static void |
58 | connect_cb (void *cls, const struct GNUNET_PeerIdentity *peer) | 58 | connect_cb (void *cls, |
59 | const struct GNUNET_PeerIdentity *peer) | ||
59 | { | 60 | { |
60 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected to peer %s.\n", | 61 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
62 | "Connected to peer %s.\n", | ||
61 | GNUNET_i2s (peer)); | 63 | GNUNET_i2s (peer)); |
62 | if (0 == memcmp (peer, &myself, sizeof (struct GNUNET_PeerIdentity))) | 64 | if (0 == memcmp (peer, &myself, sizeof (struct GNUNET_PeerIdentity))) |
63 | { | 65 | { |
64 | unsigned int i; | 66 | unsigned int i; |
65 | struct GNUNET_MQ_Envelope *ev; | 67 | struct GNUNET_MQ_Envelope *ev; |
66 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Queueing messages.\n"); | 68 | |
69 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
70 | "Queueing messages.\n"); | ||
67 | for (i = 0; i < NUM_MSG; i++) | 71 | for (i = 0; i < NUM_MSG; i++) |
68 | { | 72 | { |
69 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_TEST); | 73 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_TEST); |
@@ -78,7 +82,9 @@ handle_test (void *cls, | |||
78 | const struct GNUNET_PeerIdentity *other, | 82 | const struct GNUNET_PeerIdentity *other, |
79 | const struct GNUNET_MessageHeader *message) | 83 | const struct GNUNET_MessageHeader *message) |
80 | { | 84 | { |
81 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got test message %d\n", num_received); | 85 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
86 | "Got test message %d\n", | ||
87 | num_received); | ||
82 | num_received++; | 88 | num_received++; |
83 | if (NUM_MSG == num_received) | 89 | if (NUM_MSG == num_received) |
84 | { | 90 | { |
@@ -98,7 +104,8 @@ handle_test (void *cls, | |||
98 | static void | 104 | static void |
99 | shutdown_task (void *cls) | 105 | shutdown_task (void *cls) |
100 | { | 106 | { |
101 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n"); | 107 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
108 | "Shutting down\n"); | ||
102 | GNUNET_MQ_destroy (mq); | 109 | GNUNET_MQ_destroy (mq); |
103 | GNUNET_CORE_disconnect (core); | 110 | GNUNET_CORE_disconnect (core); |
104 | } | 111 | } |
@@ -129,9 +136,10 @@ run (void *cls, | |||
129 | GNUNET_assert (0); | 136 | GNUNET_assert (0); |
130 | return; | 137 | return; |
131 | } | 138 | } |
132 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); | 139 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
133 | } | 140 | } |
134 | 141 | ||
142 | |||
135 | int | 143 | int |
136 | main (int argc, char *argv1[]) | 144 | main (int argc, char *argv1[]) |
137 | { | 145 | { |
diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c index ed895df42..e28f57fa6 100644 --- a/src/core/test_core_quota_compliance.c +++ b/src/core/test_core_quota_compliance.c | |||
@@ -163,13 +163,9 @@ terminate_task (void *cls) | |||
163 | static void | 163 | static void |
164 | terminate_task_error (void *cls) | 164 | terminate_task_error (void *cls) |
165 | { | 165 | { |
166 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
167 | |||
168 | err_task = NULL; | 166 | err_task = NULL; |
169 | tc = GNUNET_SCHEDULER_get_task_context (); | 167 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
170 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 168 | "Testcase failed!\n"); |
171 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
172 | "Testcase failed!\n"); | ||
173 | terminate_peer (&p1); | 169 | terminate_peer (&p1); |
174 | terminate_peer (&p2); | 170 | terminate_peer (&p2); |
175 | //GNUNET_break (0); | 171 | //GNUNET_break (0); |
@@ -301,7 +297,6 @@ measurement_stop (void *cls) | |||
301 | */ | 297 | */ |
302 | GNUNET_SCHEDULER_cancel (err_task); | 298 | GNUNET_SCHEDULER_cancel (err_task); |
303 | err_task = GNUNET_SCHEDULER_add_now (&terminate_task, NULL); | 299 | err_task = GNUNET_SCHEDULER_add_now (&terminate_task, NULL); |
304 | |||
305 | } | 300 | } |
306 | 301 | ||
307 | 302 | ||
@@ -357,7 +352,6 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
357 | } | 352 | } |
358 | 353 | ||
359 | 354 | ||
360 | |||
361 | static void | 355 | static void |
362 | connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer) | 356 | connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer) |
363 | { | 357 | { |
@@ -375,8 +369,7 @@ connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
375 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 369 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
376 | "Asking core (1) for transmission to peer `%4s'\n", | 370 | "Asking core (1) for transmission to peer `%4s'\n", |
377 | GNUNET_i2s (&p2.id)); | 371 | GNUNET_i2s (&p2.id)); |
378 | if (err_task != NULL) | 372 | GNUNET_SCHEDULER_cancel (err_task); |
379 | GNUNET_SCHEDULER_cancel (err_task); | ||
380 | err_task = | 373 | err_task = |
381 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL); | 374 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL); |
382 | start_time = GNUNET_TIME_absolute_get (); | 375 | start_time = GNUNET_TIME_absolute_get (); |
diff --git a/src/curl/Makefile.am b/src/curl/Makefile.am index 4bdd03039..9867ba634 100644 --- a/src/curl/Makefile.am +++ b/src/curl/Makefile.am | |||
@@ -17,6 +17,7 @@ libgnunetcurl_la_SOURCES = \ | |||
17 | libgnunetcurl_la_LIBADD = \ | 17 | libgnunetcurl_la_LIBADD = \ |
18 | $(top_builddir)/src/util/libgnunetutil.la \ | 18 | $(top_builddir)/src/util/libgnunetutil.la \ |
19 | -ljansson \ | 19 | -ljansson \ |
20 | -lcurl \ | ||
20 | $(XLIB) | 21 | $(XLIB) |
21 | 22 | ||
22 | #check_PROGRAMS = \ | 23 | #check_PROGRAMS = \ |
diff --git a/src/datastore/gnunet-datastore.c b/src/datastore/gnunet-datastore.c index 186889e4c..ddca4ee06 100644 --- a/src/datastore/gnunet-datastore.c +++ b/src/datastore/gnunet-datastore.c | |||
@@ -224,8 +224,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
224 | ret = 1; | 224 | ret = 1; |
225 | return; | 225 | return; |
226 | } | 226 | } |
227 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 227 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
228 | &do_shutdown, NULL); | ||
229 | do_get (); | 228 | do_get (); |
230 | } | 229 | } |
231 | 230 | ||
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c index fdccd925e..6ebfba7fc 100644 --- a/src/datastore/gnunet-service-datastore.c +++ b/src/datastore/gnunet-service-datastore.c | |||
@@ -391,7 +391,9 @@ static void | |||
391 | delete_expired (void *cls) | 391 | delete_expired (void *cls) |
392 | { | 392 | { |
393 | expired_kill_task = NULL; | 393 | expired_kill_task = NULL; |
394 | plugin->api->get_expiration (plugin->api->cls, &expired_processor, NULL); | 394 | plugin->api->get_expiration (plugin->api->cls, |
395 | &expired_processor, | ||
396 | NULL); | ||
395 | } | 397 | } |
396 | 398 | ||
397 | 399 | ||
@@ -1819,9 +1821,8 @@ run (void *cls, | |||
1819 | GNUNET_SERVER_disconnect_notify (server, | 1821 | GNUNET_SERVER_disconnect_notify (server, |
1820 | &cleanup_reservations, | 1822 | &cleanup_reservations, |
1821 | NULL); | 1823 | NULL); |
1822 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1824 | GNUNET_SCHEDULER_add_shutdown (&cleaning_task, |
1823 | &cleaning_task, | 1825 | NULL); |
1824 | NULL); | ||
1825 | } | 1826 | } |
1826 | 1827 | ||
1827 | 1828 | ||
diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c index 41cac1283..97774198c 100644 --- a/src/datastore/perf_datastore_api.c +++ b/src/datastore/perf_datastore_api.c | |||
@@ -351,11 +351,7 @@ run_continuation (void *cls) | |||
351 | static struct GNUNET_HashCode key; | 351 | static struct GNUNET_HashCode key; |
352 | static char data[65536]; | 352 | static char data[65536]; |
353 | char gstr[128]; | 353 | char gstr[128]; |
354 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
355 | 354 | ||
356 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
357 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
358 | crc->phase = RP_ERROR; | ||
359 | ok = (int) crc->phase; | 355 | ok = (int) crc->phase; |
360 | switch (crc->phase) | 356 | switch (crc->phase) |
361 | { | 357 | { |
diff --git a/src/datastore/perf_plugin_datastore.c b/src/datastore/perf_plugin_datastore.c index 0aeb426ab..cbc01844e 100644 --- a/src/datastore/perf_plugin_datastore.c +++ b/src/datastore/perf_plugin_datastore.c | |||
@@ -133,6 +133,7 @@ put_continuation (void *cls, | |||
133 | GNUNET_SCHEDULER_add_now (&test, crc); | 133 | GNUNET_SCHEDULER_add_now (&test, crc); |
134 | } | 134 | } |
135 | 135 | ||
136 | |||
136 | static void | 137 | static void |
137 | do_put (struct CpsRunContext *crc) | 138 | do_put (struct CpsRunContext *crc) |
138 | { | 139 | { |
@@ -195,9 +196,14 @@ do_put (struct CpsRunContext *crc) | |||
195 | 196 | ||
196 | 197 | ||
197 | static int | 198 | static int |
198 | iterate_zeros (void *cls, const struct GNUNET_HashCode * key, uint32_t size, | 199 | iterate_zeros (void *cls, |
199 | const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, | 200 | const struct GNUNET_HashCode *key, |
200 | uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, | 201 | uint32_t size, |
202 | const void *data, | ||
203 | enum GNUNET_BLOCK_Type type, | ||
204 | uint32_t priority, | ||
205 | uint32_t anonymity, | ||
206 | struct GNUNET_TIME_Absolute expiration, | ||
201 | uint64_t uid) | 207 | uint64_t uid) |
202 | { | 208 | { |
203 | struct CpsRunContext *crc = cls; | 209 | struct CpsRunContext *crc = cls; |
@@ -246,10 +252,15 @@ iterate_zeros (void *cls, const struct GNUNET_HashCode * key, uint32_t size, | |||
246 | 252 | ||
247 | 253 | ||
248 | static int | 254 | static int |
249 | expiration_get (void *cls, const struct GNUNET_HashCode * key, uint32_t size, | 255 | expiration_get (void *cls, |
250 | const void *data, enum GNUNET_BLOCK_Type type, | 256 | const struct GNUNET_HashCode *key, |
251 | uint32_t priority, uint32_t anonymity, | 257 | uint32_t size, |
252 | struct GNUNET_TIME_Absolute expiration, uint64_t uid) | 258 | const void *data, |
259 | enum GNUNET_BLOCK_Type type, | ||
260 | uint32_t priority, | ||
261 | uint32_t anonymity, | ||
262 | struct GNUNET_TIME_Absolute expiration, | ||
263 | uint64_t uid) | ||
253 | { | 264 | { |
254 | struct CpsRunContext *crc = cls; | 265 | struct CpsRunContext *crc = cls; |
255 | int i; | 266 | int i; |
@@ -293,10 +304,15 @@ expiration_get (void *cls, const struct GNUNET_HashCode * key, uint32_t size, | |||
293 | 304 | ||
294 | 305 | ||
295 | static int | 306 | static int |
296 | replication_get (void *cls, const struct GNUNET_HashCode * key, uint32_t size, | 307 | replication_get (void *cls, |
297 | const void *data, enum GNUNET_BLOCK_Type type, | 308 | const struct GNUNET_HashCode *key, |
298 | uint32_t priority, uint32_t anonymity, | 309 | uint32_t size, |
299 | struct GNUNET_TIME_Absolute expiration, uint64_t uid) | 310 | const void *data, |
311 | enum GNUNET_BLOCK_Type type, | ||
312 | uint32_t priority, | ||
313 | uint32_t anonymity, | ||
314 | struct GNUNET_TIME_Absolute expiration, | ||
315 | uint64_t uid) | ||
300 | { | 316 | { |
301 | struct CpsRunContext *crc = cls; | 317 | struct CpsRunContext *crc = cls; |
302 | int i; | 318 | int i; |
@@ -388,14 +404,7 @@ static void | |||
388 | test (void *cls) | 404 | test (void *cls) |
389 | { | 405 | { |
390 | struct CpsRunContext *crc = cls; | 406 | struct CpsRunContext *crc = cls; |
391 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
392 | 407 | ||
393 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
394 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
395 | { | ||
396 | GNUNET_break (0); | ||
397 | crc->phase = RP_ERROR; | ||
398 | } | ||
399 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 408 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
400 | "In phase %d, iteration %u\n", crc->phase, crc->cnt); | 409 | "In phase %d, iteration %u\n", crc->phase, crc->cnt); |
401 | switch (crc->phase) | 410 | switch (crc->phase) |
diff --git a/src/datastore/test_plugin_datastore.c b/src/datastore/test_plugin_datastore.c index d7dff1041..9ec0c53a2 100644 --- a/src/datastore/test_plugin_datastore.c +++ b/src/datastore/test_plugin_datastore.c | |||
@@ -267,14 +267,7 @@ test (void *cls) | |||
267 | { | 267 | { |
268 | struct CpsRunContext *crc = cls; | 268 | struct CpsRunContext *crc = cls; |
269 | struct GNUNET_HashCode key; | 269 | struct GNUNET_HashCode key; |
270 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
271 | 270 | ||
272 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
273 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
274 | { | ||
275 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test aborted.\n"); | ||
276 | crc->phase = RP_ERROR; | ||
277 | } | ||
278 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 271 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
279 | "In phase %d, iteration %u\n", crc->phase, crc->cnt); | 272 | "In phase %d, iteration %u\n", crc->phase, crc->cnt); |
280 | switch (crc->phase) | 273 | switch (crc->phase) |
diff --git a/src/dht/gnunet-dht-get.c b/src/dht/gnunet-dht-get.c index 6846b3af7..8a1b836f6 100644 --- a/src/dht/gnunet-dht-get.c +++ b/src/dht/gnunet-dht-get.c | |||
@@ -82,9 +82,14 @@ static unsigned int result_count; | |||
82 | */ | 82 | */ |
83 | static int ret; | 83 | static int ret; |
84 | 84 | ||
85 | /** | ||
86 | * Task scheduled to handle timeout. | ||
87 | */ | ||
88 | static struct GNUNET_SCHEDULER_Task *tt; | ||
89 | |||
85 | 90 | ||
86 | /** | 91 | /** |
87 | * Task run to clean up on timeout. | 92 | * Task run to clean up on shutdown. |
88 | * | 93 | * |
89 | * @param cls unused | 94 | * @param cls unused |
90 | */ | 95 | */ |
@@ -101,6 +106,24 @@ cleanup_task (void *cls) | |||
101 | GNUNET_DHT_disconnect (dht_handle); | 106 | GNUNET_DHT_disconnect (dht_handle); |
102 | dht_handle = NULL; | 107 | dht_handle = NULL; |
103 | } | 108 | } |
109 | if (NULL != tt) | ||
110 | { | ||
111 | GNUNET_SCHEDULER_cancel (tt); | ||
112 | tt = NULL; | ||
113 | } | ||
114 | } | ||
115 | |||
116 | |||
117 | /** | ||
118 | * Task run on timeout. Triggers shutdown. | ||
119 | * | ||
120 | * @param cls unused | ||
121 | */ | ||
122 | static void | ||
123 | timeout_task (void *cls) | ||
124 | { | ||
125 | tt = NULL; | ||
126 | GNUNET_SCHEDULER_shutdown (); | ||
104 | } | 127 | } |
105 | 128 | ||
106 | 129 | ||
@@ -170,8 +193,9 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
170 | GNUNET_CRYPTO_hash (query_key, strlen (query_key), &key); | 193 | GNUNET_CRYPTO_hash (query_key, strlen (query_key), &key); |
171 | if (verbose) | 194 | if (verbose) |
172 | FPRINTF (stderr, "%s `%s' \n", _("Issueing DHT GET with key"), GNUNET_h2s_full (&key)); | 195 | FPRINTF (stderr, "%s `%s' \n", _("Issueing DHT GET with key"), GNUNET_h2s_full (&key)); |
173 | GNUNET_SCHEDULER_add_delayed (timeout_request, | 196 | GNUNET_SCHEDULER_add_shutdown (&cleanup_task, NULL); |
174 | &cleanup_task, NULL); | 197 | tt = GNUNET_SCHEDULER_add_delayed (timeout_request, |
198 | &timeout_task, NULL); | ||
175 | get_handle = | 199 | get_handle = |
176 | GNUNET_DHT_get_start (dht_handle, query_type, &key, replication, | 200 | GNUNET_DHT_get_start (dht_handle, query_type, &key, replication, |
177 | (demultixplex_everywhere) ? GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE : GNUNET_DHT_RO_NONE, | 201 | (demultixplex_everywhere) ? GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE : GNUNET_DHT_RO_NONE, |
diff --git a/src/dht/gnunet-dht-monitor.c b/src/dht/gnunet-dht-monitor.c index 0502496d7..7f14255d3 100644 --- a/src/dht/gnunet-dht-monitor.c +++ b/src/dht/gnunet-dht-monitor.c | |||
@@ -71,6 +71,11 @@ static unsigned int result_count; | |||
71 | */ | 71 | */ |
72 | static int ret; | 72 | static int ret; |
73 | 73 | ||
74 | /** | ||
75 | * Task scheduled to handle timeout. | ||
76 | */ | ||
77 | static struct GNUNET_SCHEDULER_Task *tt; | ||
78 | |||
74 | 79 | ||
75 | /** | 80 | /** |
76 | * Stop monitoring request and start shutdown | 81 | * Stop monitoring request and start shutdown |
@@ -92,9 +97,28 @@ cleanup_task (void *cls) | |||
92 | GNUNET_DHT_disconnect (dht_handle); | 97 | GNUNET_DHT_disconnect (dht_handle); |
93 | dht_handle = NULL; | 98 | dht_handle = NULL; |
94 | } | 99 | } |
100 | if (NULL != tt) | ||
101 | { | ||
102 | GNUNET_SCHEDULER_cancel (tt); | ||
103 | tt = NULL; | ||
104 | } | ||
105 | } | ||
106 | |||
107 | |||
108 | /** | ||
109 | * We hit a timeout. Stop monitoring request and start shutdown | ||
110 | * | ||
111 | * @param cls closure (unused) | ||
112 | */ | ||
113 | static void | ||
114 | timeout_task (void *cls) | ||
115 | { | ||
116 | tt = NULL; | ||
117 | GNUNET_SCHEDULER_shutdown (); | ||
95 | } | 118 | } |
96 | 119 | ||
97 | 120 | ||
121 | |||
98 | /** | 122 | /** |
99 | * Callback called on each GET request going through the DHT. | 123 | * Callback called on each GET request going through the DHT. |
100 | * | 124 | * |
@@ -107,7 +131,7 @@ cleanup_task (void *cls) | |||
107 | * @param desired_replication_level Desired replication level. | 131 | * @param desired_replication_level Desired replication level. |
108 | * @param key Key of the requested data. | 132 | * @param key Key of the requested data. |
109 | */ | 133 | */ |
110 | void | 134 | static void |
111 | get_callback (void *cls, | 135 | get_callback (void *cls, |
112 | enum GNUNET_DHT_RouteOption options, | 136 | enum GNUNET_DHT_RouteOption options, |
113 | enum GNUNET_BLOCK_Type type, | 137 | enum GNUNET_BLOCK_Type type, |
@@ -139,7 +163,7 @@ get_callback (void *cls, | |||
139 | * @param data Pointer to the result data. | 163 | * @param data Pointer to the result data. |
140 | * @param size Number of bytes in data. | 164 | * @param size Number of bytes in data. |
141 | */ | 165 | */ |
142 | void | 166 | static void |
143 | get_resp_callback (void *cls, | 167 | get_resp_callback (void *cls, |
144 | enum GNUNET_BLOCK_Type type, | 168 | enum GNUNET_BLOCK_Type type, |
145 | const struct GNUNET_PeerIdentity *get_path, | 169 | const struct GNUNET_PeerIdentity *get_path, |
@@ -177,7 +201,7 @@ get_resp_callback (void *cls, | |||
177 | * @param data Pointer to the data carried. | 201 | * @param data Pointer to the data carried. |
178 | * @param size Number of bytes in data. | 202 | * @param size Number of bytes in data. |
179 | */ | 203 | */ |
180 | void | 204 | static void |
181 | put_callback (void *cls, | 205 | put_callback (void *cls, |
182 | enum GNUNET_DHT_RouteOption options, | 206 | enum GNUNET_DHT_RouteOption options, |
183 | enum GNUNET_BLOCK_Type type, | 207 | enum GNUNET_BLOCK_Type type, |
@@ -242,7 +266,11 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
242 | FPRINTF (stderr, | 266 | FPRINTF (stderr, |
243 | "Monitoring for %s\n", | 267 | "Monitoring for %s\n", |
244 | GNUNET_STRINGS_relative_time_to_string (timeout_request, GNUNET_NO)); | 268 | GNUNET_STRINGS_relative_time_to_string (timeout_request, GNUNET_NO)); |
245 | GNUNET_SCHEDULER_add_delayed (timeout_request, &cleanup_task, NULL); | 269 | tt = GNUNET_SCHEDULER_add_delayed (timeout_request, |
270 | &timeout_task, | ||
271 | NULL); | ||
272 | GNUNET_SCHEDULER_add_shutdown (&cleanup_task, | ||
273 | NULL); | ||
246 | monitor_handle = GNUNET_DHT_monitor_start (dht_handle, | 274 | monitor_handle = GNUNET_DHT_monitor_start (dht_handle, |
247 | block_type, | 275 | block_type, |
248 | key, | 276 | key, |
diff --git a/src/dht/gnunet-dht-put.c b/src/dht/gnunet-dht-put.c index 19e385be1..972369e10 100644 --- a/src/dht/gnunet-dht-put.c +++ b/src/dht/gnunet-dht-put.c | |||
@@ -98,6 +98,7 @@ shutdown_task (void *cls) | |||
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | |||
101 | /** | 102 | /** |
102 | * Signature of the main function of a task. | 103 | * Signature of the main function of a task. |
103 | * | 104 | * |
@@ -132,6 +133,7 @@ message_sent_cont (void *cls, int success) | |||
132 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | 133 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); |
133 | } | 134 | } |
134 | 135 | ||
136 | |||
135 | /** | 137 | /** |
136 | * Main function that will be run by the scheduler. | 138 | * Main function that will be run by the scheduler. |
137 | * | 139 | * |
@@ -141,14 +143,15 @@ message_sent_cont (void *cls, int success) | |||
141 | * @param c configuration | 143 | * @param c configuration |
142 | */ | 144 | */ |
143 | static void | 145 | static void |
144 | run (void *cls, char *const *args, const char *cfgfile, | 146 | run (void *cls, |
147 | char *const *args, | ||
148 | const char *cfgfile, | ||
145 | const struct GNUNET_CONFIGURATION_Handle *c) | 149 | const struct GNUNET_CONFIGURATION_Handle *c) |
146 | { | 150 | { |
147 | struct GNUNET_TIME_Relative timeout; | 151 | struct GNUNET_TIME_Relative timeout; |
148 | struct GNUNET_TIME_Absolute expiration; | 152 | struct GNUNET_TIME_Absolute expiration; |
149 | 153 | ||
150 | cfg = c; | 154 | cfg = c; |
151 | |||
152 | if ((NULL == query_key) || (NULL == data)) | 155 | if ((NULL == query_key) || (NULL == data)) |
153 | { | 156 | { |
154 | FPRINTF (stderr, "%s", _("Must provide KEY and DATA for DHT put!\n")); | 157 | FPRINTF (stderr, "%s", _("Must provide KEY and DATA for DHT put!\n")); |
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index 1aeca9b85..a44be2dfe 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c | |||
@@ -161,9 +161,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
161 | shutdown_task (NULL); | 161 | shutdown_task (NULL); |
162 | return; | 162 | return; |
163 | } | 163 | } |
164 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 164 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
165 | &shutdown_task, | 165 | NULL); |
166 | NULL); | ||
167 | GDS_transport_handle = | 166 | GDS_transport_handle = |
168 | GNUNET_TRANSPORT_connect (GDS_cfg, NULL, NULL, NULL, NULL, NULL); | 167 | GNUNET_TRANSPORT_connect (GDS_cfg, NULL, NULL, NULL, NULL, NULL); |
169 | if (GDS_transport_handle == NULL) | 168 | if (GDS_transport_handle == NULL) |
diff --git a/src/dht/gnunet-service-dht_clients.c b/src/dht/gnunet-service-dht_clients.c index e42069fe0..a5757c25a 100644 --- a/src/dht/gnunet-service-dht_clients.c +++ b/src/dht/gnunet-service-dht_clients.c | |||
@@ -456,12 +456,8 @@ transmit_next_request_task (void *cls) | |||
456 | { | 456 | { |
457 | struct ClientQueryRecord *cqr; | 457 | struct ClientQueryRecord *cqr; |
458 | struct GNUNET_TIME_Relative delay; | 458 | struct GNUNET_TIME_Relative delay; |
459 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
460 | 459 | ||
461 | retry_task = NULL; | 460 | retry_task = NULL; |
462 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
463 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
464 | return; | ||
465 | while (NULL != (cqr = GNUNET_CONTAINER_heap_remove_root (retry_heap))) | 461 | while (NULL != (cqr = GNUNET_CONTAINER_heap_remove_root (retry_heap))) |
466 | { | 462 | { |
467 | cqr->hnode = NULL; | 463 | cqr->hnode = NULL; |
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c index d82effb34..8ab39c9aa 100644 --- a/src/dht/gnunet-service-dht_neighbours.c +++ b/src/dht/gnunet-service-dht_neighbours.c | |||
@@ -712,12 +712,8 @@ send_find_peer_message (void *cls) | |||
712 | struct GNUNET_TIME_Relative next_send_time; | 712 | struct GNUNET_TIME_Relative next_send_time; |
713 | struct BloomConstructorContext bcc; | 713 | struct BloomConstructorContext bcc; |
714 | struct GNUNET_CONTAINER_BloomFilter *peer_bf; | 714 | struct GNUNET_CONTAINER_BloomFilter *peer_bf; |
715 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
716 | 715 | ||
717 | find_peer_task = NULL; | 716 | find_peer_task = NULL; |
718 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
719 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
720 | return; | ||
721 | if (newly_found_peers > bucket_size) | 717 | if (newly_found_peers > bucket_size) |
722 | { | 718 | { |
723 | /* If we are finding many peers already, no need to send out our request right now! */ | 719 | /* If we are finding many peers already, no need to send out our request right now! */ |
@@ -2443,6 +2439,7 @@ GDS_NEIGHBOURS_done () | |||
2443 | } | 2439 | } |
2444 | } | 2440 | } |
2445 | 2441 | ||
2442 | |||
2446 | /** | 2443 | /** |
2447 | * Get the ID of the local node. | 2444 | * Get the ID of the local node. |
2448 | * | 2445 | * |
diff --git a/src/dht/gnunet-service-wdht.c b/src/dht/gnunet-service-wdht.c index 0668c9078..b58bb729d 100644 --- a/src/dht/gnunet-service-wdht.c +++ b/src/dht/gnunet-service-wdht.c | |||
@@ -102,9 +102,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
102 | shutdown_task (NULL); | 102 | shutdown_task (NULL); |
103 | return; | 103 | return; |
104 | } | 104 | } |
105 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 105 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
106 | &shutdown_task, | 106 | NULL); |
107 | NULL); | ||
108 | } | 107 | } |
109 | 108 | ||
110 | 109 | ||
diff --git a/src/dht/gnunet-service-wdht_clients.c b/src/dht/gnunet-service-wdht_clients.c index c3aff03aa..8eb114660 100644 --- a/src/dht/gnunet-service-wdht_clients.c +++ b/src/dht/gnunet-service-wdht_clients.c | |||
@@ -880,12 +880,8 @@ transmit_next_request_task (void *cls) | |||
880 | { | 880 | { |
881 | struct ClientQueryRecord *cqr; | 881 | struct ClientQueryRecord *cqr; |
882 | struct GNUNET_TIME_Relative delay; | 882 | struct GNUNET_TIME_Relative delay; |
883 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
884 | 883 | ||
885 | retry_task = NULL; | 884 | retry_task = NULL; |
886 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
887 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
888 | return; | ||
889 | while (NULL != (cqr = GNUNET_CONTAINER_heap_remove_root (retry_heap))) | 885 | while (NULL != (cqr = GNUNET_CONTAINER_heap_remove_root (retry_heap))) |
890 | { | 886 | { |
891 | cqr->hnode = NULL; | 887 | cqr->hnode = NULL; |
diff --git a/src/dht/gnunet-service-xdht.c b/src/dht/gnunet-service-xdht.c index f6c7c5167..8a60a8d9d 100644 --- a/src/dht/gnunet-service-xdht.c +++ b/src/dht/gnunet-service-xdht.c | |||
@@ -17,14 +17,12 @@ | |||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | Boston, MA 02110-1301, USA. | 18 | Boston, MA 02110-1301, USA. |
19 | */ | 19 | */ |
20 | |||
21 | /** | 20 | /** |
22 | * @file dht/gnunet-service-xdht.c | 21 | * @file dht/gnunet-service-xdht.c |
23 | * @brief GNUnet DHT service | 22 | * @brief GNUnet DHT service |
24 | * @author Christian Grothoff | 23 | * @author Christian Grothoff |
25 | * @author Nathan Evans | 24 | * @author Nathan Evans |
26 | */ | 25 | */ |
27 | |||
28 | #include "platform.h" | 26 | #include "platform.h" |
29 | #include "gnunet_block_lib.h" | 27 | #include "gnunet_block_lib.h" |
30 | #include "gnunet_util_lib.h" | 28 | #include "gnunet_util_lib.h" |
@@ -125,9 +123,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
125 | shutdown_task (NULL); | 123 | shutdown_task (NULL); |
126 | return; | 124 | return; |
127 | } | 125 | } |
128 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 126 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
129 | &shutdown_task, | 127 | NULL); |
130 | NULL); | ||
131 | } | 128 | } |
132 | 129 | ||
133 | 130 | ||
diff --git a/src/dht/gnunet-service-xdht_clients.c b/src/dht/gnunet-service-xdht_clients.c index e08ccf792..3475d00c9 100644 --- a/src/dht/gnunet-service-xdht_clients.c +++ b/src/dht/gnunet-service-xdht_clients.c | |||
@@ -877,12 +877,8 @@ transmit_next_request_task (void *cls) | |||
877 | { | 877 | { |
878 | struct ClientQueryRecord *cqr; | 878 | struct ClientQueryRecord *cqr; |
879 | struct GNUNET_TIME_Relative delay; | 879 | struct GNUNET_TIME_Relative delay; |
880 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
881 | 880 | ||
882 | retry_task = NULL; | 881 | retry_task = NULL; |
883 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
884 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
885 | return; | ||
886 | while (NULL != (cqr = GNUNET_CONTAINER_heap_remove_root (retry_heap))) | 882 | while (NULL != (cqr = GNUNET_CONTAINER_heap_remove_root (retry_heap))) |
887 | { | 883 | { |
888 | cqr->hnode = NULL; | 884 | cqr->hnode = NULL; |
diff --git a/src/dht/gnunet_dht_profiler.c b/src/dht/gnunet_dht_profiler.c index f0c4ec7be..03ea62152 100644 --- a/src/dht/gnunet_dht_profiler.c +++ b/src/dht/gnunet_dht_profiler.c | |||
@@ -461,9 +461,21 @@ do_shutdown (void *cls) | |||
461 | a_ctx = NULL; | 461 | a_ctx = NULL; |
462 | } | 462 | } |
463 | //FIXME: Should we collect stats only for put/get not for other messages. | 463 | //FIXME: Should we collect stats only for put/get not for other messages. |
464 | if(NULL != bandwidth_stats_op) | 464 | if (NULL != bandwidth_stats_op) |
465 | { | ||
465 | GNUNET_TESTBED_operation_done (bandwidth_stats_op); | 466 | GNUNET_TESTBED_operation_done (bandwidth_stats_op); |
466 | bandwidth_stats_op = NULL; | 467 | bandwidth_stats_op = NULL; |
468 | } | ||
469 | if (NULL != successor_stats_op) | ||
470 | { | ||
471 | GNUNET_TESTBED_operation_done (successor_stats_op); | ||
472 | successor_stats_op = NULL; | ||
473 | } | ||
474 | if (NULL != successor_stats_task) | ||
475 | { | ||
476 | GNUNET_SCHEDULER_cancel (successor_stats_task); | ||
477 | successor_stats_task = NULL; | ||
478 | } | ||
467 | GNUNET_free_non_null (a_ac); | 479 | GNUNET_free_non_null (a_ac); |
468 | } | 480 | } |
469 | 481 | ||
@@ -687,11 +699,7 @@ teardown_dht_connection (void *cls) | |||
687 | { | 699 | { |
688 | struct Context *ctx = cls; | 700 | struct Context *ctx = cls; |
689 | struct GNUNET_TESTBED_Operation *op; | 701 | struct GNUNET_TESTBED_Operation *op; |
690 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
691 | 702 | ||
692 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
693 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | ||
694 | return; | ||
695 | GNUNET_assert (NULL != ctx); | 703 | GNUNET_assert (NULL != ctx); |
696 | GNUNET_assert (NULL != (op = ctx->op)); | 704 | GNUNET_assert (NULL != (op = ctx->op)); |
697 | ctx->op = NULL; | 705 | ctx->op = NULL; |
@@ -1070,7 +1078,7 @@ successor_stats_cont (void *cls, | |||
1070 | successor_stats_op = NULL; | 1078 | successor_stats_op = NULL; |
1071 | if (0 == max_searches) | 1079 | if (0 == max_searches) |
1072 | { | 1080 | { |
1073 | start_func(); | 1081 | start_func (); |
1074 | return; | 1082 | return; |
1075 | } | 1083 | } |
1076 | 1084 | ||
@@ -1108,39 +1116,27 @@ successor_stats_cont (void *cls, | |||
1108 | GNUNET_NO); | 1116 | GNUNET_NO); |
1109 | if ((start_val == val) && (count == num_peers)) | 1117 | if ((start_val == val) && (count == num_peers)) |
1110 | { | 1118 | { |
1111 | DEBUG("CIRCLE COMPLETED after %u tries", tries); | 1119 | DEBUG ("CIRCLE COMPLETED after %u tries", tries); |
1112 | if(NULL == successor_stats_task) | 1120 | if(NULL == successor_stats_task) |
1113 | { | 1121 | { |
1114 | start_func(); | 1122 | start_func(); |
1115 | } | 1123 | } |
1116 | return; | 1124 | return; |
1117 | } | 1125 | } |
1118 | else | 1126 | if (max_searches == ++tries) |
1119 | { | 1127 | { |
1120 | if (max_searches == ++tries) | 1128 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1121 | { | 1129 | "Maximum tries %u exceeded while checking successor TOTAL TRIES %u" |
1122 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1130 | " circle formation. Exiting\n", |
1123 | "Maximum tries %u exceeded while checking successor TOTAL TRIES %u" | 1131 | max_searches,tries); |
1124 | " circle formation. Exiting\n", | 1132 | start_func(); |
1125 | max_searches,tries); | 1133 | return; |
1126 | if (NULL != successor_stats_task) | ||
1127 | { | ||
1128 | successor_stats_task = NULL; | ||
1129 | } | ||
1130 | if(NULL == successor_stats_task) | ||
1131 | { | ||
1132 | start_func(); | ||
1133 | } | ||
1134 | |||
1135 | return; | ||
1136 | } | ||
1137 | else | ||
1138 | { | ||
1139 | flag = 0; | ||
1140 | successor_stats_task = GNUNET_SCHEDULER_add_delayed (delay_stats, | ||
1141 | &collect_stats, cls); | ||
1142 | } | ||
1143 | } | 1134 | } |
1135 | flag = 0; | ||
1136 | successor_stats_task | ||
1137 | = GNUNET_SCHEDULER_add_delayed (delay_stats, | ||
1138 | &collect_stats, | ||
1139 | cls); | ||
1144 | } | 1140 | } |
1145 | 1141 | ||
1146 | 1142 | ||
@@ -1214,26 +1210,21 @@ successor_stats_iterator (void *cls, | |||
1214 | static void | 1210 | static void |
1215 | collect_stats (void *cls) | 1211 | collect_stats (void *cls) |
1216 | { | 1212 | { |
1217 | const struct GNUNET_SCHEDULER_TaskContext *tc; | 1213 | successor_stats_task = NULL; |
1218 | |||
1219 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
1220 | if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0) | ||
1221 | return; | ||
1222 | |||
1223 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1214 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1224 | "Start collecting statistics...\n"); | 1215 | "Start collecting statistics...\n"); |
1225 | GNUNET_assert(NULL != testbed_handles); | 1216 | GNUNET_assert(NULL != testbed_handles); |
1226 | 1217 | ||
1227 | if (0 != max_searches) | 1218 | if (0 != max_searches) |
1228 | successor_peer_hashmap = GNUNET_CONTAINER_multihashmap_create (num_peers, | 1219 | successor_peer_hashmap |
1229 | GNUNET_NO); | 1220 | = GNUNET_CONTAINER_multihashmap_create (num_peers, |
1230 | successor_stats_op = | 1221 | GNUNET_NO); |
1231 | GNUNET_TESTBED_get_statistics (num_peers, testbed_handles, | 1222 | successor_stats_op |
1232 | "dht", NULL, | 1223 | = GNUNET_TESTBED_get_statistics (num_peers, testbed_handles, |
1233 | successor_stats_iterator, | 1224 | "dht", NULL, |
1234 | successor_stats_cont, cls); | 1225 | successor_stats_iterator, |
1235 | 1226 | successor_stats_cont, cls); | |
1236 | GNUNET_assert(NULL != successor_stats_op); | 1227 | GNUNET_assert (NULL != successor_stats_op); |
1237 | } | 1228 | } |
1238 | 1229 | ||
1239 | 1230 | ||
@@ -1265,9 +1256,10 @@ service_started (void *cls, | |||
1265 | collect_stat_cls->service_connect_ctx = cls; | 1256 | collect_stat_cls->service_connect_ctx = cls; |
1266 | collect_stat_cls->op = op; | 1257 | collect_stat_cls->op = op; |
1267 | 1258 | ||
1268 | successor_stats_task = GNUNET_SCHEDULER_add_delayed (delay_stats, | 1259 | successor_stats_task |
1269 | &collect_stats, | 1260 | = GNUNET_SCHEDULER_add_delayed (delay_stats, |
1270 | collect_stat_cls); | 1261 | &collect_stats, |
1262 | collect_stat_cls); | ||
1271 | } | 1263 | } |
1272 | } | 1264 | } |
1273 | 1265 | ||
@@ -1393,7 +1385,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1393 | 1385 | ||
1394 | if (0 == num_peers) | 1386 | if (0 == num_peers) |
1395 | { | 1387 | { |
1396 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Exiting as the number of peers is %u\n"), | 1388 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1389 | _("Exiting as the number of peers is %u\n"), | ||
1397 | num_peers); | 1390 | num_peers); |
1398 | return; | 1391 | return; |
1399 | } | 1392 | } |
@@ -1401,8 +1394,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1401 | event_mask = 0; | 1394 | event_mask = 0; |
1402 | GNUNET_TESTBED_run (hosts_file, cfg, num_peers, event_mask, NULL, | 1395 | GNUNET_TESTBED_run (hosts_file, cfg, num_peers, event_mask, NULL, |
1403 | NULL, &test_run, NULL); | 1396 | NULL, &test_run, NULL); |
1404 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &do_shutdown, | 1397 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, |
1405 | NULL); | 1398 | NULL); |
1406 | } | 1399 | } |
1407 | 1400 | ||
1408 | 1401 | ||
diff --git a/src/dns/dnsstub.c b/src/dns/dnsstub.c index 957777cba..c1e7b5f61 100644 --- a/src/dns/dnsstub.c +++ b/src/dns/dnsstub.c | |||
@@ -476,7 +476,7 @@ read_response (void *cls) | |||
476 | tc = GNUNET_SCHEDULER_get_task_context (); | 476 | tc = GNUNET_SCHEDULER_get_task_context (); |
477 | if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) | 477 | if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) |
478 | { | 478 | { |
479 | /* timeout or shutdown */ | 479 | /* timeout */ |
480 | cleanup_rs (rs); | 480 | cleanup_rs (rs); |
481 | return; | 481 | return; |
482 | } | 482 | } |
diff --git a/src/dns/gnunet-dns-monitor.c b/src/dns/gnunet-dns-monitor.c index c9d840325..5e6f90555 100644 --- a/src/dns/gnunet-dns-monitor.c +++ b/src/dns/gnunet-dns-monitor.c | |||
@@ -339,8 +339,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
339 | flags, | 339 | flags, |
340 | &display_request, | 340 | &display_request, |
341 | NULL); | 341 | NULL); |
342 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 342 | GNUNET_SCHEDULER_add_shutdown (&do_disconnect, NULL); |
343 | &do_disconnect, NULL); | ||
344 | } | 343 | } |
345 | 344 | ||
346 | 345 | ||
diff --git a/src/dns/gnunet-dns-redirector.c b/src/dns/gnunet-dns-redirector.c index 8ef69eb91..89929815a 100644 --- a/src/dns/gnunet-dns-redirector.c +++ b/src/dns/gnunet-dns-redirector.c | |||
@@ -223,8 +223,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
223 | GNUNET_DNS_FLAG_POST_RESOLUTION, | 223 | GNUNET_DNS_FLAG_POST_RESOLUTION, |
224 | &modify_request, | 224 | &modify_request, |
225 | NULL); | 225 | NULL); |
226 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 226 | GNUNET_SCHEDULER_add_shutdown (&do_disconnect, NULL); |
227 | &do_disconnect, NULL); | ||
228 | } | 227 | } |
229 | 228 | ||
230 | 229 | ||
diff --git a/src/dns/gnunet-service-dns.c b/src/dns/gnunet-service-dns.c index 972c96f6d..b580f433f 100644 --- a/src/dns/gnunet-service-dns.c +++ b/src/dns/gnunet-service-dns.c | |||
@@ -1045,9 +1045,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
1045 | cfg = cfg_; | 1045 | cfg = cfg_; |
1046 | stats = GNUNET_STATISTICS_create ("dns", cfg); | 1046 | stats = GNUNET_STATISTICS_create ("dns", cfg); |
1047 | nc = GNUNET_SERVER_notification_context_create (server, 1); | 1047 | nc = GNUNET_SERVER_notification_context_create (server, 1); |
1048 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1048 | GNUNET_SCHEDULER_add_shutdown (&cleanup_task, |
1049 | &cleanup_task, | 1049 | cls); |
1050 | cls); | ||
1051 | dns_exit = NULL; | 1050 | dns_exit = NULL; |
1052 | if ( ( (GNUNET_OK != | 1051 | if ( ( (GNUNET_OK != |
1053 | GNUNET_CONFIGURATION_get_value_string (cfg, | 1052 | GNUNET_CONFIGURATION_get_value_string (cfg, |
diff --git a/src/dv/gnunet-dv.c b/src/dv/gnunet-dv.c index d5d95acca..d0917d363 100644 --- a/src/dv/gnunet-dv.c +++ b/src/dv/gnunet-dv.c | |||
@@ -145,8 +145,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
145 | &change_cb, | 145 | &change_cb, |
146 | &disconnect_cb, | 146 | &disconnect_cb, |
147 | &message_cb); | 147 | &message_cb); |
148 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 148 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
149 | &shutdown_task, NULL); | ||
150 | } | 149 | } |
151 | 150 | ||
152 | 151 | ||
diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c index bd0057ab4..df95fd67b 100644 --- a/src/dv/gnunet-service-dv.c +++ b/src/dv/gnunet-service-dv.c | |||
@@ -2229,8 +2229,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
2229 | MAX_QUEUE_SIZE_PLUGIN); | 2229 | MAX_QUEUE_SIZE_PLUGIN); |
2230 | stats = GNUNET_STATISTICS_create ("dv", cfg); | 2230 | stats = GNUNET_STATISTICS_create ("dv", cfg); |
2231 | GNUNET_SERVER_add_handlers (server, plugin_handlers); | 2231 | GNUNET_SERVER_add_handlers (server, plugin_handlers); |
2232 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 2232 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
2233 | &shutdown_task, NULL); | ||
2234 | } | 2233 | } |
2235 | 2234 | ||
2236 | 2235 | ||
diff --git a/src/dv/test_transport_dv.c b/src/dv/test_transport_dv.c index 1afa30fa9..0a43252a5 100644 --- a/src/dv/test_transport_dv.c +++ b/src/dv/test_transport_dv.c | |||
@@ -82,8 +82,8 @@ test_connection (void *cls, | |||
82 | unsigned int links_succeeded, | 82 | unsigned int links_succeeded, |
83 | unsigned int links_failed) | 83 | unsigned int links_failed) |
84 | { | 84 | { |
85 | shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 85 | shutdown_task = GNUNET_SCHEDULER_add_shutdown (&do_shutdown, |
86 | &do_shutdown, NULL); | 86 | NULL); |
87 | if (4 != num_peers) | 87 | if (4 != num_peers) |
88 | { | 88 | { |
89 | ok = 1; | 89 | ok = 1; |
diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c index 8456018ab..f31e11d83 100644 --- a/src/exit/gnunet-daemon-exit.c +++ b/src/exit/gnunet-daemon-exit.c | |||
@@ -3149,7 +3149,6 @@ dummy_task (void *cls) | |||
3149 | * Function scheduled as very last function, cleans up after us | 3149 | * Function scheduled as very last function, cleans up after us |
3150 | * | 3150 | * |
3151 | * @param cls NULL | 3151 | * @param cls NULL |
3152 | * @param tc scheduler context | ||
3153 | */ | 3152 | */ |
3154 | static void | 3153 | static void |
3155 | cleanup (void *cls) | 3154 | cleanup (void *cls) |
@@ -3548,9 +3547,8 @@ run (void *cls, | |||
3548 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 3547 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
3549 | _("`%s' must be installed SUID, EXIT will not work\n"), | 3548 | _("`%s' must be installed SUID, EXIT will not work\n"), |
3550 | "gnunet-helper-exit"); | 3549 | "gnunet-helper-exit"); |
3551 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 3550 | GNUNET_SCHEDULER_add_shutdown (&dummy_task, |
3552 | &dummy_task, | 3551 | NULL); |
3553 | NULL); | ||
3554 | global_ret = 1; | 3552 | global_ret = 1; |
3555 | return; | 3553 | return; |
3556 | } | 3554 | } |
@@ -3639,9 +3637,8 @@ run (void *cls, | |||
3639 | app_idx++; | 3637 | app_idx++; |
3640 | } | 3638 | } |
3641 | GNUNET_free_non_null (dns_exit); | 3639 | GNUNET_free_non_null (dns_exit); |
3642 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 3640 | GNUNET_SCHEDULER_add_shutdown (&cleanup, |
3643 | &cleanup, | 3641 | NULL); |
3644 | cls); | ||
3645 | 3642 | ||
3646 | if (GNUNET_OK != | 3643 | if (GNUNET_OK != |
3647 | GNUNET_CONFIGURATION_get_value_number (cfg, "exit", "MAX_CONNECTIONS", | 3644 | GNUNET_CONFIGURATION_get_value_number (cfg, "exit", "MAX_CONNECTIONS", |
diff --git a/src/fs/gnunet-auto-share.c b/src/fs/gnunet-auto-share.c index aef66614c..96f86bf5d 100644 --- a/src/fs/gnunet-auto-share.c +++ b/src/fs/gnunet-auto-share.c | |||
@@ -95,11 +95,6 @@ static int disable_extractor; | |||
95 | static int do_disable_creation_time; | 95 | static int do_disable_creation_time; |
96 | 96 | ||
97 | /** | 97 | /** |
98 | * Handle for the 'shutdown' task. | ||
99 | */ | ||
100 | static struct GNUNET_SCHEDULER_Task *kill_task; | ||
101 | |||
102 | /** | ||
103 | * Handle for the main task that does scanning and working. | 98 | * Handle for the main task that does scanning and working. |
104 | */ | 99 | */ |
105 | static struct GNUNET_SCHEDULER_Task *run_task; | 100 | static struct GNUNET_SCHEDULER_Task *run_task; |
@@ -321,7 +316,6 @@ save_state () | |||
321 | static void | 316 | static void |
322 | do_stop_task (void *cls) | 317 | do_stop_task (void *cls) |
323 | { | 318 | { |
324 | kill_task = NULL; | ||
325 | do_shutdown = GNUNET_YES; | 319 | do_shutdown = GNUNET_YES; |
326 | if (NULL != publish_proc) | 320 | if (NULL != publish_proc) |
327 | { | 321 | { |
@@ -729,10 +723,8 @@ run (void *cls, | |||
729 | run_task = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, | 723 | run_task = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, |
730 | &scan, | 724 | &scan, |
731 | NULL); | 725 | NULL); |
732 | kill_task = | 726 | GNUNET_SCHEDULER_add_shutdown (&do_stop_task, |
733 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 727 | NULL); |
734 | &do_stop_task, | ||
735 | NULL); | ||
736 | } | 728 | } |
737 | 729 | ||
738 | 730 | ||
diff --git a/src/fs/gnunet-daemon-fsprofiler.c b/src/fs/gnunet-daemon-fsprofiler.c index 326178df9..e6bc33e10 100644 --- a/src/fs/gnunet-daemon-fsprofiler.c +++ b/src/fs/gnunet-daemon-fsprofiler.c | |||
@@ -500,12 +500,8 @@ start_publish (void *cls) | |||
500 | { | 500 | { |
501 | struct Pattern *p = cls; | 501 | struct Pattern *p = cls; |
502 | struct GNUNET_FS_FileInformation *fi; | 502 | struct GNUNET_FS_FileInformation *fi; |
503 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
504 | 503 | ||
505 | p->task = NULL; | 504 | p->task = NULL; |
506 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
507 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
508 | return; | ||
509 | fi = make_file (p->x, p->y, p); | 505 | fi = make_file (p->x, p->y, p); |
510 | p->start_time = GNUNET_TIME_absolute_get (); | 506 | p->start_time = GNUNET_TIME_absolute_get (); |
511 | p->ctx = GNUNET_FS_publish_start (fs_handle, | 507 | p->ctx = GNUNET_FS_publish_start (fs_handle, |
@@ -525,12 +521,8 @@ start_download (void *cls) | |||
525 | { | 521 | { |
526 | struct Pattern *p = cls; | 522 | struct Pattern *p = cls; |
527 | struct GNUNET_FS_Uri *keywords; | 523 | struct GNUNET_FS_Uri *keywords; |
528 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
529 | 524 | ||
530 | p->task = NULL; | 525 | p->task = NULL; |
531 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
532 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
533 | return; | ||
534 | keywords = make_keywords (p->x); | 526 | keywords = make_keywords (p->x); |
535 | p->start_time = GNUNET_TIME_absolute_get (); | 527 | p->start_time = GNUNET_TIME_absolute_get (); |
536 | p->sctx = GNUNET_FS_search_start (fs_handle, keywords, | 528 | p->sctx = GNUNET_FS_search_start (fs_handle, keywords, |
@@ -558,8 +550,8 @@ run (void *cls, char *const *args GNUNET_UNUSED, | |||
558 | 550 | ||
559 | cfg = cfg_; | 551 | cfg = cfg_; |
560 | /* Scheduled the task to clean up when shutdown is called */ | 552 | /* Scheduled the task to clean up when shutdown is called */ |
561 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 553 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
562 | NULL); | 554 | NULL); |
563 | 555 | ||
564 | if (GNUNET_OK != | 556 | if (GNUNET_OK != |
565 | GNUNET_CONFIGURATION_get_value_number (cfg, | 557 | GNUNET_CONFIGURATION_get_value_number (cfg, |
diff --git a/src/fs/gnunet-download.c b/src/fs/gnunet-download.c index a2b0aa5fc..6d9adb8ab 100644 --- a/src/fs/gnunet-download.c +++ b/src/fs/gnunet-download.c | |||
@@ -284,8 +284,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
284 | ctx = NULL; | 284 | ctx = NULL; |
285 | return; | 285 | return; |
286 | } | 286 | } |
287 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 287 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
288 | NULL); | 288 | NULL); |
289 | } | 289 | } |
290 | 290 | ||
291 | 291 | ||
diff --git a/src/fs/gnunet-fs-profiler.c b/src/fs/gnunet-fs-profiler.c index 69433346f..cfbe57bbd 100644 --- a/src/fs/gnunet-fs-profiler.c +++ b/src/fs/gnunet-fs-profiler.c | |||
@@ -105,7 +105,7 @@ process_stats (void *cls, | |||
105 | 105 | ||
106 | 106 | ||
107 | /** | 107 | /** |
108 | * Task run on timeout to terminate. Triggers printing out | 108 | * Task run on shutdown to terminate. Triggers printing out |
109 | * all statistics. | 109 | * all statistics. |
110 | * | 110 | * |
111 | * @param cls NULL | 111 | * @param cls NULL |
@@ -113,7 +113,11 @@ process_stats (void *cls, | |||
113 | static void | 113 | static void |
114 | terminate_task (void *cls) | 114 | terminate_task (void *cls) |
115 | { | 115 | { |
116 | terminate_taskid = NULL; | 116 | if (NULL != terminate_taskid) |
117 | { | ||
118 | GNUNET_SCHEDULER_cancel (terminate_taskid); | ||
119 | terminate_taskid = NULL; | ||
120 | } | ||
117 | GNUNET_TESTBED_get_statistics (0, NULL, | 121 | GNUNET_TESTBED_get_statistics (0, NULL, |
118 | NULL, NULL, | 122 | NULL, NULL, |
119 | &process_stats, | 123 | &process_stats, |
@@ -123,6 +127,20 @@ terminate_task (void *cls) | |||
123 | 127 | ||
124 | 128 | ||
125 | /** | 129 | /** |
130 | * Task run on timeout to terminate. Triggers printing out | ||
131 | * all statistics. | ||
132 | * | ||
133 | * @param cls NULL | ||
134 | */ | ||
135 | static void | ||
136 | timeout_task (void *cls) | ||
137 | { | ||
138 | terminate_taskid = NULL; | ||
139 | GNUNET_SCHEDULER_shutdown (); | ||
140 | } | ||
141 | |||
142 | |||
143 | /** | ||
126 | * Signature of a main function for a testcase. | 144 | * Signature of a main function for a testcase. |
127 | * | 145 | * |
128 | * @param cls closure | 146 | * @param cls closure |
@@ -148,11 +166,10 @@ test_master (void *cls, | |||
148 | 166 | ||
149 | if (0 != timeout.rel_value_us) | 167 | if (0 != timeout.rel_value_us) |
150 | terminate_taskid = GNUNET_SCHEDULER_add_delayed (timeout, | 168 | terminate_taskid = GNUNET_SCHEDULER_add_delayed (timeout, |
151 | &terminate_task, NULL); | 169 | &timeout_task, |
152 | else | ||
153 | terminate_taskid = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | ||
154 | &terminate_task, | ||
155 | NULL); | 170 | NULL); |
171 | GNUNET_SCHEDULER_add_shutdown (&terminate_task, | ||
172 | NULL); | ||
156 | } | 173 | } |
157 | 174 | ||
158 | 175 | ||
diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c index f058c10b2..a563d7b7a 100644 --- a/src/fs/gnunet-publish.c +++ b/src/fs/gnunet-publish.c | |||
@@ -872,9 +872,8 @@ run (void *cls, | |||
872 | ret = 1; | 872 | ret = 1; |
873 | return; | 873 | return; |
874 | } | 874 | } |
875 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 875 | GNUNET_SCHEDULER_add_shutdown (&do_stop_task, |
876 | &do_stop_task, | 876 | NULL); |
877 | NULL); | ||
878 | if (NULL != pseudonym) | 877 | if (NULL != pseudonym) |
879 | identity = GNUNET_IDENTITY_connect (cfg, | 878 | identity = GNUNET_IDENTITY_connect (cfg, |
880 | &identity_cb, | 879 | &identity_cb, |
diff --git a/src/fs/gnunet-search.c b/src/fs/gnunet-search.c index a15d0d883..0ddcd892e 100644 --- a/src/fs/gnunet-search.c +++ b/src/fs/gnunet-search.c | |||
@@ -55,6 +55,9 @@ static int verbose; | |||
55 | 55 | ||
56 | static int local_only; | 56 | static int local_only; |
57 | 57 | ||
58 | static struct GNUNET_SCHEDULER_Task *tt; | ||
59 | |||
60 | |||
58 | /** | 61 | /** |
59 | * Type of a function that libextractor calls for each | 62 | * Type of a function that libextractor calls for each |
60 | * meta data item found. | 63 | * meta data item found. |
@@ -220,6 +223,14 @@ shutdown_task (void *cls) | |||
220 | } | 223 | } |
221 | 224 | ||
222 | 225 | ||
226 | static void | ||
227 | timeout_task (void *cls) | ||
228 | { | ||
229 | tt = NULL; | ||
230 | GNUNET_SCHEDULER_shutdown (); | ||
231 | } | ||
232 | |||
233 | |||
223 | /** | 234 | /** |
224 | * Main function that will be run by the scheduler. | 235 | * Main function that will be run by the scheduler. |
225 | * | 236 | * |
@@ -272,10 +283,11 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
272 | return; | 283 | return; |
273 | } | 284 | } |
274 | if (0 != timeout.rel_value_us) | 285 | if (0 != timeout.rel_value_us) |
275 | GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_task, NULL); | 286 | tt = GNUNET_SCHEDULER_add_delayed (timeout, |
276 | else | 287 | &timeout_task, |
277 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 288 | NULL); |
278 | NULL); | 289 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
290 | NULL); | ||
279 | } | 291 | } |
280 | 292 | ||
281 | 293 | ||
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index 2ba96334c..348bab092 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c | |||
@@ -191,7 +191,8 @@ age_cover_counters (void *cls) | |||
191 | GSF_cover_content_count = (GSF_cover_content_count * 15) / 16; | 191 | GSF_cover_content_count = (GSF_cover_content_count * 15) / 16; |
192 | GSF_cover_query_count = (GSF_cover_query_count * 15) / 16; | 192 | GSF_cover_query_count = (GSF_cover_query_count * 15) / 16; |
193 | cover_age_task = | 193 | cover_age_task = |
194 | GNUNET_SCHEDULER_add_delayed (COVER_AGE_FREQUENCY, &age_cover_counters, | 194 | GNUNET_SCHEDULER_add_delayed (COVER_AGE_FREQUENCY, |
195 | &age_cover_counters, | ||
195 | NULL); | 196 | NULL); |
196 | } | 197 | } |
197 | 198 | ||
@@ -759,13 +760,14 @@ main_init (struct GNUNET_SERVER_Handle *server, | |||
759 | NULL); | 760 | NULL); |
760 | GNUNET_SERVER_add_handlers (server, handlers); | 761 | GNUNET_SERVER_add_handlers (server, handlers); |
761 | cover_age_task = | 762 | cover_age_task = |
762 | GNUNET_SCHEDULER_add_delayed (COVER_AGE_FREQUENCY, &age_cover_counters, | 763 | GNUNET_SCHEDULER_add_delayed (COVER_AGE_FREQUENCY, |
764 | &age_cover_counters, | ||
763 | NULL); | 765 | NULL); |
764 | datastore_get_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE); | 766 | datastore_get_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE); |
765 | GSF_cadet_start_server (); | 767 | GSF_cadet_start_server (); |
766 | GSF_cadet_start_client (); | 768 | GSF_cadet_start_client (); |
767 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 769 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
768 | NULL); | 770 | NULL); |
769 | return GNUNET_OK; | 771 | return GNUNET_OK; |
770 | } | 772 | } |
771 | 773 | ||
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c index e916a73a8..53838a542 100644 --- a/src/fs/gnunet-service-fs_cp.c +++ b/src/fs/gnunet-service-fs_cp.c | |||
@@ -335,6 +335,11 @@ static struct GNUNET_CONTAINER_MultiPeerMap *cp_map; | |||
335 | */ | 335 | */ |
336 | static struct GNUNET_PEERSTORE_Handle *peerstore; | 336 | static struct GNUNET_PEERSTORE_Handle *peerstore; |
337 | 337 | ||
338 | /** | ||
339 | * Task used to flush respect values to disk. | ||
340 | */ | ||
341 | static struct GNUNET_SCHEDULER_Task *fr_task; | ||
342 | |||
338 | 343 | ||
339 | /** | 344 | /** |
340 | * Update the latency information kept for the given peer. | 345 | * Update the latency information kept for the given peer. |
@@ -876,19 +881,11 @@ transmit_delayed_now (void *cls) | |||
876 | { | 881 | { |
877 | struct GSF_DelayedHandle *dh = cls; | 882 | struct GSF_DelayedHandle *dh = cls; |
878 | struct GSF_ConnectedPeer *cp = dh->cp; | 883 | struct GSF_ConnectedPeer *cp = dh->cp; |
879 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
880 | 884 | ||
881 | GNUNET_CONTAINER_DLL_remove (cp->delayed_head, | 885 | GNUNET_CONTAINER_DLL_remove (cp->delayed_head, |
882 | cp->delayed_tail, | 886 | cp->delayed_tail, |
883 | dh); | 887 | dh); |
884 | cp->delay_queue_size--; | 888 | cp->delay_queue_size--; |
885 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
886 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | ||
887 | { | ||
888 | GNUNET_free (dh->pm); | ||
889 | GNUNET_free (dh); | ||
890 | return; | ||
891 | } | ||
892 | (void) GSF_peer_transmit_ (cp, | 889 | (void) GSF_peer_transmit_ (cp, |
893 | GNUNET_NO, | 890 | GNUNET_NO, |
894 | UINT32_MAX, | 891 | UINT32_MAX, |
@@ -1977,18 +1974,13 @@ GSF_connected_peer_change_preference_ (struct GSF_ConnectedPeer *cp, | |||
1977 | static void | 1974 | static void |
1978 | cron_flush_respect (void *cls) | 1975 | cron_flush_respect (void *cls) |
1979 | { | 1976 | { |
1980 | const struct GNUNET_SCHEDULER_TaskContext *tc; | 1977 | fr_task = NULL; |
1981 | |||
1982 | if (NULL == cp_map) | ||
1983 | return; | ||
1984 | GNUNET_CONTAINER_multipeermap_iterate (cp_map, | 1978 | GNUNET_CONTAINER_multipeermap_iterate (cp_map, |
1985 | &flush_respect, NULL); | 1979 | &flush_respect, |
1986 | tc = GNUNET_SCHEDULER_get_task_context (); | 1980 | NULL); |
1987 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 1981 | fr_task = GNUNET_SCHEDULER_add_delayed_with_priority (RESPECT_FLUSH_FREQ, |
1988 | return; | 1982 | GNUNET_SCHEDULER_PRIORITY_HIGH, |
1989 | GNUNET_SCHEDULER_add_delayed_with_priority (RESPECT_FLUSH_FREQ, | 1983 | &cron_flush_respect, NULL); |
1990 | GNUNET_SCHEDULER_PRIORITY_HIGH, | ||
1991 | &cron_flush_respect, NULL); | ||
1992 | } | 1984 | } |
1993 | 1985 | ||
1994 | 1986 | ||
@@ -2000,8 +1992,8 @@ GSF_connected_peer_init_ () | |||
2000 | { | 1992 | { |
2001 | cp_map = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_YES); | 1993 | cp_map = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_YES); |
2002 | peerstore = GNUNET_PEERSTORE_connect (GSF_cfg); | 1994 | peerstore = GNUNET_PEERSTORE_connect (GSF_cfg); |
2003 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_HIGH, | 1995 | fr_task = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_HIGH, |
2004 | &cron_flush_respect, NULL); | 1996 | &cron_flush_respect, NULL); |
2005 | } | 1997 | } |
2006 | 1998 | ||
2007 | 1999 | ||
@@ -2033,10 +2025,15 @@ GSF_connected_peer_done_ () | |||
2033 | &flush_respect, | 2025 | &flush_respect, |
2034 | NULL); | 2026 | NULL); |
2035 | GNUNET_CONTAINER_multipeermap_iterate (cp_map, | 2027 | GNUNET_CONTAINER_multipeermap_iterate (cp_map, |
2036 | &clean_peer, NULL); | 2028 | &clean_peer, |
2029 | NULL); | ||
2030 | GNUNET_SCHEDULER_cancel (fr_task); | ||
2031 | fr_task = NULL; | ||
2037 | GNUNET_CONTAINER_multipeermap_destroy (cp_map); | 2032 | GNUNET_CONTAINER_multipeermap_destroy (cp_map); |
2038 | cp_map = NULL; | 2033 | cp_map = NULL; |
2039 | GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_YES); | 2034 | GNUNET_PEERSTORE_disconnect (peerstore, |
2035 | GNUNET_YES); | ||
2036 | |||
2040 | } | 2037 | } |
2041 | 2038 | ||
2042 | 2039 | ||
diff --git a/src/fs/gnunet-service-fs_put.c b/src/fs/gnunet-service-fs_put.c index fa5aa461d..045b640db 100644 --- a/src/fs/gnunet-service-fs_put.c +++ b/src/fs/gnunet-service-fs_put.c | |||
@@ -215,12 +215,8 @@ static void | |||
215 | gather_dht_put_blocks (void *cls) | 215 | gather_dht_put_blocks (void *cls) |
216 | { | 216 | { |
217 | struct PutOperator *po = cls; | 217 | struct PutOperator *po = cls; |
218 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
219 | 218 | ||
220 | po->dht_task = NULL; | 219 | po->dht_task = NULL; |
221 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
222 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
223 | return; | ||
224 | po->dht_qe = | 220 | po->dht_qe = |
225 | GNUNET_DATASTORE_get_zero_anonymity (GSF_dsh, po->current_offset++, 0, | 221 | GNUNET_DATASTORE_get_zero_anonymity (GSF_dsh, po->current_offset++, 0, |
226 | UINT_MAX, | 222 | UINT_MAX, |
diff --git a/src/fs/gnunet-unindex.c b/src/fs/gnunet-unindex.c index cab963e0d..40fa13b62 100644 --- a/src/fs/gnunet-unindex.c +++ b/src/fs/gnunet-unindex.c | |||
@@ -147,8 +147,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
147 | GNUNET_FS_stop (ctx); | 147 | GNUNET_FS_stop (ctx); |
148 | return; | 148 | return; |
149 | } | 149 | } |
150 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 150 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
151 | NULL); | 151 | NULL); |
152 | } | 152 | } |
153 | 153 | ||
154 | 154 | ||
diff --git a/src/fs/test_gnunet_service_fs_migration.c b/src/fs/test_gnunet_service_fs_migration.c index f00290b0d..2ff495ac3 100644 --- a/src/fs/test_gnunet_service_fs_migration.c +++ b/src/fs/test_gnunet_service_fs_migration.c | |||
@@ -142,15 +142,13 @@ static void | |||
142 | stop_source_peer (void *cls) | 142 | stop_source_peer (void *cls) |
143 | { | 143 | { |
144 | struct DownloadContext *dc = cls; | 144 | struct DownloadContext *dc = cls; |
145 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
146 | 145 | ||
147 | tc = GNUNET_SCHEDULER_get_task_context (); | 146 | /* FIXME: We should not interact with testbed when shutting down */ |
148 | /* Do not interact with testbed when shutting down */ | ||
149 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
150 | return; | ||
151 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 147 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
152 | "Stopping source peer\n"); | 148 | "Stopping source peer\n"); |
153 | op = GNUNET_TESTBED_peer_stop (NULL, daemons[1], &do_download, dc); | 149 | op = GNUNET_TESTBED_peer_stop (NULL, |
150 | daemons[1], | ||
151 | &do_download, dc); | ||
154 | GNUNET_assert (NULL != op); | 152 | GNUNET_assert (NULL != op); |
155 | } | 153 | } |
156 | 154 | ||
@@ -176,7 +174,9 @@ do_wait (void *cls, | |||
176 | dc->uri = GNUNET_FS_uri_dup (uri); | 174 | dc->uri = GNUNET_FS_uri_dup (uri); |
177 | if (NULL != fn) | 175 | if (NULL != fn) |
178 | dc->fn = GNUNET_strdup (fn); | 176 | dc->fn = GNUNET_strdup (fn); |
179 | (void) GNUNET_SCHEDULER_add_delayed (MIGRATION_DELAY, &stop_source_peer, dc); | 177 | (void) GNUNET_SCHEDULER_add_delayed (MIGRATION_DELAY, |
178 | &stop_source_peer, | ||
179 | dc); | ||
180 | } | 180 | } |
181 | 181 | ||
182 | 182 | ||
@@ -196,7 +196,8 @@ do_publish (void *cls, | |||
196 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 196 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
197 | "Publishing %llu bytes\n", | 197 | "Publishing %llu bytes\n", |
198 | (unsigned long long) FILESIZE); | 198 | (unsigned long long) FILESIZE); |
199 | GNUNET_FS_TEST_publish (daemons[1], TIMEOUT, 1, GNUNET_NO, FILESIZE, SEED, | 199 | GNUNET_FS_TEST_publish (daemons[1], TIMEOUT, 1, GNUNET_NO, |
200 | FILESIZE, SEED, | ||
200 | VERBOSE, &do_wait, NULL); | 201 | VERBOSE, &do_wait, NULL); |
201 | } | 202 | } |
202 | 203 | ||
diff --git a/src/gns/gns_api.c b/src/gns/gns_api.c index 6696158c9..a1fe3680a 100644 --- a/src/gns/gns_api.c +++ b/src/gns/gns_api.c | |||
@@ -239,9 +239,10 @@ force_reconnect (struct GNUNET_GNS_Handle *handle) | |||
239 | p); | 239 | p); |
240 | } | 240 | } |
241 | handle->reconnect_backoff = GNUNET_TIME_STD_BACKOFF (handle->reconnect_backoff); | 241 | handle->reconnect_backoff = GNUNET_TIME_STD_BACKOFF (handle->reconnect_backoff); |
242 | handle->reconnect_task = GNUNET_SCHEDULER_add_delayed (handle->reconnect_backoff, | 242 | handle->reconnect_task |
243 | &reconnect_task, | 243 | = GNUNET_SCHEDULER_add_delayed (handle->reconnect_backoff, |
244 | handle); | 244 | &reconnect_task, |
245 | handle); | ||
245 | } | 246 | } |
246 | 247 | ||
247 | 248 | ||
diff --git a/src/gns/gnunet-bcd.c b/src/gns/gnunet-bcd.c index e7be8fd84..284804175 100644 --- a/src/gns/gnunet-bcd.c +++ b/src/gns/gnunet-bcd.c | |||
@@ -90,10 +90,14 @@ struct Entry | |||
90 | * Main request handler. | 90 | * Main request handler. |
91 | */ | 91 | */ |
92 | static int | 92 | static int |
93 | access_handler_callback (void *cls, struct MHD_Connection *connection, | 93 | access_handler_callback (void *cls, |
94 | const char *url, const char *method, | 94 | struct MHD_Connection *connection, |
95 | const char *version, const char *upload_data, | 95 | const char *url, |
96 | size_t * upload_data_size, void **con_cls) | 96 | const char *method, |
97 | const char *version, | ||
98 | const char *upload_data, | ||
99 | size_t * upload_data_size, | ||
100 | void **con_cls) | ||
97 | { | 101 | { |
98 | static int dummy; | 102 | static int dummy; |
99 | static const struct Entry map[] = { | 103 | static const struct Entry map[] = { |
@@ -290,12 +294,8 @@ static void | |||
290 | run_daemon (void *cls) | 294 | run_daemon (void *cls) |
291 | { | 295 | { |
292 | struct MHD_Daemon *daemon_handle = cls; | 296 | struct MHD_Daemon *daemon_handle = cls; |
293 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
294 | 297 | ||
295 | http_task = NULL; | 298 | http_task = NULL; |
296 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
297 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
298 | return; | ||
299 | GNUNET_assert (MHD_YES == MHD_run (daemon_handle)); | 299 | GNUNET_assert (MHD_YES == MHD_run (daemon_handle)); |
300 | http_task = prepare_daemon (daemon_handle); | 300 | http_task = prepare_daemon (daemon_handle); |
301 | } | 301 | } |
@@ -499,9 +499,8 @@ run (void *cls, | |||
499 | if (GNUNET_OK != | 499 | if (GNUNET_OK != |
500 | server_start ()) | 500 | server_start ()) |
501 | return; | 501 | return; |
502 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 502 | GNUNET_SCHEDULER_add_shutdown (&server_stop, |
503 | &server_stop, | 503 | NULL); |
504 | NULL); | ||
505 | } | 504 | } |
506 | 505 | ||
507 | 506 | ||
diff --git a/src/gns/gnunet-dns2gns.c b/src/gns/gnunet-dns2gns.c index 119bda91a..df3b4e882 100644 --- a/src/gns/gnunet-dns2gns.c +++ b/src/gns/gnunet-dns2gns.c | |||
@@ -175,9 +175,15 @@ static void | |||
175 | do_shutdown (void *cls) | 175 | do_shutdown (void *cls) |
176 | { | 176 | { |
177 | if (NULL != t4) | 177 | if (NULL != t4) |
178 | { | ||
178 | GNUNET_SCHEDULER_cancel (t4); | 179 | GNUNET_SCHEDULER_cancel (t4); |
180 | t4 = NULL; | ||
181 | } | ||
179 | if (NULL != t6) | 182 | if (NULL != t6) |
183 | { | ||
180 | GNUNET_SCHEDULER_cancel (t6); | 184 | GNUNET_SCHEDULER_cancel (t6); |
185 | t6 = NULL; | ||
186 | } | ||
181 | if (NULL != listen_socket4) | 187 | if (NULL != listen_socket4) |
182 | { | 188 | { |
183 | GNUNET_NETWORK_socket_close (listen_socket4); | 189 | GNUNET_NETWORK_socket_close (listen_socket4); |
@@ -607,57 +613,57 @@ run_dnsd () | |||
607 | SOCK_DGRAM, | 613 | SOCK_DGRAM, |
608 | IPPROTO_UDP); | 614 | IPPROTO_UDP); |
609 | if (NULL != listen_socket4) | 615 | if (NULL != listen_socket4) |
610 | { | 616 | { |
611 | struct sockaddr_in v4; | 617 | struct sockaddr_in v4; |
612 | 618 | ||
613 | memset (&v4, 0, sizeof (v4)); | 619 | memset (&v4, 0, sizeof (v4)); |
614 | v4.sin_family = AF_INET; | 620 | v4.sin_family = AF_INET; |
615 | #if HAVE_SOCKADDR_IN_SIN_LEN | 621 | #if HAVE_SOCKADDR_IN_SIN_LEN |
616 | v4.sin_len = sizeof (v4); | 622 | v4.sin_len = sizeof (v4); |
617 | #endif | 623 | #endif |
618 | v4.sin_port = htons (listen_port); | 624 | v4.sin_port = htons (listen_port); |
619 | if (GNUNET_OK != | 625 | if (GNUNET_OK != |
620 | GNUNET_NETWORK_socket_bind (listen_socket4, | 626 | GNUNET_NETWORK_socket_bind (listen_socket4, |
621 | (struct sockaddr *) &v4, | 627 | (struct sockaddr *) &v4, |
622 | sizeof (v4))) | 628 | sizeof (v4))) |
623 | { | 629 | { |
624 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "bind"); | 630 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "bind"); |
625 | GNUNET_NETWORK_socket_close (listen_socket4); | 631 | GNUNET_NETWORK_socket_close (listen_socket4); |
626 | listen_socket4 = NULL; | 632 | listen_socket4 = NULL; |
627 | } | ||
628 | } | 633 | } |
634 | } | ||
629 | listen_socket6 = GNUNET_NETWORK_socket_create (PF_INET6, | 635 | listen_socket6 = GNUNET_NETWORK_socket_create (PF_INET6, |
630 | SOCK_DGRAM, | 636 | SOCK_DGRAM, |
631 | IPPROTO_UDP); | 637 | IPPROTO_UDP); |
632 | if (NULL != listen_socket6) | 638 | if (NULL != listen_socket6) |
633 | { | 639 | { |
634 | struct sockaddr_in6 v6; | 640 | struct sockaddr_in6 v6; |
635 | 641 | ||
636 | memset (&v6, 0, sizeof (v6)); | 642 | memset (&v6, 0, sizeof (v6)); |
637 | v6.sin6_family = AF_INET6; | 643 | v6.sin6_family = AF_INET6; |
638 | #if HAVE_SOCKADDR_IN_SIN_LEN | 644 | #if HAVE_SOCKADDR_IN_SIN_LEN |
639 | v6.sin6_len = sizeof (v6); | 645 | v6.sin6_len = sizeof (v6); |
640 | #endif | 646 | #endif |
641 | v6.sin6_port = htons (listen_port); | 647 | v6.sin6_port = htons (listen_port); |
642 | if (GNUNET_OK != | 648 | if (GNUNET_OK != |
643 | GNUNET_NETWORK_socket_bind (listen_socket6, | 649 | GNUNET_NETWORK_socket_bind (listen_socket6, |
644 | (struct sockaddr *) &v6, | 650 | (struct sockaddr *) &v6, |
645 | sizeof (v6))) | 651 | sizeof (v6))) |
646 | { | 652 | { |
647 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "bind"); | 653 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "bind"); |
648 | GNUNET_NETWORK_socket_close (listen_socket6); | 654 | GNUNET_NETWORK_socket_close (listen_socket6); |
649 | listen_socket6 = NULL; | 655 | listen_socket6 = NULL; |
650 | } | ||
651 | } | 656 | } |
657 | } | ||
652 | if ( (NULL == listen_socket4) && | 658 | if ( (NULL == listen_socket4) && |
653 | (NULL == listen_socket6) ) | 659 | (NULL == listen_socket6) ) |
654 | { | 660 | { |
655 | GNUNET_GNS_disconnect (gns); | 661 | GNUNET_GNS_disconnect (gns); |
656 | gns = NULL; | 662 | gns = NULL; |
657 | GNUNET_DNSSTUB_stop (dns_stub); | 663 | GNUNET_DNSSTUB_stop (dns_stub); |
658 | dns_stub = NULL; | 664 | dns_stub = NULL; |
659 | return; | 665 | return; |
660 | } | 666 | } |
661 | if (NULL != listen_socket4) | 667 | if (NULL != listen_socket4) |
662 | t4 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 668 | t4 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
663 | listen_socket4, | 669 | listen_socket4, |
@@ -668,7 +674,6 @@ run_dnsd () | |||
668 | listen_socket6, | 674 | listen_socket6, |
669 | &read_dns6, | 675 | &read_dns6, |
670 | listen_socket6); | 676 | listen_socket6); |
671 | |||
672 | } | 677 | } |
673 | 678 | ||
674 | 679 | ||
@@ -719,7 +724,9 @@ identity_cb (void *cls, | |||
719 | * @param c configuration | 724 | * @param c configuration |
720 | */ | 725 | */ |
721 | static void | 726 | static void |
722 | run (void *cls, char *const *args, const char *cfgfile, | 727 | run (void *cls, |
728 | char *const *args, | ||
729 | const char *cfgfile, | ||
723 | const struct GNUNET_CONFIGURATION_Handle *c) | 730 | const struct GNUNET_CONFIGURATION_Handle *c) |
724 | { | 731 | { |
725 | cfg = c; | 732 | cfg = c; |
@@ -730,8 +737,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
730 | _("No DNS server specified!\n")); | 737 | _("No DNS server specified!\n")); |
731 | return; | 738 | return; |
732 | } | 739 | } |
733 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 740 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
734 | &do_shutdown, NULL); | ||
735 | if (NULL == gns_zone_str) | 741 | if (NULL == gns_zone_str) |
736 | { | 742 | { |
737 | identity = GNUNET_IDENTITY_connect (cfg, | 743 | identity = GNUNET_IDENTITY_connect (cfg, |
@@ -745,8 +751,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
745 | if ( (NULL == gns_zone_str) || | 751 | if ( (NULL == gns_zone_str) || |
746 | (GNUNET_OK != | 752 | (GNUNET_OK != |
747 | GNUNET_CRYPTO_ecdsa_public_key_from_string (gns_zone_str, | 753 | GNUNET_CRYPTO_ecdsa_public_key_from_string (gns_zone_str, |
748 | strlen (gns_zone_str), | 754 | strlen (gns_zone_str), |
749 | &my_zone)) ) | 755 | &my_zone)) ) |
750 | { | 756 | { |
751 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 757 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
752 | _("No valid GNS zone specified!\n")); | 758 | _("No valid GNS zone specified!\n")); |
diff --git a/src/gns/gnunet-gns-helper-service-w32.c b/src/gns/gnunet-gns-helper-service-w32.c index 112bcd258..c9c9e3fec 100644 --- a/src/gns/gnunet-gns-helper-service-w32.c +++ b/src/gns/gnunet-gns-helper-service-w32.c | |||
@@ -827,8 +827,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
827 | GNUNET_SCHEDULER_shutdown (); | 827 | GNUNET_SCHEDULER_shutdown (); |
828 | return; | 828 | return; |
829 | } | 829 | } |
830 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &do_shutdown, | 830 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, |
831 | NULL); | 831 | NULL); |
832 | 832 | ||
833 | identity = GNUNET_IDENTITY_connect (cfg, NULL, NULL); | 833 | identity = GNUNET_IDENTITY_connect (cfg, NULL, NULL); |
834 | if (NULL == identity) | 834 | if (NULL == identity) |
diff --git a/src/gns/gnunet-gns-import.c b/src/gns/gnunet-gns-import.c index 5f94e7792..e98babfa8 100644 --- a/src/gns/gnunet-gns-import.c +++ b/src/gns/gnunet-gns-import.c | |||
@@ -454,8 +454,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
454 | 454 | ||
455 | ns = GNUNET_NAMESTORE_connect (cfg); | 455 | ns = GNUNET_NAMESTORE_connect (cfg); |
456 | sh = GNUNET_IDENTITY_connect (cfg, &get_ego, NULL); | 456 | sh = GNUNET_IDENTITY_connect (cfg, &get_ego, NULL); |
457 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 457 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
458 | &shutdown_task, NULL); | ||
459 | } | 458 | } |
460 | 459 | ||
461 | 460 | ||
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c index 9a34c83af..6793d6f5c 100644 --- a/src/gns/gnunet-gns-proxy.c +++ b/src/gns/gnunet-gns-proxy.c | |||
@@ -2713,15 +2713,11 @@ do_accept (void *cls) | |||
2713 | struct GNUNET_NETWORK_Handle *lsock = cls; | 2713 | struct GNUNET_NETWORK_Handle *lsock = cls; |
2714 | struct GNUNET_NETWORK_Handle *s; | 2714 | struct GNUNET_NETWORK_Handle *s; |
2715 | struct Socks5Request *s5r; | 2715 | struct Socks5Request *s5r; |
2716 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
2717 | 2716 | ||
2718 | if (lsock == lsock4) | 2717 | if (lsock == lsock4) |
2719 | ltask4 = NULL; | 2718 | ltask4 = NULL; |
2720 | else | 2719 | else |
2721 | ltask6 = NULL; | 2720 | ltask6 = NULL; |
2722 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
2723 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
2724 | return; | ||
2725 | if (lsock == lsock4) | 2721 | if (lsock == lsock4) |
2726 | ltask4 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 2722 | ltask4 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
2727 | lsock, | 2723 | lsock, |
@@ -3126,8 +3122,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
3126 | "gns-proxy", | 3122 | "gns-proxy", |
3127 | &identity_master_cb, | 3123 | &identity_master_cb, |
3128 | NULL); | 3124 | NULL); |
3129 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 3125 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
3130 | &do_shutdown, NULL); | ||
3131 | } | 3126 | } |
3132 | 3127 | ||
3133 | 3128 | ||
diff --git a/src/gns/gnunet-gns.c b/src/gns/gnunet-gns.c index c8310db46..62cec54cb 100644 --- a/src/gns/gnunet-gns.c +++ b/src/gns/gnunet-gns.c | |||
@@ -100,6 +100,11 @@ static struct GNUNET_IDENTITY_Handle *identity; | |||
100 | */ | 100 | */ |
101 | static struct GNUNET_IDENTITY_Operation *id_op; | 101 | static struct GNUNET_IDENTITY_Operation *id_op; |
102 | 102 | ||
103 | /** | ||
104 | * Task scheduled to handle timeout. | ||
105 | */ | ||
106 | static struct GNUNET_SCHEDULER_Task *tt; | ||
107 | |||
103 | 108 | ||
104 | /** | 109 | /** |
105 | * Task run on shutdown. Cleans up everything. | 110 | * Task run on shutdown. Cleans up everything. |
@@ -134,6 +139,24 @@ do_shutdown (void *cls) | |||
134 | GNUNET_GNS_disconnect (gns); | 139 | GNUNET_GNS_disconnect (gns); |
135 | gns = NULL; | 140 | gns = NULL; |
136 | } | 141 | } |
142 | if (NULL != tt) | ||
143 | { | ||
144 | GNUNET_SCHEDULER_cancel (tt); | ||
145 | tt = NULL; | ||
146 | } | ||
147 | } | ||
148 | |||
149 | |||
150 | /** | ||
151 | * Task run on timeout. Triggers shutdown. | ||
152 | * | ||
153 | * @param cls unused | ||
154 | */ | ||
155 | static void | ||
156 | do_timeout (void *cls) | ||
157 | { | ||
158 | tt = NULL; | ||
159 | GNUNET_SCHEDULER_shutdown (); | ||
137 | } | 160 | } |
138 | 161 | ||
139 | 162 | ||
@@ -376,7 +399,9 @@ identity_master_cb (void *cls, | |||
376 | * @param c configuration | 399 | * @param c configuration |
377 | */ | 400 | */ |
378 | static void | 401 | static void |
379 | run (void *cls, char *const *args, const char *cfgfile, | 402 | run (void *cls, |
403 | char *const *args, | ||
404 | const char *cfgfile, | ||
380 | const struct GNUNET_CONFIGURATION_Handle *c) | 405 | const struct GNUNET_CONFIGURATION_Handle *c) |
381 | { | 406 | { |
382 | struct GNUNET_CRYPTO_EcdsaPublicKey pkey; | 407 | struct GNUNET_CRYPTO_EcdsaPublicKey pkey; |
@@ -390,8 +415,9 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
390 | _("Failed to connect to GNS\n")); | 415 | _("Failed to connect to GNS\n")); |
391 | return; | 416 | return; |
392 | } | 417 | } |
393 | GNUNET_SCHEDULER_add_delayed (timeout, | 418 | tt = GNUNET_SCHEDULER_add_delayed (timeout, |
394 | &do_shutdown, NULL); | 419 | &do_timeout, NULL); |
420 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); | ||
395 | if (NULL != public_key) | 421 | if (NULL != public_key) |
396 | { | 422 | { |
397 | if (GNUNET_OK != | 423 | if (GNUNET_OK != |
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index 87b0fd04e..682d8f5f7 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c | |||
@@ -1010,8 +1010,7 @@ run (void *cls, | |||
1010 | &monitor_sync_event, | 1010 | &monitor_sync_event, |
1011 | NULL); | 1011 | NULL); |
1012 | GNUNET_break (NULL != zmon); | 1012 | GNUNET_break (NULL != zmon); |
1013 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1013 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
1014 | &shutdown_task, NULL); | ||
1015 | } | 1014 | } |
1016 | 1015 | ||
1017 | 1016 | ||
diff --git a/src/gns/plugin_rest_gns.c b/src/gns/plugin_rest_gns.c index 8a3f26041..1315e6cda 100644 --- a/src/gns/plugin_rest_gns.c +++ b/src/gns/plugin_rest_gns.c | |||
@@ -632,9 +632,10 @@ options_cont (struct RestConnectionDataHandle *con_handle, | |||
632 | MHD_add_response_header (resp, | 632 | MHD_add_response_header (resp, |
633 | "Access-Control-Allow-Methods", | 633 | "Access-Control-Allow-Methods", |
634 | MHD_HTTP_METHOD_GET); | 634 | MHD_HTTP_METHOD_GET); |
635 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | 635 | handle->proc (handle->proc_cls, |
636 | resp, | ||
637 | MHD_HTTP_OK); | ||
636 | cleanup_handle (handle); | 638 | cleanup_handle (handle); |
637 | return; | ||
638 | } | 639 | } |
639 | 640 | ||
640 | 641 | ||
@@ -671,7 +672,6 @@ rest_gns_process_request(struct RestConnectionDataHandle *conndata_handle, | |||
671 | } | 672 | } |
672 | 673 | ||
673 | 674 | ||
674 | |||
675 | /** | 675 | /** |
676 | * Entry point for the plugin. | 676 | * Entry point for the plugin. |
677 | * | 677 | * |
diff --git a/src/gns/test_gns_proxy.c b/src/gns/test_gns_proxy.c index 0afc3ea0b..55ada84d7 100644 --- a/src/gns/test_gns_proxy.c +++ b/src/gns/test_gns_proxy.c | |||
@@ -245,6 +245,7 @@ curl_main () | |||
245 | NULL); | 245 | NULL); |
246 | } | 246 | } |
247 | 247 | ||
248 | |||
248 | static void | 249 | static void |
249 | start_curl (void *cls) | 250 | start_curl (void *cls) |
250 | { | 251 | { |
@@ -289,25 +290,27 @@ disco_ns (void* cls) | |||
289 | * specified target peer; NULL on error | 290 | * specified target peer; NULL on error |
290 | */ | 291 | */ |
291 | static void | 292 | static void |
292 | commence_testing (void *cls, int32_t success, const char *emsg) | 293 | commence_testing (void *cls, |
294 | int32_t success, | ||
295 | const char *emsg) | ||
293 | { | 296 | { |
294 | GNUNET_SCHEDULER_add_now (&disco_ns, NULL); | 297 | GNUNET_SCHEDULER_add_now (&disco_ns, NULL); |
295 | 298 | ||
296 | if ((emsg != NULL) && (GNUNET_YES != success)) | 299 | if ( (emsg != NULL) && (GNUNET_YES != success) ) |
297 | { | 300 | { |
298 | fprintf (stderr, | 301 | fprintf (stderr, |
299 | "NS failed to create record %s\n", emsg); | 302 | "NS failed to create record %s\n", |
303 | emsg); | ||
300 | GNUNET_SCHEDULER_shutdown (); | 304 | GNUNET_SCHEDULER_shutdown (); |
301 | return; | 305 | return; |
302 | } | 306 | } |
303 | 307 | ||
304 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), start_curl, NULL); | 308 | curl_task_id = |
305 | 309 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | |
310 | &start_curl, NULL); | ||
306 | } | 311 | } |
307 | 312 | ||
308 | 313 | ||
309 | |||
310 | |||
311 | /** | 314 | /** |
312 | * Function to keep the HTTP server running. | 315 | * Function to keep the HTTP server running. |
313 | */ | 316 | */ |
diff --git a/src/hostlist/gnunet-daemon-hostlist.c b/src/hostlist/gnunet-daemon-hostlist.c index 6a4689af1..21fab323b 100644 --- a/src/hostlist/gnunet-daemon-hostlist.c +++ b/src/hostlist/gnunet-daemon-hostlist.c | |||
@@ -299,9 +299,8 @@ run (void *cls, | |||
299 | GNUNET_HOSTLIST_server_start (cfg, stats, core, &server_ch, &server_dh, | 299 | GNUNET_HOSTLIST_server_start (cfg, stats, core, &server_ch, &server_dh, |
300 | advertising); | 300 | advertising); |
301 | #endif | 301 | #endif |
302 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 302 | GNUNET_SCHEDULER_add_shutdown (&cleaning_task, |
303 | &cleaning_task, | 303 | NULL); |
304 | NULL); | ||
305 | 304 | ||
306 | if (NULL == core) | 305 | if (NULL == core) |
307 | { | 306 | { |
diff --git a/src/hostlist/gnunet-daemon-hostlist_client.c b/src/hostlist/gnunet-daemon-hostlist_client.c index dbf6eaeda..15a82c2d5 100644 --- a/src/hostlist/gnunet-daemon-hostlist_client.c +++ b/src/hostlist/gnunet-daemon-hostlist_client.c | |||
@@ -210,27 +210,27 @@ static struct GNUNET_TIME_Relative hostlist_delay; | |||
210 | /** | 210 | /** |
211 | * ID of the task, checking if hostlist download should take plate | 211 | * ID of the task, checking if hostlist download should take plate |
212 | */ | 212 | */ |
213 | static struct GNUNET_SCHEDULER_Task * ti_check_download; | 213 | static struct GNUNET_SCHEDULER_Task *ti_check_download; |
214 | 214 | ||
215 | /** | 215 | /** |
216 | * ID of the task downloading the hostlist | 216 | * ID of the task downloading the hostlist |
217 | */ | 217 | */ |
218 | static struct GNUNET_SCHEDULER_Task * ti_download; | 218 | static struct GNUNET_SCHEDULER_Task *ti_download; |
219 | 219 | ||
220 | /** | 220 | /** |
221 | * ID of the task saving the hostlsit in a regular intervall | 221 | * ID of the task saving the hostlsit in a regular intervall |
222 | */ | 222 | */ |
223 | static struct GNUNET_SCHEDULER_Task * ti_saving_task; | 223 | static struct GNUNET_SCHEDULER_Task *ti_saving_task; |
224 | 224 | ||
225 | /** | 225 | /** |
226 | * ID of the task called to initiate a download | 226 | * ID of the task called to initiate a download |
227 | */ | 227 | */ |
228 | static struct GNUNET_SCHEDULER_Task * ti_download_dispatcher_task; | 228 | static struct GNUNET_SCHEDULER_Task *ti_download_dispatcher_task; |
229 | 229 | ||
230 | /** | 230 | /** |
231 | * ID of the task controlling the locking between two hostlist tests | 231 | * ID of the task controlling the locking between two hostlist tests |
232 | */ | 232 | */ |
233 | static struct GNUNET_SCHEDULER_Task * ti_testing_intervall_task; | 233 | static struct GNUNET_SCHEDULER_Task *ti_testing_intervall_task; |
234 | 234 | ||
235 | /** | 235 | /** |
236 | * At what time MUST the current hostlist request be done? | 236 | * At what time MUST the current hostlist request be done? |
@@ -719,8 +719,9 @@ clean_up () | |||
719 | { | 719 | { |
720 | CURLMcode mret; | 720 | CURLMcode mret; |
721 | 721 | ||
722 | if ((stat_testing_hostlist == GNUNET_YES) && | 722 | if ( (stat_testing_hostlist == GNUNET_YES) && |
723 | (GNUNET_NO == stat_download_successful) && (NULL != hostlist_to_test)) | 723 | (GNUNET_NO == stat_download_successful) && |
724 | (NULL != hostlist_to_test) ) | ||
724 | { | 725 | { |
725 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 726 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
726 | _ | 727 | _ |
@@ -738,7 +739,7 @@ clean_up () | |||
738 | hostlist_to_test = NULL; | 739 | hostlist_to_test = NULL; |
739 | } | 740 | } |
740 | 741 | ||
741 | if (multi != NULL) | 742 | if (NULL != multi) |
742 | { | 743 | { |
743 | mret = curl_multi_remove_handle (multi, curl); | 744 | mret = curl_multi_remove_handle (multi, curl); |
744 | if (mret != CURLM_OK) | 745 | if (mret != CURLM_OK) |
@@ -754,7 +755,7 @@ clean_up () | |||
754 | curl_multi_strerror (mret)); | 755 | curl_multi_strerror (mret)); |
755 | multi = NULL; | 756 | multi = NULL; |
756 | } | 757 | } |
757 | if (curl != NULL) | 758 | if (NULL != curl) |
758 | { | 759 | { |
759 | curl_easy_cleanup (curl); | 760 | curl_easy_cleanup (curl); |
760 | curl = NULL; | 761 | curl = NULL; |
@@ -847,19 +848,8 @@ task_download (void *cls) | |||
847 | int running; | 848 | int running; |
848 | struct CURLMsg *msg; | 849 | struct CURLMsg *msg; |
849 | CURLMcode mret; | 850 | CURLMcode mret; |
850 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
851 | 851 | ||
852 | ti_download = NULL; | 852 | ti_download = NULL; |
853 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
854 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
855 | { | ||
856 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
857 | "Shutdown requested while trying to download hostlist from `%s'\n", | ||
858 | current_url); | ||
859 | update_hostlist (); | ||
860 | clean_up (); | ||
861 | return; | ||
862 | } | ||
863 | if (0 == GNUNET_TIME_absolute_get_remaining (end_time).rel_value_us) | 853 | if (0 == GNUNET_TIME_absolute_get_remaining (end_time).rel_value_us) |
864 | { | 854 | { |
865 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 855 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -1047,12 +1037,7 @@ download_hostlist () | |||
1047 | static void | 1037 | static void |
1048 | task_download_dispatcher (void *cls) | 1038 | task_download_dispatcher (void *cls) |
1049 | { | 1039 | { |
1050 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
1051 | |||
1052 | ti_download_dispatcher_task = NULL; | 1040 | ti_download_dispatcher_task = NULL; |
1053 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
1054 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
1055 | return; | ||
1056 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download is initiated...\n"); | 1041 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download is initiated...\n"); |
1057 | if (GNUNET_NO == stat_download_in_progress) | 1042 | if (GNUNET_NO == stat_download_in_progress) |
1058 | { | 1043 | { |
@@ -1080,12 +1065,8 @@ task_check (void *cls) | |||
1080 | { | 1065 | { |
1081 | static int once; | 1066 | static int once; |
1082 | struct GNUNET_TIME_Relative delay; | 1067 | struct GNUNET_TIME_Relative delay; |
1083 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
1084 | 1068 | ||
1085 | ti_check_download = NULL; | 1069 | ti_check_download = NULL; |
1086 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
1087 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
1088 | return; | ||
1089 | if (stats == NULL) | 1070 | if (stats == NULL) |
1090 | { | 1071 | { |
1091 | curl_global_cleanup (); | 1072 | curl_global_cleanup (); |
@@ -1120,7 +1101,8 @@ task_check (void *cls) | |||
1120 | _("Have %u/%u connections. Will consider downloading hostlist in %s\n"), | 1101 | _("Have %u/%u connections. Will consider downloading hostlist in %s\n"), |
1121 | stat_connection_count, MIN_CONNECTIONS, | 1102 | stat_connection_count, MIN_CONNECTIONS, |
1122 | GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); | 1103 | GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); |
1123 | ti_check_download = GNUNET_SCHEDULER_add_delayed (delay, &task_check, NULL); | 1104 | ti_check_download = GNUNET_SCHEDULER_add_delayed (delay, |
1105 | &task_check, NULL); | ||
1124 | } | 1106 | } |
1125 | 1107 | ||
1126 | 1108 | ||
@@ -1132,12 +1114,7 @@ task_check (void *cls) | |||
1132 | static void | 1114 | static void |
1133 | task_testing_intervall_reset (void *cls) | 1115 | task_testing_intervall_reset (void *cls) |
1134 | { | 1116 | { |
1135 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
1136 | |||
1137 | ti_testing_intervall_task = NULL; | 1117 | ti_testing_intervall_task = NULL; |
1138 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
1139 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
1140 | return; | ||
1141 | stat_testing_allowed = GNUNET_OK; | 1118 | stat_testing_allowed = GNUNET_OK; |
1142 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1119 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1143 | "Testing new hostlist advertisements is allowed again\n"); | 1120 | "Testing new hostlist advertisements is allowed again\n"); |
@@ -1152,19 +1129,15 @@ task_testing_intervall_reset (void *cls) | |||
1152 | static void | 1129 | static void |
1153 | task_hostlist_saving (void *cls) | 1130 | task_hostlist_saving (void *cls) |
1154 | { | 1131 | { |
1155 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
1156 | |||
1157 | ti_saving_task = NULL; | 1132 | ti_saving_task = NULL; |
1158 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
1159 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
1160 | return; | ||
1161 | save_hostlist_file (GNUNET_NO); | 1133 | save_hostlist_file (GNUNET_NO); |
1162 | 1134 | ||
1163 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1135 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1164 | "Hostlists will be saved to file again in %s\n", | 1136 | "Hostlists will be saved to file again in %s\n", |
1165 | GNUNET_STRINGS_relative_time_to_string(SAVING_INTERVAL, GNUNET_YES)); | 1137 | GNUNET_STRINGS_relative_time_to_string(SAVING_INTERVAL, GNUNET_YES)); |
1166 | ti_saving_task = | 1138 | ti_saving_task = |
1167 | GNUNET_SCHEDULER_add_delayed (SAVING_INTERVAL, &task_hostlist_saving, | 1139 | GNUNET_SCHEDULER_add_delayed (SAVING_INTERVAL, |
1140 | &task_hostlist_saving, | ||
1168 | NULL); | 1141 | NULL); |
1169 | } | 1142 | } |
1170 | 1143 | ||
@@ -1684,7 +1657,8 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, | |||
1684 | void | 1657 | void |
1685 | GNUNET_HOSTLIST_client_stop () | 1658 | GNUNET_HOSTLIST_client_stop () |
1686 | { | 1659 | { |
1687 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Hostlist client shutdown\n"); | 1660 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1661 | "Hostlist client shutdown\n"); | ||
1688 | if (NULL != sget) | 1662 | if (NULL != sget) |
1689 | { | 1663 | { |
1690 | GNUNET_STATISTICS_get_cancel (sget); | 1664 | GNUNET_STATISTICS_get_cancel (sget); |
@@ -1693,28 +1667,29 @@ GNUNET_HOSTLIST_client_stop () | |||
1693 | stats = NULL; | 1667 | stats = NULL; |
1694 | if (GNUNET_YES == stat_learning) | 1668 | if (GNUNET_YES == stat_learning) |
1695 | save_hostlist_file (GNUNET_YES); | 1669 | save_hostlist_file (GNUNET_YES); |
1696 | if (ti_saving_task != NULL) | 1670 | if (NULL != ti_saving_task) |
1697 | { | 1671 | { |
1698 | GNUNET_SCHEDULER_cancel (ti_saving_task); | 1672 | GNUNET_SCHEDULER_cancel (ti_saving_task); |
1699 | ti_saving_task = NULL; | 1673 | ti_saving_task = NULL; |
1700 | } | 1674 | } |
1701 | 1675 | if (NULL != ti_download_dispatcher_task) | |
1702 | if (ti_download_dispatcher_task != NULL) | ||
1703 | { | 1676 | { |
1704 | GNUNET_SCHEDULER_cancel (ti_download_dispatcher_task); | 1677 | GNUNET_SCHEDULER_cancel (ti_download_dispatcher_task); |
1705 | ti_download_dispatcher_task = NULL; | 1678 | ti_download_dispatcher_task = NULL; |
1706 | } | 1679 | } |
1707 | if (ti_testing_intervall_task != NULL) | 1680 | if (NULL != ti_testing_intervall_task) |
1708 | { | 1681 | { |
1709 | GNUNET_SCHEDULER_cancel (ti_testing_intervall_task); | 1682 | GNUNET_SCHEDULER_cancel (ti_testing_intervall_task); |
1710 | ti_testing_intervall_task = NULL; | 1683 | ti_testing_intervall_task = NULL; |
1711 | } | 1684 | } |
1712 | if (ti_download != NULL) | 1685 | if (NULL != ti_download) |
1713 | { | 1686 | { |
1714 | GNUNET_SCHEDULER_cancel (ti_download); | 1687 | GNUNET_SCHEDULER_cancel (ti_download); |
1715 | ti_download = NULL; | 1688 | ti_download = NULL; |
1689 | update_hostlist (); | ||
1690 | clean_up (); | ||
1716 | } | 1691 | } |
1717 | if (ti_check_download != NULL) | 1692 | if (NULL != ti_check_download) |
1718 | { | 1693 | { |
1719 | GNUNET_SCHEDULER_cancel (ti_check_download); | 1694 | GNUNET_SCHEDULER_cancel (ti_check_download); |
1720 | ti_check_download = NULL; | 1695 | ti_check_download = NULL; |
diff --git a/src/hostlist/gnunet-daemon-hostlist_server.c b/src/hostlist/gnunet-daemon-hostlist_server.c index 6e2cb7ee4..5b45af831 100644 --- a/src/hostlist/gnunet-daemon-hostlist_server.c +++ b/src/hostlist/gnunet-daemon-hostlist_server.c | |||
@@ -74,12 +74,12 @@ static struct GNUNET_PEERINFO_NotifyContext *notify; | |||
74 | /** | 74 | /** |
75 | * Our primary task for IPv4. | 75 | * Our primary task for IPv4. |
76 | */ | 76 | */ |
77 | static struct GNUNET_SCHEDULER_Task * hostlist_task_v4; | 77 | static struct GNUNET_SCHEDULER_Task *hostlist_task_v4; |
78 | 78 | ||
79 | /** | 79 | /** |
80 | * Our primary task for IPv6. | 80 | * Our primary task for IPv6. |
81 | */ | 81 | */ |
82 | static struct GNUNET_SCHEDULER_Task * hostlist_task_v6; | 82 | static struct GNUNET_SCHEDULER_Task *hostlist_task_v6; |
83 | 83 | ||
84 | /** | 84 | /** |
85 | * Our canonical response. | 85 | * Our canonical response. |
@@ -632,15 +632,11 @@ static void | |||
632 | run_daemon (void *cls) | 632 | run_daemon (void *cls) |
633 | { | 633 | { |
634 | struct MHD_Daemon *daemon_handle = cls; | 634 | struct MHD_Daemon *daemon_handle = cls; |
635 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
636 | 635 | ||
637 | if (daemon_handle == daemon_handle_v4) | 636 | if (daemon_handle == daemon_handle_v4) |
638 | hostlist_task_v4 = NULL; | 637 | hostlist_task_v4 = NULL; |
639 | else | 638 | else |
640 | hostlist_task_v6 = NULL; | 639 | hostlist_task_v6 = NULL; |
641 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
642 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
643 | return; | ||
644 | GNUNET_assert (MHD_YES == MHD_run (daemon_handle)); | 640 | GNUNET_assert (MHD_YES == MHD_run (daemon_handle)); |
645 | if (daemon_handle == daemon_handle_v4) | 641 | if (daemon_handle == daemon_handle_v4) |
646 | hostlist_task_v4 = prepare_daemon (daemon_handle); | 642 | hostlist_task_v4 = prepare_daemon (daemon_handle); |
@@ -675,7 +671,9 @@ prepare_daemon (struct MHD_Daemon *daemon_handle) | |||
675 | wrs = GNUNET_NETWORK_fdset_create (); | 671 | wrs = GNUNET_NETWORK_fdset_create (); |
676 | wws = GNUNET_NETWORK_fdset_create (); | 672 | wws = GNUNET_NETWORK_fdset_create (); |
677 | max = -1; | 673 | max = -1; |
678 | GNUNET_assert (MHD_YES == MHD_get_fdset (daemon_handle, &rs, &ws, &es, &max)); | 674 | GNUNET_assert (MHD_YES == |
675 | MHD_get_fdset (daemon_handle, | ||
676 | &rs, &ws, &es, &max)); | ||
679 | haveto = MHD_get_timeout (daemon_handle, &timeout); | 677 | haveto = MHD_get_timeout (daemon_handle, &timeout); |
680 | if (haveto == MHD_YES) | 678 | if (haveto == MHD_YES) |
681 | tv.rel_value_us = (uint64_t) timeout * 1000LL; | 679 | tv.rel_value_us = (uint64_t) timeout * 1000LL; |
@@ -683,10 +681,9 @@ prepare_daemon (struct MHD_Daemon *daemon_handle) | |||
683 | tv = GNUNET_TIME_UNIT_FOREVER_REL; | 681 | tv = GNUNET_TIME_UNIT_FOREVER_REL; |
684 | GNUNET_NETWORK_fdset_copy_native (wrs, &rs, max + 1); | 682 | GNUNET_NETWORK_fdset_copy_native (wrs, &rs, max + 1); |
685 | GNUNET_NETWORK_fdset_copy_native (wws, &ws, max + 1); | 683 | GNUNET_NETWORK_fdset_copy_native (wws, &ws, max + 1); |
686 | ret = | 684 | ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH, |
687 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH, | 685 | tv, wrs, wws, |
688 | tv, wrs, wws, | 686 | &run_daemon, daemon_handle); |
689 | &run_daemon, daemon_handle); | ||
690 | GNUNET_NETWORK_fdset_destroy (wrs); | 687 | GNUNET_NETWORK_fdset_destroy (wrs); |
691 | GNUNET_NETWORK_fdset_destroy (wws); | 688 | GNUNET_NETWORK_fdset_destroy (wws); |
692 | return ret; | 689 | return ret; |
diff --git a/src/hostlist/test_gnunet_daemon_hostlist.c b/src/hostlist/test_gnunet_daemon_hostlist.c index 2f99b887d..5f8ece9b8 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist.c +++ b/src/hostlist/test_gnunet_daemon_hostlist.c | |||
@@ -35,7 +35,7 @@ | |||
35 | 35 | ||
36 | static int ok; | 36 | static int ok; |
37 | 37 | ||
38 | static struct GNUNET_SCHEDULER_Task * timeout_task; | 38 | static struct GNUNET_SCHEDULER_Task *timeout_task; |
39 | 39 | ||
40 | struct PeerContext | 40 | struct PeerContext |
41 | { | 41 | { |
@@ -100,11 +100,13 @@ timeout_error (void *cls) | |||
100 | * @param distance in overlay hops, as given by transport plugin | 100 | * @param distance in overlay hops, as given by transport plugin |
101 | */ | 101 | */ |
102 | static void | 102 | static void |
103 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | 103 | notify_connect (void *cls, |
104 | const struct GNUNET_PeerIdentity *peer) | ||
104 | { | 105 | { |
105 | if (peer == NULL) | 106 | if (peer == NULL) |
106 | return; | 107 | return; |
107 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected, shutting down.\n"); | 108 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
109 | "Peers connected, shutting down.\n"); | ||
108 | ok = 0; | 110 | ok = 0; |
109 | if (timeout_task != NULL) | 111 | if (timeout_task != NULL) |
110 | { | 112 | { |
@@ -116,7 +118,8 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
116 | 118 | ||
117 | 119 | ||
118 | static void | 120 | static void |
119 | process_hello (void *cls, const struct GNUNET_MessageHeader *message) | 121 | process_hello (void *cls, |
122 | const struct GNUNET_MessageHeader *message) | ||
120 | { | 123 | { |
121 | struct PeerContext *p = cls; | 124 | struct PeerContext *p = cls; |
122 | 125 | ||
@@ -170,8 +173,10 @@ waitpid_task (void *cls) | |||
170 | static void | 173 | static void |
171 | stop_arm (struct PeerContext *p) | 174 | stop_arm (struct PeerContext *p) |
172 | { | 175 | { |
173 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking ARM to stop core service\n"); | 176 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
174 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &waitpid_task, p); | 177 | "Asking ARM to stop core service\n"); |
178 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | ||
179 | &waitpid_task, p); | ||
175 | } | 180 | } |
176 | 181 | ||
177 | 182 | ||
@@ -187,14 +192,18 @@ shutdown_task (void *cls) | |||
187 | 192 | ||
188 | 193 | ||
189 | static void | 194 | static void |
190 | run (void *cls, char *const *args, const char *cfgfile, | 195 | run (void *cls, |
196 | char *const *args, | ||
197 | const char *cfgfile, | ||
191 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 198 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
192 | { | 199 | { |
193 | GNUNET_assert (ok == 1); | 200 | GNUNET_assert (ok == 1); |
194 | ok++; | 201 | ok++; |
195 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_error, NULL); | 202 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
196 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 203 | &timeout_error, |
197 | NULL); | 204 | NULL); |
205 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, | ||
206 | NULL); | ||
198 | setup_peer (&p1, "test_gnunet_daemon_hostlist_peer1.conf"); | 207 | setup_peer (&p1, "test_gnunet_daemon_hostlist_peer1.conf"); |
199 | setup_peer (&p2, "test_gnunet_daemon_hostlist_peer2.conf"); | 208 | setup_peer (&p2, "test_gnunet_daemon_hostlist_peer2.conf"); |
200 | } | 209 | } |
diff --git a/src/hostlist/test_gnunet_daemon_hostlist_learning.c b/src/hostlist/test_gnunet_daemon_hostlist_learning.c index a71b8ecae..717311be7 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist_learning.c +++ b/src/hostlist/test_gnunet_daemon_hostlist_learning.c | |||
@@ -242,7 +242,9 @@ process_adv_sent_done (void *cls, int success) | |||
242 | 242 | ||
243 | 243 | ||
244 | static int | 244 | static int |
245 | process_adv_sent (void *cls, const char *subsystem, const char *name, | 245 | process_adv_sent (void *cls, |
246 | const char *subsystem, | ||
247 | const char *name, | ||
246 | uint64_t value, int is_persistent) | 248 | uint64_t value, int is_persistent) |
247 | { | 249 | { |
248 | if ((value >= 1) && (adv_sent == GNUNET_NO)) | 250 | if ((value >= 1) && (adv_sent == GNUNET_NO)) |
@@ -267,13 +269,10 @@ static void | |||
267 | check_statistics (void *cls) | 269 | check_statistics (void *cls) |
268 | { | 270 | { |
269 | char *stat; | 271 | char *stat; |
270 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
271 | 272 | ||
272 | check_task = NULL; | 273 | check_task = NULL; |
273 | tc = GNUNET_SCHEDULER_get_task_context (); | 274 | GNUNET_asprintf (&stat, |
274 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 275 | gettext_noop ("# advertised URI `%s' downloaded"), |
275 | return; | ||
276 | GNUNET_asprintf (&stat, gettext_noop ("# advertised URI `%s' downloaded"), | ||
277 | current_adv_uri); | 276 | current_adv_uri); |
278 | if (NULL != learn_peer.stats) | 277 | if (NULL != learn_peer.stats) |
279 | { | 278 | { |
@@ -313,7 +312,8 @@ check_statistics (void *cls) | |||
313 | * Core handler for p2p hostlist advertisements | 312 | * Core handler for p2p hostlist advertisements |
314 | */ | 313 | */ |
315 | static int | 314 | static int |
316 | ad_arrive_handler (void *cls, const struct GNUNET_PeerIdentity *peer, | 315 | ad_arrive_handler (void *cls, |
316 | const struct GNUNET_PeerIdentity *peer, | ||
317 | const struct GNUNET_MessageHeader *message) | 317 | const struct GNUNET_MessageHeader *message) |
318 | { | 318 | { |
319 | char *hostname; | 319 | char *hostname; |
diff --git a/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c b/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c index 0af16e065..562eec55b 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c +++ b/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c | |||
@@ -100,11 +100,13 @@ timeout_error (void *cls) | |||
100 | * @param distance in overlay hops, as given by transport plugin | 100 | * @param distance in overlay hops, as given by transport plugin |
101 | */ | 101 | */ |
102 | static void | 102 | static void |
103 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | 103 | notify_connect (void *cls, |
104 | const struct GNUNET_PeerIdentity *peer) | ||
104 | { | 105 | { |
105 | if (peer == NULL) | 106 | if (peer == NULL) |
106 | return; | 107 | return; |
107 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected, shutting down.\n"); | 108 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
109 | "Peers connected, shutting down.\n"); | ||
108 | ok = 0; | 110 | ok = 0; |
109 | if (timeout_task != NULL) | 111 | if (timeout_task != NULL) |
110 | { | 112 | { |
@@ -116,7 +118,8 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
116 | 118 | ||
117 | 119 | ||
118 | static void | 120 | static void |
119 | process_hello (void *cls, const struct GNUNET_MessageHeader *message) | 121 | process_hello (void *cls, |
122 | const struct GNUNET_MessageHeader *message) | ||
120 | { | 123 | { |
121 | struct PeerContext *p = cls; | 124 | struct PeerContext *p = cls; |
122 | 125 | ||
@@ -171,7 +174,8 @@ static void | |||
171 | stop_arm (struct PeerContext *p) | 174 | stop_arm (struct PeerContext *p) |
172 | { | 175 | { |
173 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking ARM to stop core service\n"); | 176 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking ARM to stop core service\n"); |
174 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &waitpid_task, p); | 177 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
178 | &waitpid_task, p); | ||
175 | } | 179 | } |
176 | 180 | ||
177 | 181 | ||
@@ -192,8 +196,10 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
192 | { | 196 | { |
193 | GNUNET_assert (ok == 1); | 197 | GNUNET_assert (ok == 1); |
194 | ok++; | 198 | ok++; |
195 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_error, NULL); | 199 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
196 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 200 | &timeout_error, NULL); |
201 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | ||
202 | &shutdown_task, | ||
197 | NULL); | 203 | NULL); |
198 | setup_peer (&p1, "test_gnunet_daemon_hostlist_peer1.conf"); | 204 | setup_peer (&p1, "test_gnunet_daemon_hostlist_peer1.conf"); |
199 | setup_peer (&p2, "test_gnunet_daemon_hostlist_peer2.conf"); | 205 | setup_peer (&p2, "test_gnunet_daemon_hostlist_peer2.conf"); |
diff --git a/src/identity-provider/gnunet-service-identity-provider.c b/src/identity-provider/gnunet-service-identity-provider.c index 59e678b24..0bb400e07 100644 --- a/src/identity-provider/gnunet-service-identity-provider.c +++ b/src/identity-provider/gnunet-service-identity-provider.c | |||
@@ -105,13 +105,12 @@ static struct GNUNET_NAMESTORE_ZoneIterator *ns_it; | |||
105 | /** | 105 | /** |
106 | * Timeout task | 106 | * Timeout task |
107 | */ | 107 | */ |
108 | static struct GNUNET_SCHEDULER_Task * timeout_task; | 108 | static struct GNUNET_SCHEDULER_Task *timeout_task; |
109 | |||
110 | 109 | ||
111 | /** | 110 | /** |
112 | * Update task | 111 | * Update task |
113 | */ | 112 | */ |
114 | static struct GNUNET_SCHEDULER_Task * update_task; | 113 | static struct GNUNET_SCHEDULER_Task *update_task; |
115 | 114 | ||
116 | /** | 115 | /** |
117 | * Timeout for next update pass | 116 | * Timeout for next update pass |
@@ -494,9 +493,11 @@ handle_token_update (void *cls) | |||
494 | scopes = NULL; | 493 | scopes = NULL; |
495 | } | 494 | } |
496 | 495 | ||
496 | |||
497 | static void | 497 | static void |
498 | update_identities(void *cls); | 498 | update_identities(void *cls); |
499 | 499 | ||
500 | |||
500 | /** | 501 | /** |
501 | * | 502 | * |
502 | * Cleanup attr_map | 503 | * Cleanup attr_map |
@@ -504,7 +505,7 @@ update_identities(void *cls); | |||
504 | * @param cls NULL | 505 | * @param cls NULL |
505 | * @param key the key | 506 | * @param key the key |
506 | * @param value the json_t attribute value | 507 | * @param value the json_t attribute value |
507 | * @return GNUNET_YES | 508 | * @return #GNUNET_YES |
508 | */ | 509 | */ |
509 | static int | 510 | static int |
510 | clear_ego_attrs (void *cls, | 511 | clear_ego_attrs (void *cls, |
@@ -530,6 +531,7 @@ clear_ego_attrs (void *cls, | |||
530 | return GNUNET_YES; | 531 | return GNUNET_YES; |
531 | } | 532 | } |
532 | 533 | ||
534 | |||
533 | /** | 535 | /** |
534 | * | 536 | * |
535 | * Update all ID_TOKEN records for an identity and store them | 537 | * Update all ID_TOKEN records for an identity and store them |
@@ -539,7 +541,6 @@ clear_ego_attrs (void *cls, | |||
539 | * @param lbl the name of the record | 541 | * @param lbl the name of the record |
540 | * @param rd_count number of records | 542 | * @param rd_count number of records |
541 | * @param rd record data | 543 | * @param rd record data |
542 | * | ||
543 | */ | 544 | */ |
544 | static void | 545 | static void |
545 | token_collect (void *cls, | 546 | token_collect (void *cls, |
@@ -579,7 +580,9 @@ token_collect (void *cls, | |||
579 | { | 580 | { |
580 | token_metadata_record = &rd[0]; | 581 | token_metadata_record = &rd[0]; |
581 | token_record = &rd[1]; | 582 | token_record = &rd[1]; |
582 | } else { | 583 | } |
584 | else | ||
585 | { | ||
583 | token_record = &rd[0]; | 586 | token_record = &rd[0]; |
584 | token_metadata_record = &rd[1]; | 587 | token_metadata_record = &rd[1]; |
585 | } | 588 | } |
@@ -607,7 +610,8 @@ token_collect (void *cls, | |||
607 | label = GNUNET_strdup (lbl); | 610 | label = GNUNET_strdup (lbl); |
608 | rd_exp = token_record->expiration_time; | 611 | rd_exp = token_record->expiration_time; |
609 | 612 | ||
610 | GNUNET_SCHEDULER_add_now (&handle_token_update, ego_entry); | 613 | GNUNET_SCHEDULER_add_now (&handle_token_update, |
614 | ego_entry); | ||
611 | } | 615 | } |
612 | 616 | ||
613 | 617 | ||
@@ -642,7 +646,8 @@ attribute_collect (void *cls, | |||
642 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 646 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
643 | ">>> Updating Attributes finished\n"); | 647 | ">>> Updating Attributes finished\n"); |
644 | ego_entry->attributes_dirty = GNUNET_NO; | 648 | ego_entry->attributes_dirty = GNUNET_NO; |
645 | update_task = GNUNET_SCHEDULER_add_now (&update_identities, ego_entry); | 649 | update_task = GNUNET_SCHEDULER_add_now (&update_identities, |
650 | ego_entry); | ||
646 | return; | 651 | return; |
647 | } | 652 | } |
648 | 653 | ||
@@ -752,7 +757,6 @@ update_identities(void *cls) | |||
752 | } | 757 | } |
753 | 758 | ||
754 | 759 | ||
755 | |||
756 | /** | 760 | /** |
757 | * Function called initially to start update task | 761 | * Function called initially to start update task |
758 | */ | 762 | */ |
@@ -761,9 +765,11 @@ init_cont () | |||
761 | { | 765 | { |
762 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, ">>> Starting Service\n"); | 766 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, ">>> Starting Service\n"); |
763 | //Initially iterate all itenties and refresh all tokens | 767 | //Initially iterate all itenties and refresh all tokens |
764 | update_task = GNUNET_SCHEDULER_add_now (&update_identities, ego_head); | 768 | update_task = GNUNET_SCHEDULER_add_now (&update_identities, |
769 | ego_head); | ||
765 | } | 770 | } |
766 | 771 | ||
772 | |||
767 | /** | 773 | /** |
768 | * Initial ego collection function. | 774 | * Initial ego collection function. |
769 | * | 775 | * |
@@ -934,6 +940,7 @@ store_token_issue_cont (void *cls, | |||
934 | struct GNUNET_IDENTITY_PROVIDER_IssueResultMessage *irm; | 940 | struct GNUNET_IDENTITY_PROVIDER_IssueResultMessage *irm; |
935 | char *ticket_str; | 941 | char *ticket_str; |
936 | char *token_str; | 942 | char *token_str; |
943 | |||
937 | handle->ns_qe = NULL; | 944 | handle->ns_qe = NULL; |
938 | if (GNUNET_SYSERR == success) | 945 | if (GNUNET_SYSERR == success) |
939 | { | 946 | { |
@@ -964,7 +971,9 @@ store_token_issue_cont (void *cls, | |||
964 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 971 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
965 | return; | 972 | return; |
966 | } | 973 | } |
967 | irm = create_issue_result_message (handle->label, ticket_str, token_str); | 974 | irm = create_issue_result_message (handle->label, |
975 | ticket_str, | ||
976 | token_str); | ||
968 | GNUNET_SERVER_notification_context_unicast (nc, | 977 | GNUNET_SERVER_notification_context_unicast (nc, |
969 | handle->client, | 978 | handle->client, |
970 | &irm->header, | 979 | &irm->header, |
@@ -1528,19 +1537,16 @@ run (void *cls, | |||
1528 | token_expiration_interval = DEFAULT_TOKEN_EXPIRATION_INTERVAL; | 1537 | token_expiration_interval = DEFAULT_TOKEN_EXPIRATION_INTERVAL; |
1529 | } | 1538 | } |
1530 | 1539 | ||
1531 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1540 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
1532 | &do_shutdown, NULL); | ||
1533 | } | 1541 | } |
1534 | 1542 | ||
1535 | 1543 | ||
1536 | /** | 1544 | /** |
1537 | * | ||
1538 | * The main function | 1545 | * The main function |
1539 | * | 1546 | * |
1540 | * @param argc number of arguments from the cli | 1547 | * @param argc number of arguments from the cli |
1541 | * @param argv command line arguments | 1548 | * @param argv command line arguments |
1542 | * @return 0 ok, 1 on error | 1549 | * @return 0 ok, 1 on error |
1543 | * | ||
1544 | */ | 1550 | */ |
1545 | int | 1551 | int |
1546 | main (int argc, char *const *argv) | 1552 | main (int argc, char *const *argv) |
@@ -1551,4 +1557,4 @@ main (int argc, char *const *argv) | |||
1551 | &run, NULL)) ? 0 : 1; | 1557 | &run, NULL)) ? 0 : 1; |
1552 | } | 1558 | } |
1553 | 1559 | ||
1554 | /* end of gnunet-rest-server.c */ | 1560 | /* end of gnunet-service-identity-provider.c */ |
diff --git a/src/identity-provider/plugin_rest_identity_provider.c b/src/identity-provider/plugin_rest_identity_provider.c index b104950ba..376110a6d 100644 --- a/src/identity-provider/plugin_rest_identity_provider.c +++ b/src/identity-provider/plugin_rest_identity_provider.c | |||
@@ -248,7 +248,7 @@ struct RequestHandle | |||
248 | /** | 248 | /** |
249 | * ID of a task associated with the resolution process. | 249 | * ID of a task associated with the resolution process. |
250 | */ | 250 | */ |
251 | struct GNUNET_SCHEDULER_Task * timeout_task; | 251 | struct GNUNET_SCHEDULER_Task *timeout_task; |
252 | 252 | ||
253 | /** | 253 | /** |
254 | * The plugin result processor | 254 | * The plugin result processor |
@@ -321,9 +321,9 @@ cleanup_handle (struct RequestHandle *handle) | |||
321 | 321 | ||
322 | 322 | ||
323 | /** | 323 | /** |
324 | * Task run on shutdown. Cleans up everything. | 324 | * Task run on error, sends error message. Cleans up everything. |
325 | * | 325 | * |
326 | * @param cls unused | 326 | * @param cls the `struct RequestHandle` |
327 | */ | 327 | */ |
328 | static void | 328 | static void |
329 | do_error (void *cls) | 329 | do_error (void *cls) |
@@ -342,6 +342,21 @@ do_error (void *cls) | |||
342 | } | 342 | } |
343 | 343 | ||
344 | /** | 344 | /** |
345 | * Task run on timeout, sends error message. Cleans up everything. | ||
346 | * | ||
347 | * @param cls the `struct RequestHandle` | ||
348 | */ | ||
349 | static void | ||
350 | do_timeout (void *cls) | ||
351 | { | ||
352 | struct RequestHandle *handle = cls; | ||
353 | |||
354 | handle->timeout_task = NULL; | ||
355 | do_error (handle); | ||
356 | } | ||
357 | |||
358 | |||
359 | /** | ||
345 | * Task run on shutdown. Cleans up everything. | 360 | * Task run on shutdown. Cleans up everything. |
346 | * | 361 | * |
347 | * @param cls unused | 362 | * @param cls unused |
@@ -350,7 +365,8 @@ static void | |||
350 | do_cleanup_handle_delayed (void *cls) | 365 | do_cleanup_handle_delayed (void *cls) |
351 | { | 366 | { |
352 | struct RequestHandle *handle = cls; | 367 | struct RequestHandle *handle = cls; |
353 | cleanup_handle(handle); | 368 | |
369 | cleanup_handle (handle); | ||
354 | } | 370 | } |
355 | 371 | ||
356 | 372 | ||
@@ -406,10 +422,9 @@ token_creat_cont (void *cls, | |||
406 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | 422 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); |
407 | GNUNET_free (result_str); | 423 | GNUNET_free (result_str); |
408 | GNUNET_SCHEDULER_add_now (&do_cleanup_handle_delayed, handle); | 424 | GNUNET_SCHEDULER_add_now (&do_cleanup_handle_delayed, handle); |
409 | |||
410 | |||
411 | } | 425 | } |
412 | 426 | ||
427 | |||
413 | /** | 428 | /** |
414 | * Continueationf for token issue request | 429 | * Continueationf for token issue request |
415 | * | 430 | * |
@@ -459,7 +474,8 @@ issue_token_cont (struct RestConnectionDataHandle *con, | |||
459 | GNUNET_CONTAINER_multihashmap_contains (handle->conndata_handle->url_param_map, | 474 | GNUNET_CONTAINER_multihashmap_contains (handle->conndata_handle->url_param_map, |
460 | &key) ) | 475 | &key) ) |
461 | { | 476 | { |
462 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Issuer not found\n"); | 477 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
478 | "Issuer not found\n"); | ||
463 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 479 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
464 | return; | 480 | return; |
465 | } | 481 | } |
@@ -468,7 +484,9 @@ issue_token_cont (struct RestConnectionDataHandle *con, | |||
468 | if (NULL == ego_val) | 484 | if (NULL == ego_val) |
469 | { | 485 | { |
470 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 486 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
471 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Ego invalid: %s\n", ego_val); | 487 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
488 | "Ego invalid: %s\n", | ||
489 | ego_val); | ||
472 | return; | 490 | return; |
473 | } | 491 | } |
474 | for (ego_entry = handle->ego_head; | 492 | for (ego_entry = handle->ego_head; |
@@ -480,13 +498,18 @@ issue_token_cont (struct RestConnectionDataHandle *con, | |||
480 | egoname = ego_entry->identifier; | 498 | egoname = ego_entry->identifier; |
481 | break; | 499 | break; |
482 | } | 500 | } |
483 | if (NULL == egoname || NULL == ego_entry) | 501 | if ( (NULL == egoname) || |
502 | (NULL == ego_entry) ) | ||
484 | { | 503 | { |
485 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Ego not found: %s\n", ego_val); | 504 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
505 | "Ego not found: %s\n", | ||
506 | ego_val); | ||
486 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 507 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
487 | return; | 508 | return; |
488 | } | 509 | } |
489 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego to issue token for: %s\n", egoname); | 510 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
511 | "Ego to issue token for: %s\n", | ||
512 | egoname); | ||
490 | 513 | ||
491 | 514 | ||
492 | //Meta info | 515 | //Meta info |
@@ -516,13 +539,16 @@ issue_token_cont (struct RestConnectionDataHandle *con, | |||
516 | GNUNET_CONTAINER_multihashmap_contains (handle->conndata_handle->url_param_map, | 539 | GNUNET_CONTAINER_multihashmap_contains (handle->conndata_handle->url_param_map, |
517 | &key) ) | 540 | &key) ) |
518 | { | 541 | { |
519 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Audience missing!\n"); | 542 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
543 | "Audience missing!\n"); | ||
520 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 544 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
521 | return; | 545 | return; |
522 | } | 546 | } |
523 | audience = GNUNET_CONTAINER_multihashmap_get (handle->conndata_handle->url_param_map, | 547 | audience = GNUNET_CONTAINER_multihashmap_get (handle->conndata_handle->url_param_map, |
524 | &key); | 548 | &key); |
525 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Audience to issue token for: %s\n", audience); | 549 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
550 | "Audience to issue token for: %s\n", | ||
551 | audience); | ||
526 | 552 | ||
527 | priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); | 553 | priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); |
528 | GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, | 554 | GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, |
@@ -547,7 +573,9 @@ issue_token_cont (struct RestConnectionDataHandle *con, | |||
547 | } | 573 | } |
548 | nonce_str = GNUNET_CONTAINER_multihashmap_get (handle->conndata_handle->url_param_map, | 574 | nonce_str = GNUNET_CONTAINER_multihashmap_get (handle->conndata_handle->url_param_map, |
549 | &key); | 575 | &key); |
550 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Request nonce: %s\n", nonce_str); | 576 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
577 | "Request nonce: %s\n", | ||
578 | nonce_str); | ||
551 | sscanf (nonce_str, "%"SCNu64, &nonce); | 579 | sscanf (nonce_str, "%"SCNu64, &nonce); |
552 | 580 | ||
553 | //Get expiration for token from URL parameter | 581 | //Get expiration for token from URL parameter |
@@ -1048,10 +1076,8 @@ rest_identity_process_request(struct RestConnectionDataHandle *conndata_handle, | |||
1048 | handle); | 1076 | handle); |
1049 | handle->timeout_task = | 1077 | handle->timeout_task = |
1050 | GNUNET_SCHEDULER_add_delayed (handle->timeout, | 1078 | GNUNET_SCHEDULER_add_delayed (handle->timeout, |
1051 | &do_error, | 1079 | &do_timeout, |
1052 | handle); | 1080 | handle); |
1053 | |||
1054 | |||
1055 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1081 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1056 | "Connected\n"); | 1082 | "Connected\n"); |
1057 | } | 1083 | } |
diff --git a/src/identity/gnunet-identity.c b/src/identity/gnunet-identity.c index dc9174d21..23c20d91f 100644 --- a/src/identity/gnunet-identity.c +++ b/src/identity/gnunet-identity.c | |||
@@ -302,8 +302,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
302 | create_ego, | 302 | create_ego, |
303 | &create_finished, | 303 | &create_finished, |
304 | &create_op); | 304 | &create_op); |
305 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 305 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
306 | &shutdown_task, NULL); | ||
307 | test_finished (); | 306 | test_finished (); |
308 | } | 307 | } |
309 | 308 | ||
diff --git a/src/identity/gnunet-service-identity.c b/src/identity/gnunet-service-identity.c index d36319a99..9185aac64 100644 --- a/src/identity/gnunet-service-identity.c +++ b/src/identity/gnunet-service-identity.c | |||
@@ -916,8 +916,8 @@ run (void *cls, | |||
916 | GNUNET_DISK_directory_scan (ego_directory, | 916 | GNUNET_DISK_directory_scan (ego_directory, |
917 | &process_ego_file, | 917 | &process_ego_file, |
918 | NULL); | 918 | NULL); |
919 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 919 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
920 | NULL); | 920 | NULL); |
921 | } | 921 | } |
922 | 922 | ||
923 | 923 | ||
diff --git a/src/identity/plugin_rest_identity.c b/src/identity/plugin_rest_identity.c index 22ade6a0e..5bed8af55 100644 --- a/src/identity/plugin_rest_identity.c +++ b/src/identity/plugin_rest_identity.c | |||
@@ -257,9 +257,9 @@ cleanup_handle (struct RequestHandle *handle) | |||
257 | 257 | ||
258 | 258 | ||
259 | /** | 259 | /** |
260 | * Task run on shutdown. Cleans up everything. | 260 | * Task run on errors. Reports an error and cleans up everything. |
261 | * | 261 | * |
262 | * @param cls unused | 262 | * @param cls the `struct RequestHandle` |
263 | */ | 263 | */ |
264 | static void | 264 | static void |
265 | do_error (void *cls) | 265 | do_error (void *cls) |
@@ -273,7 +273,9 @@ do_error (void *cls) | |||
273 | &handle->emsg); | 273 | &handle->emsg); |
274 | 274 | ||
275 | resp = GNUNET_REST_create_json_response (json_error); | 275 | resp = GNUNET_REST_create_json_response (json_error); |
276 | handle->proc (handle->proc_cls, resp, MHD_HTTP_BAD_REQUEST); | 276 | handle->proc (handle->proc_cls, |
277 | resp, | ||
278 | MHD_HTTP_BAD_REQUEST); | ||
277 | cleanup_handle (handle); | 279 | cleanup_handle (handle); |
278 | GNUNET_free (json_error); | 280 | GNUNET_free (json_error); |
279 | } | 281 | } |
diff --git a/src/identity/test_identity.c b/src/identity/test_identity.c index 6eaa86e91..37065ce08 100644 --- a/src/identity/test_identity.c +++ b/src/identity/test_identity.c | |||
@@ -110,8 +110,7 @@ end () | |||
110 | GNUNET_SCHEDULER_cancel (endbadly_task); | 110 | GNUNET_SCHEDULER_cancel (endbadly_task); |
111 | endbadly_task = NULL; | 111 | endbadly_task = NULL; |
112 | } | 112 | } |
113 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS, | 113 | GNUNET_SCHEDULER_add_now (&end_normally, NULL); |
114 | &end_normally, NULL); | ||
115 | } | 114 | } |
116 | 115 | ||
117 | 116 | ||
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index 3d7dede17..89b692789 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h | |||
@@ -66,7 +66,7 @@ extern "C" | |||
66 | /** | 66 | /** |
67 | * Version of the API (for entire gnunetutil.so library). | 67 | * Version of the API (for entire gnunetutil.so library). |
68 | */ | 68 | */ |
69 | #define GNUNET_UTIL_VERSION 0x000A0100 | 69 | #define GNUNET_UTIL_VERSION 0x000A0101 |
70 | 70 | ||
71 | 71 | ||
72 | /** | 72 | /** |
diff --git a/src/include/gnunet_scheduler_lib.h b/src/include/gnunet_scheduler_lib.h index d9b63775a..87cb3b6f1 100644 --- a/src/include/gnunet_scheduler_lib.h +++ b/src/include/gnunet_scheduler_lib.h | |||
@@ -65,8 +65,7 @@ enum GNUNET_SCHEDULER_Reason | |||
65 | GNUNET_SCHEDULER_REASON_STARTUP = 1, | 65 | GNUNET_SCHEDULER_REASON_STARTUP = 1, |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * We are shutting down and are running all shutdown-related tasks | 68 | * We are shutting down and are running all shutdown-related tasks. |
69 | * (regardless of timeout, etc.). | ||
70 | */ | 69 | */ |
71 | GNUNET_SCHEDULER_REASON_SHUTDOWN = 2, | 70 | GNUNET_SCHEDULER_REASON_SHUTDOWN = 2, |
72 | 71 | ||
@@ -158,7 +157,7 @@ typedef int | |||
158 | * tasks have completed. On systems with signals, receiving a SIGTERM | 157 | * tasks have completed. On systems with signals, receiving a SIGTERM |
159 | * (and other similar signals) will cause #GNUNET_SCHEDULER_shutdown | 158 | * (and other similar signals) will cause #GNUNET_SCHEDULER_shutdown |
160 | * to be run after the active task is complete. As a result, SIGTERM | 159 | * to be run after the active task is complete. As a result, SIGTERM |
161 | * causes all active tasks to be scheduled with reason | 160 | * causes all shutdown tasks to be scheduled with reason |
162 | * #GNUNET_SCHEDULER_REASON_SHUTDOWN. (However, tasks added | 161 | * #GNUNET_SCHEDULER_REASON_SHUTDOWN. (However, tasks added |
163 | * afterwards will execute normally!). Note that any particular | 162 | * afterwards will execute normally!). Note that any particular |
164 | * signal will only shut down one scheduler; applications should | 163 | * signal will only shut down one scheduler; applications should |
@@ -173,11 +172,10 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task, | |||
173 | 172 | ||
174 | 173 | ||
175 | /** | 174 | /** |
176 | * Request the shutdown of the scheduler. Marks all currently | 175 | * Request the shutdown of a scheduler. Marks all tasks |
177 | * pending tasks as ready because of shutdown. This will | 176 | * awaiting shutdown as ready. Note that tasks |
178 | * cause all tasks to run (as soon as possible, respecting | 177 | * scheduled with #GNUNET_SCHEDULER_add_shutdown() AFTER this call |
179 | * priorities and prerequisite tasks). Note that tasks | 178 | * will be delayed until the next shutdown signal. |
180 | * scheduled AFTER this call may still be delayed arbitrarily. | ||
181 | */ | 179 | */ |
182 | void | 180 | void |
183 | GNUNET_SCHEDULER_shutdown (void); | 181 | GNUNET_SCHEDULER_shutdown (void); |
@@ -272,6 +270,21 @@ GNUNET_SCHEDULER_add_now (GNUNET_SCHEDULER_TaskCallback task, | |||
272 | 270 | ||
273 | 271 | ||
274 | /** | 272 | /** |
273 | * Schedule a new task to be run on shutdown, that is when a CTRL-C | ||
274 | * signal is received, or when #GNUNET_SCHEDULER_shutdown() is being | ||
275 | * invoked. | ||
276 | * | ||
277 | * @param task main function of the task | ||
278 | * @param task_cls closure of @a task | ||
279 | * @return unique task identifier for the job | ||
280 | * only valid until @a task is started! | ||
281 | */ | ||
282 | struct GNUNET_SCHEDULER_Task * | ||
283 | GNUNET_SCHEDULER_add_shutdown (GNUNET_SCHEDULER_TaskCallback task, | ||
284 | void *task_cls); | ||
285 | |||
286 | |||
287 | /** | ||
275 | * Schedule a new task to be run as soon as possible with the | 288 | * Schedule a new task to be run as soon as possible with the |
276 | * (transitive) ignore-shutdown flag either explicitly set or | 289 | * (transitive) ignore-shutdown flag either explicitly set or |
277 | * explicitly enabled. This task (and all tasks created from it, | 290 | * explicitly enabled. This task (and all tasks created from it, |
@@ -296,8 +309,7 @@ GNUNET_SCHEDULER_add_now_with_lifeness (int lifeness, | |||
296 | * will be scheduled for execution once the delay has expired. It | 309 | * will be scheduled for execution once the delay has expired. It |
297 | * will be run with the DEFAULT priority. | 310 | * will be run with the DEFAULT priority. |
298 | * | 311 | * |
299 | * * @param delay when should this operation time out? Use | 312 | * @param delay when should this operation time out? |
300 | * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
301 | * @param task main function of the task | 313 | * @param task main function of the task |
302 | * @param task_cls closure of @a task | 314 | * @param task_cls closure of @a task |
303 | * @return unique task identifier for the job | 315 | * @return unique task identifier for the job |
@@ -313,8 +325,7 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_TIME_Relative delay, | |||
313 | * Schedule a new task to be run with a specified delay. The task | 325 | * Schedule a new task to be run with a specified delay. The task |
314 | * will be scheduled for execution once the delay has expired. | 326 | * will be scheduled for execution once the delay has expired. |
315 | * | 327 | * |
316 | * @param delay when should this operation time out? Use | 328 | * @param delay when should this operation time out? |
317 | * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
318 | * @param priority priority to use for the task | 329 | * @param priority priority to use for the task |
319 | * @param task main function of the task | 330 | * @param task main function of the task |
320 | * @param task_cls closure of @a task | 331 | * @param task_cls closure of @a task |
@@ -335,8 +346,7 @@ GNUNET_SCHEDULER_add_delayed_with_priority (struct GNUNET_TIME_Relative delay, | |||
335 | * scheduled for execution once either the delay has expired or the | 346 | * scheduled for execution once either the delay has expired or the |
336 | * socket operation is ready. It will be run with the DEFAULT priority. | 347 | * socket operation is ready. It will be run with the DEFAULT priority. |
337 | * | 348 | * |
338 | * * @param delay when should this operation time out? Use | 349 | * * @param delay when should this operation time out? |
339 | * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
340 | * @param rfd read file-descriptor | 350 | * @param rfd read file-descriptor |
341 | * @param task main function of the task | 351 | * @param task main function of the task |
342 | * @param task_cls closure of @a task | 352 | * @param task_cls closure of @a task |
@@ -358,8 +368,7 @@ GNUNET_SCHEDULER_add_read_net (struct GNUNET_TIME_Relative delay, | |||
358 | * either the delay has expired or the socket operation is ready. It | 368 | * either the delay has expired or the socket operation is ready. It |
359 | * will be run with the DEFAULT priority. | 369 | * will be run with the DEFAULT priority. |
360 | * | 370 | * |
361 | * @param delay when should this operation time out? Use | 371 | * @param delay when should this operation time out? |
362 | * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
363 | * @param priority priority to use for the task | 372 | * @param priority priority to use for the task |
364 | * @param rfd read file-descriptor | 373 | * @param rfd read file-descriptor |
365 | * @param task main function of the task | 374 | * @param task main function of the task |
@@ -382,8 +391,7 @@ GNUNET_SCHEDULER_add_read_net_with_priority (struct GNUNET_TIME_Relative delay, | |||
382 | * scheduled for execution once either the delay has expired or the | 391 | * scheduled for execution once either the delay has expired or the |
383 | * socket operation is ready. It will be run with the DEFAULT priority. | 392 | * socket operation is ready. It will be run with the DEFAULT priority. |
384 | * | 393 | * |
385 | * * @param delay when should this operation time out? Use | 394 | * * @param delay when should this operation time out? |
386 | * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
387 | * @param wfd write file-descriptor | 395 | * @param wfd write file-descriptor |
388 | * @param task main function of the task | 396 | * @param task main function of the task |
389 | * @param task_cls closure of @a task | 397 | * @param task_cls closure of @a task |
@@ -404,8 +412,7 @@ GNUNET_SCHEDULER_add_write_net (struct GNUNET_TIME_Relative delay, | |||
404 | * scheduled for execution once either the delay has expired or the | 412 | * scheduled for execution once either the delay has expired or the |
405 | * socket operation is ready. | 413 | * socket operation is ready. |
406 | * | 414 | * |
407 | * @param delay when should this operation time out? Use | 415 | * @param delay when should this operation time out? |
408 | * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
409 | * @param priority priority of the task | 416 | * @param priority priority of the task |
410 | * @param fd file-descriptor | 417 | * @param fd file-descriptor |
411 | * @param on_read whether to poll the file-descriptor for readability | 418 | * @param on_read whether to poll the file-descriptor for readability |
@@ -431,8 +438,7 @@ GNUNET_SCHEDULER_add_net_with_priority (struct GNUNET_TIME_Relative delay, | |||
431 | * scheduled for execution once either the delay has expired or the | 438 | * scheduled for execution once either the delay has expired or the |
432 | * socket operation is ready. It will be run with the DEFAULT priority. | 439 | * socket operation is ready. It will be run with the DEFAULT priority. |
433 | * | 440 | * |
434 | * * @param delay when should this operation time out? Use | 441 | * * @param delay when should this operation time out? |
435 | * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
436 | * @param rfd read file-descriptor | 442 | * @param rfd read file-descriptor |
437 | * @param task main function of the task | 443 | * @param task main function of the task |
438 | * @param task_cls closure of @a task | 444 | * @param task_cls closure of @a task |
@@ -453,8 +459,7 @@ GNUNET_SCHEDULER_add_read_file (struct GNUNET_TIME_Relative delay, | |||
453 | * scheduled for execution once either the delay has expired or the | 459 | * scheduled for execution once either the delay has expired or the |
454 | * socket operation is ready. It will be run with the DEFAULT priority. | 460 | * socket operation is ready. It will be run with the DEFAULT priority. |
455 | * | 461 | * |
456 | * * @param delay when should this operation time out? Use | 462 | * * @param delay when should this operation time out? |
457 | * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
458 | * @param wfd write file-descriptor | 463 | * @param wfd write file-descriptor |
459 | * @param task main function of the task | 464 | * @param task main function of the task |
460 | * @param task_cls closure of @a task | 465 | * @param task_cls closure of @a task |
@@ -475,8 +480,7 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay, | |||
475 | * scheduled for execution once either the delay has expired or the | 480 | * scheduled for execution once either the delay has expired or the |
476 | * socket operation is ready. | 481 | * socket operation is ready. |
477 | * | 482 | * |
478 | * @param delay when should this operation time out? Use | 483 | * @param delay when should this operation time out? |
479 | * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
480 | * @param priority priority of the task | 484 | * @param priority priority of the task |
481 | * @param fd file-descriptor | 485 | * @param fd file-descriptor |
482 | * @param on_read whether to poll the file-descriptor for readability | 486 | * @param on_read whether to poll the file-descriptor for readability |
@@ -508,13 +512,11 @@ GNUNET_SCHEDULER_add_file_with_priority (struct GNUNET_TIME_Relative delay, | |||
508 | * (prerequisite-run) | 512 | * (prerequisite-run) |
509 | * && (delay-ready | 513 | * && (delay-ready |
510 | * || any-rs-ready | 514 | * || any-rs-ready |
511 | * || any-ws-ready | 515 | * || any-ws-ready) |
512 | * || shutdown-active) | ||
513 | * </code> | 516 | * </code> |
514 | * | 517 | * |
515 | * @param prio how important is this task? | 518 | * @param prio how important is this task? |
516 | * @param delay how long should we wait? Use #GNUNET_TIME_UNIT_FOREVER_REL for "forever", | 519 | * @param delay how long should we wait? |
517 | * which means that the task will only be run after we receive SIGTERM | ||
518 | * @param rs set of file descriptors we want to read (can be NULL) | 520 | * @param rs set of file descriptors we want to read (can be NULL) |
519 | * @param ws set of file descriptors we want to write (can be NULL) | 521 | * @param ws set of file descriptors we want to write (can be NULL) |
520 | * @param task main function of the task | 522 | * @param task main function of the task |
diff --git a/src/multicast/gnunet-service-multicast.c b/src/multicast/gnunet-service-multicast.c index 8041119b0..f157041bc 100644 --- a/src/multicast/gnunet-service-multicast.c +++ b/src/multicast/gnunet-service-multicast.c | |||
@@ -1837,10 +1837,10 @@ core_connected_cb (void *cls, const struct GNUNET_PeerIdentity *my_identity) | |||
1837 | 1837 | ||
1838 | nc = GNUNET_SERVER_notification_context_create (server, 1); | 1838 | nc = GNUNET_SERVER_notification_context_create (server, 1); |
1839 | GNUNET_SERVER_add_handlers (server, server_handlers); | 1839 | GNUNET_SERVER_add_handlers (server, server_handlers); |
1840 | GNUNET_SERVER_disconnect_notify (server, &client_notify_disconnect, NULL); | 1840 | GNUNET_SERVER_disconnect_notify (server, |
1841 | 1841 | &client_notify_disconnect, NULL); | |
1842 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 1842 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
1843 | NULL); | 1843 | NULL); |
1844 | } | 1844 | } |
1845 | 1845 | ||
1846 | 1846 | ||
@@ -1852,7 +1852,8 @@ core_connected_cb (void *cls, const struct GNUNET_PeerIdentity *my_identity) | |||
1852 | * @param cfg configuration to use | 1852 | * @param cfg configuration to use |
1853 | */ | 1853 | */ |
1854 | static void | 1854 | static void |
1855 | run (void *cls, struct GNUNET_SERVER_Handle *srv, | 1855 | run (void *cls, |
1856 | struct GNUNET_SERVER_Handle *srv, | ||
1856 | const struct GNUNET_CONFIGURATION_Handle *c) | 1857 | const struct GNUNET_CONFIGURATION_Handle *c) |
1857 | { | 1858 | { |
1858 | cfg = c; | 1859 | cfg = c; |
diff --git a/src/multicast/test_multicast.c b/src/multicast/test_multicast.c index 9550b8894..9e042d61b 100644 --- a/src/multicast/test_multicast.c +++ b/src/multicast/test_multicast.c | |||
@@ -276,7 +276,7 @@ member_parted (void *cls) | |||
276 | break; | 276 | break; |
277 | 277 | ||
278 | case TEST_MEMBER_PART: | 278 | case TEST_MEMBER_PART: |
279 | GNUNET_SCHEDULER_add_now (schedule_origin_stop, NULL); | 279 | GNUNET_SCHEDULER_add_now (&schedule_origin_stop, NULL); |
280 | break; | 280 | break; |
281 | 281 | ||
282 | default: | 282 | default: |
@@ -302,7 +302,7 @@ member_part () | |||
302 | test = TEST_MEMBER_PART; | 302 | test = TEST_MEMBER_PART; |
303 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 303 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
304 | "Test #%u: member_part()\n", test); | 304 | "Test #%u: member_part()\n", test); |
305 | GNUNET_SCHEDULER_add_now (schedule_member_part, NULL); | 305 | GNUNET_SCHEDULER_add_now (&schedule_member_part, NULL); |
306 | } | 306 | } |
307 | 307 | ||
308 | 308 | ||
@@ -569,7 +569,7 @@ member_recv_join_decision (void *cls, | |||
569 | { | 569 | { |
570 | case TEST_MEMBER_JOIN_REFUSE: | 570 | case TEST_MEMBER_JOIN_REFUSE: |
571 | GNUNET_assert (0 == relay_count); | 571 | GNUNET_assert (0 == relay_count); |
572 | GNUNET_SCHEDULER_add_now (schedule_member_part, NULL); | 572 | GNUNET_SCHEDULER_add_now (&schedule_member_part, NULL); |
573 | break; | 573 | break; |
574 | 574 | ||
575 | case TEST_MEMBER_JOIN_ADMIT: | 575 | case TEST_MEMBER_JOIN_ADMIT: |
@@ -695,7 +695,9 @@ core_connected (void *cls, const struct GNUNET_PeerIdentity *my_identity) | |||
695 | */ | 695 | */ |
696 | static void | 696 | static void |
697 | #if DEBUG_TEST_MULTICAST | 697 | #if DEBUG_TEST_MULTICAST |
698 | run (void *cls, char *const *args, const char *cfgfile, | 698 | run (void *cls, |
699 | char *const *args, | ||
700 | const char *cfgfile, | ||
699 | const struct GNUNET_CONFIGURATION_Handle *c) | 701 | const struct GNUNET_CONFIGURATION_Handle *c) |
700 | #else | 702 | #else |
701 | run (void *cls, | 703 | run (void *cls, |
@@ -704,10 +706,13 @@ run (void *cls, | |||
704 | #endif | 706 | #endif |
705 | { | 707 | { |
706 | cfg = c; | 708 | cfg = c; |
707 | end_badly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | 709 | end_badly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
708 | 710 | &end_badly, NULL); | |
709 | core = GNUNET_CORE_connect (cfg, NULL, &core_connected, NULL, NULL, | 711 | core = GNUNET_CORE_connect (cfg, NULL, |
710 | NULL, GNUNET_NO, NULL, GNUNET_NO, NULL); | 712 | &core_connected, NULL, NULL, |
713 | NULL, GNUNET_NO, | ||
714 | NULL, GNUNET_NO, | ||
715 | NULL); | ||
711 | } | 716 | } |
712 | 717 | ||
713 | 718 | ||
diff --git a/src/namecache/gnunet-namecache.c b/src/namecache/gnunet-namecache.c index 6abcb7b92..490197b1e 100644 --- a/src/namecache/gnunet-namecache.c +++ b/src/namecache/gnunet-namecache.c | |||
@@ -202,10 +202,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
202 | return; | 202 | return; |
203 | } | 203 | } |
204 | 204 | ||
205 | 205 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, | |
206 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 206 | NULL); |
207 | &do_shutdown, | ||
208 | NULL); | ||
209 | ns = GNUNET_NAMECACHE_connect (cfg); | 207 | ns = GNUNET_NAMECACHE_connect (cfg); |
210 | GNUNET_GNSRECORD_query_from_public_key (&pubkey, | 208 | GNUNET_GNSRECORD_query_from_public_key (&pubkey, |
211 | name, | 209 | name, |
diff --git a/src/namecache/gnunet-service-namecache.c b/src/namecache/gnunet-service-namecache.c index 81b1cce9b..e01dfcdf3 100644 --- a/src/namecache/gnunet-service-namecache.c +++ b/src/namecache/gnunet-service-namecache.c | |||
@@ -404,8 +404,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
404 | GNUNET_SERVER_disconnect_notify (server, | 404 | GNUNET_SERVER_disconnect_notify (server, |
405 | &client_disconnect_notification, | 405 | &client_disconnect_notification, |
406 | NULL); | 406 | NULL); |
407 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task, | 407 | GNUNET_SCHEDULER_add_shutdown (&cleanup_task, |
408 | NULL); | 408 | NULL); |
409 | } | 409 | } |
410 | 410 | ||
411 | 411 | ||
diff --git a/src/namecache/test_namecache_api_cache_block.c b/src/namecache/test_namecache_api_cache_block.c index 5522b207d..7b0e6e318 100644 --- a/src/namecache/test_namecache_api_cache_block.c +++ b/src/namecache/test_namecache_api_cache_block.c | |||
@@ -108,10 +108,11 @@ rd_decrypt_cb (void *cls, | |||
108 | 108 | ||
109 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 109 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
110 | "Block was decrypted successfully \n"); | 110 | "Block was decrypted successfully \n"); |
111 | 111 | ||
112 | GNUNET_SCHEDULER_add_now (&end, NULL); | 112 | GNUNET_SCHEDULER_add_now (&end, NULL); |
113 | } | 113 | } |
114 | 114 | ||
115 | |||
115 | static void | 116 | static void |
116 | name_lookup_proc (void *cls, | 117 | name_lookup_proc (void *cls, |
117 | const struct GNUNET_GNSRECORD_Block *block) | 118 | const struct GNUNET_GNSRECORD_Block *block) |
@@ -131,7 +132,7 @@ name_lookup_proc (void *cls, | |||
131 | { | 132 | { |
132 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 133 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
133 | _("Namecache returned no block\n")); | 134 | _("Namecache returned no block\n")); |
134 | if (endbadly_task != NULL) | 135 | if (NULL != endbadly_task) |
135 | GNUNET_SCHEDULER_cancel (endbadly_task); | 136 | GNUNET_SCHEDULER_cancel (endbadly_task); |
136 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | 137 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); |
137 | return; | 138 | return; |
diff --git a/src/namestore/gnunet-namestore-fcfsd.c b/src/namestore/gnunet-namestore-fcfsd.c index 82d73f6de..c2f506f6d 100644 --- a/src/namestore/gnunet-namestore-fcfsd.c +++ b/src/namestore/gnunet-namestore-fcfsd.c | |||
@@ -988,8 +988,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
988 | } | 988 | } |
989 | id_op = GNUNET_IDENTITY_get (identity, "fcfsd", | 989 | id_op = GNUNET_IDENTITY_get (identity, "fcfsd", |
990 | &identity_cb, NULL); | 990 | &identity_cb, NULL); |
991 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 991 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
992 | &do_shutdown, NULL); | ||
993 | } | 992 | } |
994 | 993 | ||
995 | 994 | ||
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c index 0965d8cbe..90214e9d6 100644 --- a/src/namestore/gnunet-namestore.c +++ b/src/namestore/gnunet-namestore.c | |||
@@ -1006,8 +1006,7 @@ testservice_id_task (void *cls, int result) | |||
1006 | ret = -1; | 1006 | ret = -1; |
1007 | return; | 1007 | return; |
1008 | } | 1008 | } |
1009 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1009 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, (void *) cfg); |
1010 | &do_shutdown, (void *) cfg); | ||
1011 | 1010 | ||
1012 | if (NULL == ego_name) | 1011 | if (NULL == ego_name) |
1013 | { | 1012 | { |
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index 0bfd002f5..4be55cf9b 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -1689,8 +1689,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
1689 | GNUNET_SERVER_disconnect_notify (server, | 1689 | GNUNET_SERVER_disconnect_notify (server, |
1690 | &client_disconnect_notification, | 1690 | &client_disconnect_notification, |
1691 | NULL); | 1691 | NULL); |
1692 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task, | 1692 | GNUNET_SCHEDULER_add_shutdown (&cleanup_task, |
1693 | NULL); | 1693 | NULL); |
1694 | } | 1694 | } |
1695 | 1695 | ||
1696 | 1696 | ||
diff --git a/src/namestore/plugin_rest_namestore.c b/src/namestore/plugin_rest_namestore.c index cfebd63a7..4612528c6 100644 --- a/src/namestore/plugin_rest_namestore.c +++ b/src/namestore/plugin_rest_namestore.c | |||
@@ -242,6 +242,7 @@ struct RequestHandle | |||
242 | 242 | ||
243 | /** | 243 | /** |
244 | * Cleanup lookup handle | 244 | * Cleanup lookup handle |
245 | * | ||
245 | * @param handle Handle to clean up | 246 | * @param handle Handle to clean up |
246 | */ | 247 | */ |
247 | static void | 248 | static void |
@@ -250,6 +251,7 @@ cleanup_handle (struct RequestHandle *handle) | |||
250 | struct RecordEntry *record_entry; | 251 | struct RecordEntry *record_entry; |
251 | struct RecordEntry *record_tmp; | 252 | struct RecordEntry *record_tmp; |
252 | int i; | 253 | int i; |
254 | |||
253 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 255 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
254 | "Cleaning up\n"); | 256 | "Cleaning up\n"); |
255 | if (NULL != handle->resp_object) | 257 | if (NULL != handle->resp_object) |
@@ -295,6 +297,7 @@ cleanup_handle (struct RequestHandle *handle) | |||
295 | GNUNET_free (handle); | 297 | GNUNET_free (handle); |
296 | } | 298 | } |
297 | 299 | ||
300 | |||
298 | /** | 301 | /** |
299 | * Create json representation of a GNSRECORD | 302 | * Create json representation of a GNSRECORD |
300 | * | 303 | * |
@@ -350,9 +353,9 @@ gnsrecord_to_json (const struct GNUNET_GNSRECORD_Data *rd) | |||
350 | 353 | ||
351 | 354 | ||
352 | /** | 355 | /** |
353 | * Task run on shutdown. Cleans up everything. | 356 | * Task run on error. Generates error response and cleans up. |
354 | * | 357 | * |
355 | * @param cls unused | 358 | * @param cls the request to generate an error response for |
356 | */ | 359 | */ |
357 | static void | 360 | static void |
358 | do_error (void *cls) | 361 | do_error (void *cls) |
@@ -365,6 +368,21 @@ do_error (void *cls) | |||
365 | } | 368 | } |
366 | 369 | ||
367 | 370 | ||
371 | /** | ||
372 | * Task run on timeout. | ||
373 | * | ||
374 | * @param cls the request to time out | ||
375 | */ | ||
376 | static void | ||
377 | do_timeout (void *cls) | ||
378 | { | ||
379 | struct RequestHandle *handle = cls; | ||
380 | |||
381 | handle->timeout_task = NULL; | ||
382 | do_error (handle); | ||
383 | } | ||
384 | |||
385 | |||
368 | static void | 386 | static void |
369 | cleanup_handle_delayed (void *cls) | 387 | cleanup_handle_delayed (void *cls) |
370 | { | 388 | { |
@@ -1138,10 +1156,8 @@ rest_identity_process_request(struct RestConnectionDataHandle *conndata_handle, | |||
1138 | &testservice_id_task, | 1156 | &testservice_id_task, |
1139 | handle); | 1157 | handle); |
1140 | handle->timeout_task = GNUNET_SCHEDULER_add_delayed (handle->timeout, | 1158 | handle->timeout_task = GNUNET_SCHEDULER_add_delayed (handle->timeout, |
1141 | &do_error, | 1159 | &do_timeout, |
1142 | handle); | 1160 | handle); |
1143 | |||
1144 | |||
1145 | } | 1161 | } |
1146 | 1162 | ||
1147 | /** | 1163 | /** |
diff --git a/src/nat/gnunet-nat-server.c b/src/nat/gnunet-nat-server.c index 0069303ca..db51ef89a 100644 --- a/src/nat/gnunet-nat-server.c +++ b/src/nat/gnunet-nat-server.c | |||
@@ -294,8 +294,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
294 | GNUNET_SERVER_create (NULL, NULL, (struct sockaddr * const *) sa, slen, | 294 | GNUNET_SERVER_create (NULL, NULL, (struct sockaddr * const *) sa, slen, |
295 | GNUNET_TIME_UNIT_SECONDS, GNUNET_YES); | 295 | GNUNET_TIME_UNIT_SECONDS, GNUNET_YES); |
296 | GNUNET_SERVER_add_handlers (server, handlers); | 296 | GNUNET_SERVER_add_handlers (server, handlers); |
297 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 297 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
298 | NULL); | 298 | NULL); |
299 | } | 299 | } |
300 | 300 | ||
301 | 301 | ||
diff --git a/src/nat/nat.c b/src/nat/nat.c index 1c60e4e0d..042a0f686 100644 --- a/src/nat/nat.c +++ b/src/nat/nat.c | |||
@@ -603,7 +603,8 @@ add_to_address_list (struct GNUNET_NAT_Handle *h, | |||
603 | */ | 603 | */ |
604 | static void | 604 | static void |
605 | add_ip_to_address_list (struct GNUNET_NAT_Handle *h, | 605 | add_ip_to_address_list (struct GNUNET_NAT_Handle *h, |
606 | enum LocalAddressSource src, const void *addr, | 606 | enum LocalAddressSource src, |
607 | const void *addr, | ||
607 | socklen_t addrlen) | 608 | socklen_t addrlen) |
608 | { | 609 | { |
609 | struct sockaddr_in s4; | 610 | struct sockaddr_in s4; |
@@ -913,10 +914,12 @@ process_interfaces (void *cls, | |||
913 | GNUNET_break (0); | 914 | GNUNET_break (0); |
914 | return GNUNET_OK; | 915 | return GNUNET_OK; |
915 | } | 916 | } |
916 | if ((h->internal_address == NULL) && (h->server_proc == NULL) && | 917 | if ( (h->internal_address == NULL) && |
917 | (h->server_read_task == NULL) && | 918 | (h->server_proc == NULL) && |
918 | (GNUNET_YES == isDefault) && ((addr->sa_family == AF_INET) || | 919 | (h->server_read_task == NULL) && |
919 | (addr->sa_family == AF_INET6))) | 920 | (GNUNET_YES == isDefault) && |
921 | ( (addr->sa_family == AF_INET) || | ||
922 | (addr->sa_family == AF_INET6) ) ) | ||
920 | { | 923 | { |
921 | /* no internal address configured, but we found a "default" | 924 | /* no internal address configured, but we found a "default" |
922 | * interface, try using that as our 'internal' address */ | 925 | * interface, try using that as our 'internal' address */ |
@@ -938,12 +941,8 @@ static void | |||
938 | restart_nat_server (void *cls) | 941 | restart_nat_server (void *cls) |
939 | { | 942 | { |
940 | struct GNUNET_NAT_Handle *h = cls; | 943 | struct GNUNET_NAT_Handle *h = cls; |
941 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
942 | 944 | ||
943 | h->server_read_task = NULL; | 945 | h->server_read_task = NULL; |
944 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
945 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
946 | return; | ||
947 | start_gnunet_nat_server (h); | 946 | start_gnunet_nat_server (h); |
948 | } | 947 | } |
949 | 948 | ||
@@ -965,12 +964,8 @@ nat_server_read (void *cls) | |||
965 | int port; | 964 | int port; |
966 | const char *port_start; | 965 | const char *port_start; |
967 | struct sockaddr_in sin_addr; | 966 | struct sockaddr_in sin_addr; |
968 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
969 | 967 | ||
970 | h->server_read_task = NULL; | 968 | h->server_read_task = NULL; |
971 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
972 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
973 | return; | ||
974 | memset (mybuf, 0, sizeof (mybuf)); | 969 | memset (mybuf, 0, sizeof (mybuf)); |
975 | bytes = | 970 | bytes = |
976 | GNUNET_DISK_file_read (h->server_stdout_handle, mybuf, sizeof (mybuf)); | 971 | GNUNET_DISK_file_read (h->server_stdout_handle, mybuf, sizeof (mybuf)); |
@@ -1036,7 +1031,8 @@ nat_server_read (void *cls) | |||
1036 | sizeof (sin_addr)); | 1031 | sizeof (sin_addr)); |
1037 | h->server_read_task = | 1032 | h->server_read_task = |
1038 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | 1033 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
1039 | h->server_stdout_handle, &nat_server_read, | 1034 | h->server_stdout_handle, |
1035 | &nat_server_read, | ||
1040 | h); | 1036 | h); |
1041 | } | 1037 | } |
1042 | 1038 | ||
diff --git a/src/nat/nat_auto.c b/src/nat/nat_auto.c index 82e067f73..4611edc62 100644 --- a/src/nat/nat_auto.c +++ b/src/nat/nat_auto.c | |||
@@ -273,7 +273,9 @@ do_udp_read (void *cls) | |||
273 | (GNUNET_NETWORK_fdset_isset (tc->read_ready, | 273 | (GNUNET_NETWORK_fdset_isset (tc->read_ready, |
274 | lsock4))) | 274 | lsock4))) |
275 | { | 275 | { |
276 | rlen = GNUNET_NETWORK_socket_recv (lsock4, reply_buf, sizeof (reply_buf)); | 276 | rlen = GNUNET_NETWORK_socket_recv (lsock4, |
277 | reply_buf, | ||
278 | sizeof (reply_buf)); | ||
277 | 279 | ||
278 | //Lets handle the packet | 280 | //Lets handle the packet |
279 | memset(&answer, 0, sizeof(struct sockaddr_in)); | 281 | memset(&answer, 0, sizeof(struct sockaddr_in)); |
@@ -288,7 +290,8 @@ do_udp_read (void *cls) | |||
288 | } | 290 | } |
289 | else | 291 | else |
290 | { | 292 | { |
291 | if (GNUNET_OK == GNUNET_NAT_stun_handle_packet (reply_buf, rlen, &answer)) | 293 | if (GNUNET_OK == |
294 | GNUNET_NAT_stun_handle_packet (reply_buf, rlen, &answer)) | ||
292 | { | 295 | { |
293 | //Process the answer | 296 | //Process the answer |
294 | process_stun_reply (&answer, ah); | 297 | process_stun_reply (&answer, ah); |
@@ -310,9 +313,6 @@ do_udp_read (void *cls) | |||
310 | 313 | ||
311 | next_phase (ah); | 314 | next_phase (ah); |
312 | } | 315 | } |
313 | |||
314 | |||
315 | |||
316 | } | 316 | } |
317 | 317 | ||
318 | 318 | ||
@@ -352,10 +352,9 @@ bind_v4 () | |||
352 | } | 352 | } |
353 | 353 | ||
354 | 354 | ||
355 | 355 | static void | |
356 | 356 | request_callback (void *cls, | |
357 | static void request_callback (void *cls, | 357 | enum GNUNET_NAT_StatusCode result) |
358 | enum GNUNET_NAT_StatusCode result) | ||
359 | { | 358 | { |
360 | // struct GNUNET_NAT_AutoHandle *ah = cls; | 359 | // struct GNUNET_NAT_AutoHandle *ah = cls; |
361 | 360 | ||
@@ -363,10 +362,7 @@ static void request_callback (void *cls, | |||
363 | stop_stun (); | 362 | stop_stun (); |
364 | 363 | ||
365 | // next_phase (ah); FIXME this always will be NULL, as called in test_stun() | 364 | // next_phase (ah); FIXME this always will be NULL, as called in test_stun() |
366 | }; | 365 | } |
367 | |||
368 | |||
369 | |||
370 | 366 | ||
371 | 367 | ||
372 | /** | 368 | /** |
@@ -518,17 +514,20 @@ test_stun (struct GNUNET_NAT_AutoHandle *ah) | |||
518 | { | 514 | { |
519 | //Lets call our function now when it accepts | 515 | //Lets call our function now when it accepts |
520 | ltask4 = GNUNET_SCHEDULER_add_read_net (NAT_SERVER_TIMEOUT, | 516 | ltask4 = GNUNET_SCHEDULER_add_read_net (NAT_SERVER_TIMEOUT, |
521 | lsock4, &do_udp_read, ah); | 517 | lsock4, |
522 | 518 | &do_udp_read, | |
519 | ah); | ||
523 | } | 520 | } |
524 | 521 | ||
525 | 522 | ||
526 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 523 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
527 | "STUN service listens on port %u\n", | 524 | "STUN service listens on port %u\n", |
528 | port); | 525 | port); |
529 | if (GNUNET_NO == GNUNET_NAT_stun_make_request (stun_server, stun_port, | 526 | if (GNUNET_NO == |
530 | lsock4, &request_callback, | 527 | GNUNET_NAT_stun_make_request (stun_server, stun_port, |
531 | NULL)) | 528 | lsock4, |
529 | &request_callback, | ||
530 | NULL)) | ||
532 | { | 531 | { |
533 | /*An error happened*/ | 532 | /*An error happened*/ |
534 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "STUN error, stopping\n"); | 533 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "STUN error, stopping\n"); |
@@ -538,7 +537,6 @@ test_stun (struct GNUNET_NAT_AutoHandle *ah) | |||
538 | } | 537 | } |
539 | 538 | ||
540 | 539 | ||
541 | |||
542 | /** | 540 | /** |
543 | * Process list of local IP addresses. Find and set the | 541 | * Process list of local IP addresses. Find and set the |
544 | * one of the default interface. | 542 | * one of the default interface. |
@@ -550,16 +548,16 @@ test_stun (struct GNUNET_NAT_AutoHandle *ah) | |||
550 | * @param broadcast_addr the broadcast address (can be NULL for unknown or unassigned) | 548 | * @param broadcast_addr the broadcast address (can be NULL for unknown or unassigned) |
551 | * @param netmask the network mask (can be NULL for unknown or unassigned)) | 549 | * @param netmask the network mask (can be NULL for unknown or unassigned)) |
552 | * @param addrlen length of the @a addr and @a broadcast_addr | 550 | * @param addrlen length of the @a addr and @a broadcast_addr |
553 | * @return GNUNET_OK to continue iteration, #GNUNET_SYSERR to abort | 551 | * @return #GNUNET_OK to continue iteration, #GNUNET_SYSERR to abort |
554 | */ | 552 | */ |
555 | static int | 553 | static int |
556 | process_if (void *cls, | 554 | process_if (void *cls, |
557 | const char *name, | 555 | const char *name, |
558 | int isDefault, | 556 | int isDefault, |
559 | const struct sockaddr *addr, | 557 | const struct sockaddr *addr, |
560 | const struct sockaddr *broadcast_addr, | 558 | const struct sockaddr *broadcast_addr, |
561 | const struct sockaddr *netmask, | 559 | const struct sockaddr *netmask, |
562 | socklen_t addrlen) | 560 | socklen_t addrlen) |
563 | { | 561 | { |
564 | struct GNUNET_NAT_AutoHandle *ah = cls; | 562 | struct GNUNET_NAT_AutoHandle *ah = cls; |
565 | const struct sockaddr_in *in; | 563 | const struct sockaddr_in *in; |
@@ -640,11 +638,9 @@ test_local_ip (struct GNUNET_NAT_AutoHandle *ah) | |||
640 | static void | 638 | static void |
641 | test_nat_punched (struct GNUNET_NAT_AutoHandle *ah) | 639 | test_nat_punched (struct GNUNET_NAT_AutoHandle *ah) |
642 | { | 640 | { |
643 | |||
644 | struct GNUNET_CLIENT_Connection *client; | 641 | struct GNUNET_CLIENT_Connection *client; |
645 | struct GNUNET_NAT_TestMessage msg; | 642 | struct GNUNET_NAT_TestMessage msg; |
646 | 643 | ||
647 | |||
648 | if (ah->stun_ip) | 644 | if (ah->stun_ip) |
649 | { | 645 | { |
650 | LOG (GNUNET_ERROR_TYPE_INFO, | 646 | LOG (GNUNET_ERROR_TYPE_INFO, |
@@ -676,9 +672,10 @@ test_nat_punched (struct GNUNET_NAT_AutoHandle *ah) | |||
676 | { | 672 | { |
677 | GNUNET_SCHEDULER_cancel (ltask4); | 673 | GNUNET_SCHEDULER_cancel (ltask4); |
678 | ltask4 = GNUNET_SCHEDULER_add_read_net (NAT_SERVER_TIMEOUT, | 674 | ltask4 = GNUNET_SCHEDULER_add_read_net (NAT_SERVER_TIMEOUT, |
679 | lsock4, &do_udp_read, ah); | 675 | lsock4, |
676 | &do_udp_read, | ||
677 | ah); | ||
680 | } | 678 | } |
681 | |||
682 | } | 679 | } |
683 | else | 680 | else |
684 | { | 681 | { |
@@ -686,13 +683,9 @@ test_nat_punched (struct GNUNET_NAT_AutoHandle *ah) | |||
686 | "We don't have a STUN IP"); | 683 | "We don't have a STUN IP"); |
687 | next_phase(ah); | 684 | next_phase(ah); |
688 | } | 685 | } |
689 | |||
690 | |||
691 | } | 686 | } |
692 | 687 | ||
693 | 688 | ||
694 | |||
695 | |||
696 | /** | 689 | /** |
697 | * Test if UPnPC works. | 690 | * Test if UPnPC works. |
698 | * | 691 | * |
@@ -772,7 +765,6 @@ err: | |||
772 | ah->task = GNUNET_SCHEDULER_add_now (&reversal_test, ah); | 765 | ah->task = GNUNET_SCHEDULER_add_now (&reversal_test, ah); |
773 | else | 766 | else |
774 | next_phase (ah); | 767 | next_phase (ah); |
775 | |||
776 | } | 768 | } |
777 | 769 | ||
778 | 770 | ||
@@ -784,8 +776,6 @@ err: | |||
784 | static void | 776 | static void |
785 | test_icmp_client (struct GNUNET_NAT_AutoHandle *ah) | 777 | test_icmp_client (struct GNUNET_NAT_AutoHandle *ah) |
786 | { | 778 | { |
787 | |||
788 | |||
789 | char *tmp; | 779 | char *tmp; |
790 | char *helper; | 780 | char *helper; |
791 | 781 | ||
@@ -802,7 +792,8 @@ test_icmp_client (struct GNUNET_NAT_AutoHandle *ah) | |||
802 | 792 | ||
803 | if (GNUNET_YES != | 793 | if (GNUNET_YES != |
804 | GNUNET_CONFIGURATION_get_value_yesno (ah->cfg, "nat", "BEHIND_NAT")){ | 794 | GNUNET_CONFIGURATION_get_value_yesno (ah->cfg, "nat", "BEHIND_NAT")){ |
805 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("test_icmp_server not possible, as we are not behind NAT\n")); | 795 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
796 | _("test_icmp_server not possible, as we are not behind NAT\n")); | ||
806 | } | 797 | } |
807 | else | 798 | else |
808 | goto err; | 799 | goto err; |
@@ -810,14 +801,14 @@ test_icmp_client (struct GNUNET_NAT_AutoHandle *ah) | |||
810 | if (GNUNET_YES == | 801 | if (GNUNET_YES == |
811 | GNUNET_OS_check_helper_binary (helper, GNUNET_YES, "-d 127.0.0.1 127.0.0.2 42")){ | 802 | GNUNET_OS_check_helper_binary (helper, GNUNET_YES, "-d 127.0.0.1 127.0.0.2 42")){ |
812 | // none of these parameters are actually used in privilege testing mode | 803 | // none of these parameters are actually used in privilege testing mode |
813 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("No working gnunet-helper-nat-server found\n")); | 804 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
805 | _("No working gnunet-helper-nat-server found\n")); | ||
814 | } | 806 | } |
815 | err: | 807 | err: |
816 | GNUNET_free_non_null (tmp); | 808 | GNUNET_free_non_null (tmp); |
817 | GNUNET_free (helper); | 809 | GNUNET_free (helper); |
818 | 810 | ||
819 | next_phase (ah); | 811 | next_phase (ah); |
820 | |||
821 | } | 812 | } |
822 | 813 | ||
823 | 814 | ||
@@ -940,11 +931,7 @@ next_phase (struct GNUNET_NAT_AutoHandle *ah) | |||
940 | GNUNET_CONFIGURATION_destroy (diff); | 931 | GNUNET_CONFIGURATION_destroy (diff); |
941 | GNUNET_NAT_autoconfig_cancel (ah); | 932 | GNUNET_NAT_autoconfig_cancel (ah); |
942 | return; | 933 | return; |
943 | |||
944 | } | 934 | } |
945 | |||
946 | |||
947 | |||
948 | } | 935 | } |
949 | 936 | ||
950 | 937 | ||
diff --git a/src/nat/nat_mini.c b/src/nat/nat_mini.c index d310b3e14..915bcbdb6 100644 --- a/src/nat/nat_mini.c +++ b/src/nat/nat_mini.c | |||
@@ -121,11 +121,15 @@ read_external_ipv4 (void *cls) | |||
121 | 121 | ||
122 | eh->task = NULL; | 122 | eh->task = NULL; |
123 | tc = GNUNET_SCHEDULER_get_task_context (); | 123 | tc = GNUNET_SCHEDULER_get_task_context (); |
124 | if (GNUNET_YES == GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, eh->r)) | 124 | if (GNUNET_YES == |
125 | GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, eh->r)) | ||
126 | { | ||
125 | ret = | 127 | ret = |
126 | GNUNET_DISK_file_read (eh->r, &eh->buf[eh->off], | 128 | GNUNET_DISK_file_read (eh->r, &eh->buf[eh->off], |
127 | sizeof (eh->buf) - eh->off); | 129 | sizeof (eh->buf) - eh->off); |
128 | else { | 130 | } |
131 | else | ||
132 | { | ||
129 | eh->ret = GNUNET_NAT_ERROR_IPC_FAILURE; | 133 | eh->ret = GNUNET_NAT_ERROR_IPC_FAILURE; |
130 | ret = -1; /* error reading, timeout, etc. */ | 134 | ret = -1; /* error reading, timeout, etc. */ |
131 | } | 135 | } |
@@ -541,7 +545,9 @@ process_map_output (void *cls, | |||
541 | GNUNET_NAT_ERROR_UPNPC_PORTMAP_FAILED); | 545 | GNUNET_NAT_ERROR_UPNPC_PORTMAP_FAILED); |
542 | if (NULL == mini->refresh_task) | 546 | if (NULL == mini->refresh_task) |
543 | mini->refresh_task = | 547 | mini->refresh_task = |
544 | GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ, &do_refresh, mini); | 548 | GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ, |
549 | &do_refresh, | ||
550 | mini); | ||
545 | return; | 551 | return; |
546 | } | 552 | } |
547 | /* | 553 | /* |
@@ -617,7 +623,9 @@ GNUNET_NAT_mini_map_start (uint16_t port, | |||
617 | ret->is_tcp = is_tcp; | 623 | ret->is_tcp = is_tcp; |
618 | ret->port = port; | 624 | ret->port = port; |
619 | ret->refresh_task = | 625 | ret->refresh_task = |
620 | GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ, &do_refresh, ret); | 626 | GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ, |
627 | &do_refresh, | ||
628 | ret); | ||
621 | run_upnpc_r (ret); | 629 | run_upnpc_r (ret); |
622 | return ret; | 630 | return ret; |
623 | } | 631 | } |
diff --git a/src/nat/nat_test.c b/src/nat/nat_test.c index 33f81d800..b2f22781e 100644 --- a/src/nat/nat_test.c +++ b/src/nat/nat_test.c | |||
@@ -252,7 +252,9 @@ do_read (void *cls) | |||
252 | tc = GNUNET_SCHEDULER_get_task_context (); | 252 | tc = GNUNET_SCHEDULER_get_task_context (); |
253 | na->rtask = NULL; | 253 | na->rtask = NULL; |
254 | tst = na->h; | 254 | tst = na->h; |
255 | GNUNET_CONTAINER_DLL_remove (tst->na_head, tst->na_tail, na); | 255 | GNUNET_CONTAINER_DLL_remove (tst->na_head, |
256 | tst->na_tail, | ||
257 | na); | ||
256 | if ((NULL != tc->write_ready) && | 258 | if ((NULL != tc->write_ready) && |
257 | (GNUNET_NETWORK_fdset_isset (tc->read_ready, na->sock)) && | 259 | (GNUNET_NETWORK_fdset_isset (tc->read_ready, na->sock)) && |
258 | (sizeof (data) == | 260 | (sizeof (data) == |
@@ -284,14 +286,10 @@ do_accept (void *cls) | |||
284 | struct GNUNET_NAT_Test *tst = cls; | 286 | struct GNUNET_NAT_Test *tst = cls; |
285 | struct GNUNET_NETWORK_Handle *s; | 287 | struct GNUNET_NETWORK_Handle *s; |
286 | struct NatActivity *wl; | 288 | struct NatActivity *wl; |
287 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
288 | 289 | ||
289 | tst->ltask = NULL; | ||
290 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
291 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
292 | return; | ||
293 | tst->ltask = | 290 | tst->ltask = |
294 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, tst->lsock, | 291 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
292 | tst->lsock, | ||
295 | &do_accept, tst); | 293 | &do_accept, tst); |
296 | s = GNUNET_NETWORK_socket_accept (tst->lsock, NULL, NULL); | 294 | s = GNUNET_NETWORK_socket_accept (tst->lsock, NULL, NULL); |
297 | if (NULL == s) | 295 | if (NULL == s) |
@@ -308,7 +306,9 @@ do_accept (void *cls) | |||
308 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 306 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
309 | wl->sock, | 307 | wl->sock, |
310 | &do_read, wl); | 308 | &do_read, wl); |
311 | GNUNET_CONTAINER_DLL_insert (tst->na_head, tst->na_tail, wl); | 309 | GNUNET_CONTAINER_DLL_insert (tst->na_head, |
310 | tst->na_tail, | ||
311 | wl); | ||
312 | } | 312 | } |
313 | 313 | ||
314 | 314 | ||
@@ -474,13 +474,15 @@ GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
474 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_listen (nh->lsock, 5)); | 474 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_listen (nh->lsock, 5)); |
475 | nh->ltask = | 475 | nh->ltask = |
476 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 476 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
477 | nh->lsock, &do_accept, nh); | 477 | nh->lsock, |
478 | &do_accept, nh); | ||
478 | } | 479 | } |
479 | else | 480 | else |
480 | { | 481 | { |
481 | nh->ltask = | 482 | nh->ltask = |
482 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 483 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
483 | nh->lsock, &do_udp_read, nh); | 484 | nh->lsock, |
485 | &do_udp_read, nh); | ||
484 | } | 486 | } |
485 | LOG (GNUNET_ERROR_TYPE_INFO, | 487 | LOG (GNUNET_ERROR_TYPE_INFO, |
486 | "NAT test listens on port %u (%s)\n", | 488 | "NAT test listens on port %u (%s)\n", |
@@ -508,7 +510,9 @@ GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
508 | return nh; | 510 | return nh; |
509 | } | 511 | } |
510 | } | 512 | } |
511 | nh->ttask = GNUNET_SCHEDULER_add_delayed (timeout, &do_timeout, nh); | 513 | nh->ttask = GNUNET_SCHEDULER_add_delayed (timeout, |
514 | &do_timeout, | ||
515 | nh); | ||
512 | return nh; | 516 | return nh; |
513 | } | 517 | } |
514 | 518 | ||
@@ -528,13 +532,17 @@ GNUNET_NAT_test_stop (struct GNUNET_NAT_Test *tst) | |||
528 | "Stopping NAT test\n"); | 532 | "Stopping NAT test\n"); |
529 | while (NULL != (cpos = tst->ca_head)) | 533 | while (NULL != (cpos = tst->ca_head)) |
530 | { | 534 | { |
531 | GNUNET_CONTAINER_DLL_remove (tst->ca_head, tst->ca_tail, cpos); | 535 | GNUNET_CONTAINER_DLL_remove (tst->ca_head, |
536 | tst->ca_tail, | ||
537 | cpos); | ||
532 | GNUNET_CLIENT_disconnect (cpos->client); | 538 | GNUNET_CLIENT_disconnect (cpos->client); |
533 | GNUNET_free (cpos); | 539 | GNUNET_free (cpos); |
534 | } | 540 | } |
535 | while (NULL != (pos = tst->na_head)) | 541 | while (NULL != (pos = tst->na_head)) |
536 | { | 542 | { |
537 | GNUNET_CONTAINER_DLL_remove (tst->na_head, tst->na_tail, pos); | 543 | GNUNET_CONTAINER_DLL_remove (tst->na_head, |
544 | tst->na_tail, | ||
545 | pos); | ||
538 | GNUNET_SCHEDULER_cancel (pos->rtask); | 546 | GNUNET_SCHEDULER_cancel (pos->rtask); |
539 | GNUNET_NETWORK_socket_close (pos->sock); | 547 | GNUNET_NETWORK_socket_close (pos->sock); |
540 | GNUNET_free (pos); | 548 | GNUNET_free (pos); |
diff --git a/src/nat/test_nat.c b/src/nat/test_nat.c index a840f3ef9..fd67473ee 100644 --- a/src/nat/test_nat.c +++ b/src/nat/test_nat.c | |||
@@ -69,7 +69,8 @@ stop (void *cls) | |||
69 | { | 69 | { |
70 | struct GNUNET_NAT_Handle *nat = cls; | 70 | struct GNUNET_NAT_Handle *nat = cls; |
71 | 71 | ||
72 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stopping NAT and quitting...\n"); | 72 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
73 | "Stopping NAT and quitting...\n"); | ||
73 | GNUNET_NAT_unregister (nat); | 74 | GNUNET_NAT_unregister (nat); |
74 | } | 75 | } |
75 | 76 | ||
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 | ||
diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c index 8cfb67a73..5f28fd484 100644 --- a/src/peerinfo-tool/gnunet-peerinfo.c +++ b/src/peerinfo-tool/gnunet-peerinfo.c | |||
@@ -757,9 +757,8 @@ testservice_task (void *cls, | |||
757 | { | 757 | { |
758 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); | 758 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); |
759 | } | 759 | } |
760 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 760 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
761 | &shutdown_task, | 761 | NULL); |
762 | NULL); | ||
763 | } | 762 | } |
764 | 763 | ||
765 | 764 | ||
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c index a0defb8cc..66082e8f7 100644 --- a/src/peerinfo/gnunet-service-peerinfo.c +++ b/src/peerinfo/gnunet-service-peerinfo.c | |||
@@ -161,6 +161,16 @@ static struct NotificationContext *nc_head; | |||
161 | */ | 161 | */ |
162 | static struct NotificationContext *nc_tail; | 162 | static struct NotificationContext *nc_tail; |
163 | 163 | ||
164 | /** | ||
165 | * Handle for task to run #cron_clean_data_hosts() | ||
166 | */ | ||
167 | static struct GNUNET_SCHEDULER_Task *cron_clean; | ||
168 | |||
169 | /** | ||
170 | * Handle for task to run #cron_scan_directory_hosts() | ||
171 | */ | ||
172 | static struct GNUNET_SCHEDULER_Task *cron_scan; | ||
173 | |||
164 | 174 | ||
165 | /** | 175 | /** |
166 | * Notify all clients in the notify list about the | 176 | * Notify all clients in the notify list about the |
@@ -657,16 +667,14 @@ cron_scan_directory_data_hosts (void *cls) | |||
657 | { | 667 | { |
658 | static unsigned int retries; | 668 | static unsigned int retries; |
659 | struct DirScanContext dsc; | 669 | struct DirScanContext dsc; |
660 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
661 | 670 | ||
662 | tc = GNUNET_SCHEDULER_get_task_context (); | 671 | cron_scan = NULL; |
663 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 672 | if (GNUNET_SYSERR == |
664 | return; | 673 | GNUNET_DISK_directory_create (networkIdDirectory)) |
665 | if (GNUNET_SYSERR == GNUNET_DISK_directory_create (networkIdDirectory)) | ||
666 | { | 674 | { |
667 | GNUNET_SCHEDULER_add_delayed_with_priority (DATA_HOST_FREQ, | 675 | cron_scan = GNUNET_SCHEDULER_add_delayed_with_priority (DATA_HOST_FREQ, |
668 | GNUNET_SCHEDULER_PRIORITY_IDLE, | 676 | GNUNET_SCHEDULER_PRIORITY_IDLE, |
669 | &cron_scan_directory_data_hosts, NULL); | 677 | &cron_scan_directory_data_hosts, NULL); |
670 | return; | 678 | return; |
671 | } | 679 | } |
672 | dsc.matched = 0; | 680 | dsc.matched = 0; |
@@ -680,10 +688,10 @@ cron_scan_directory_data_hosts (void *cls) | |||
680 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, | 688 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, |
681 | _("Still no peers found in `%s'!\n"), | 689 | _("Still no peers found in `%s'!\n"), |
682 | networkIdDirectory); | 690 | networkIdDirectory); |
683 | GNUNET_SCHEDULER_add_delayed_with_priority (DATA_HOST_FREQ, | 691 | cron_scan = GNUNET_SCHEDULER_add_delayed_with_priority (DATA_HOST_FREQ, |
684 | GNUNET_SCHEDULER_PRIORITY_IDLE, | 692 | GNUNET_SCHEDULER_PRIORITY_IDLE, |
685 | &cron_scan_directory_data_hosts, | 693 | &cron_scan_directory_data_hosts, |
686 | NULL); | 694 | NULL); |
687 | } | 695 | } |
688 | 696 | ||
689 | 697 | ||
@@ -1046,11 +1054,8 @@ static void | |||
1046 | cron_clean_data_hosts (void *cls) | 1054 | cron_clean_data_hosts (void *cls) |
1047 | { | 1055 | { |
1048 | struct GNUNET_TIME_Absolute now; | 1056 | struct GNUNET_TIME_Absolute now; |
1049 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
1050 | 1057 | ||
1051 | tc = GNUNET_SCHEDULER_get_task_context (); | 1058 | cron_clean = NULL; |
1052 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
1053 | return; | ||
1054 | now = GNUNET_TIME_absolute_get (); | 1059 | now = GNUNET_TIME_absolute_get (); |
1055 | GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK, | 1060 | GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK, |
1056 | _("Cleaning up directory `%s'\n"), | 1061 | _("Cleaning up directory `%s'\n"), |
@@ -1058,9 +1063,9 @@ cron_clean_data_hosts (void *cls) | |||
1058 | GNUNET_DISK_directory_scan (networkIdDirectory, | 1063 | GNUNET_DISK_directory_scan (networkIdDirectory, |
1059 | &discard_hosts_helper, | 1064 | &discard_hosts_helper, |
1060 | &now); | 1065 | &now); |
1061 | GNUNET_SCHEDULER_add_delayed (DATA_HOST_CLEAN_FREQ, | 1066 | cron_clean = GNUNET_SCHEDULER_add_delayed (DATA_HOST_CLEAN_FREQ, |
1062 | &cron_clean_data_hosts, | 1067 | &cron_clean_data_hosts, |
1063 | NULL); | 1068 | NULL); |
1064 | } | 1069 | } |
1065 | 1070 | ||
1066 | 1071 | ||
@@ -1302,6 +1307,16 @@ shutdown_task (void *cls) | |||
1302 | GNUNET_STATISTICS_destroy (stats, GNUNET_NO); | 1307 | GNUNET_STATISTICS_destroy (stats, GNUNET_NO); |
1303 | stats = NULL; | 1308 | stats = NULL; |
1304 | } | 1309 | } |
1310 | if (NULL != cron_clean) | ||
1311 | { | ||
1312 | GNUNET_SCHEDULER_cancel (cron_clean); | ||
1313 | cron_clean = NULL; | ||
1314 | } | ||
1315 | if (NULL != cron_scan) | ||
1316 | { | ||
1317 | GNUNET_SCHEDULER_cancel (cron_scan); | ||
1318 | cron_scan = NULL; | ||
1319 | } | ||
1305 | } | 1320 | } |
1306 | 1321 | ||
1307 | 1322 | ||
@@ -1342,9 +1357,8 @@ run (void *cls, | |||
1342 | "USE_INCLUDED_HELLOS"); | 1357 | "USE_INCLUDED_HELLOS"); |
1343 | if (GNUNET_SYSERR == use_included) | 1358 | if (GNUNET_SYSERR == use_included) |
1344 | use_included = GNUNET_NO; | 1359 | use_included = GNUNET_NO; |
1345 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1360 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
1346 | &shutdown_task, | 1361 | NULL); |
1347 | NULL); | ||
1348 | if (GNUNET_YES != noio) | 1362 | if (GNUNET_YES != noio) |
1349 | { | 1363 | { |
1350 | GNUNET_assert (GNUNET_OK == | 1364 | GNUNET_assert (GNUNET_OK == |
@@ -1358,11 +1372,13 @@ run (void *cls, | |||
1358 | return; | 1372 | return; |
1359 | } | 1373 | } |
1360 | 1374 | ||
1361 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, | 1375 | cron_scan = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, |
1362 | &cron_scan_directory_data_hosts, NULL); | 1376 | &cron_scan_directory_data_hosts, |
1377 | NULL); | ||
1363 | 1378 | ||
1364 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, | 1379 | cron_clean = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, |
1365 | &cron_clean_data_hosts, NULL); | 1380 | &cron_clean_data_hosts, |
1381 | NULL); | ||
1366 | if (GNUNET_YES == use_included) | 1382 | if (GNUNET_YES == use_included) |
1367 | { | 1383 | { |
1368 | ip = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); | 1384 | ip = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); |
diff --git a/src/peerinfo/peerinfo_api.c b/src/peerinfo/peerinfo_api.c index ad4576fc2..0637eda72 100644 --- a/src/peerinfo/peerinfo_api.c +++ b/src/peerinfo/peerinfo_api.c | |||
@@ -786,7 +786,9 @@ GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h, | |||
786 | GNUNET_SCHEDULER_add_delayed (timeout, &signal_timeout, ic); | 786 | GNUNET_SCHEDULER_add_delayed (timeout, &signal_timeout, ic); |
787 | ac->cont = &iterator_start_receive; | 787 | ac->cont = &iterator_start_receive; |
788 | ac->cont_cls = ic; | 788 | ac->cont_cls = ic; |
789 | GNUNET_CONTAINER_DLL_insert_tail (h->ac_head, h->ac_tail, ac); | 789 | GNUNET_CONTAINER_DLL_insert_tail (h->ac_head, |
790 | h->ac_tail, | ||
791 | ac); | ||
790 | GNUNET_CONTAINER_DLL_insert_tail (h->ic_head, | 792 | GNUNET_CONTAINER_DLL_insert_tail (h->ic_head, |
791 | h->ic_tail, | 793 | h->ic_tail, |
792 | ic); | 794 | ic); |
diff --git a/src/peerinfo/peerinfo_api_notify.c b/src/peerinfo/peerinfo_api_notify.c index 16331548d..2a80c6c1a 100644 --- a/src/peerinfo/peerinfo_api_notify.c +++ b/src/peerinfo/peerinfo_api_notify.c | |||
@@ -66,7 +66,7 @@ struct GNUNET_PEERINFO_NotifyContext | |||
66 | /** | 66 | /** |
67 | * Tasked used for delayed re-connection attempt. | 67 | * Tasked used for delayed re-connection attempt. |
68 | */ | 68 | */ |
69 | struct GNUNET_SCHEDULER_Task * task; | 69 | struct GNUNET_SCHEDULER_Task *task; |
70 | 70 | ||
71 | /** | 71 | /** |
72 | * Include friend only HELLOs in callbacks | 72 | * Include friend only HELLOs in callbacks |
@@ -112,7 +112,8 @@ reconnect (void *cls) | |||
112 | { | 112 | { |
113 | /* ugh */ | 113 | /* ugh */ |
114 | nc->task = | 114 | nc->task = |
115 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &reconnect, nc); | 115 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
116 | &reconnect, nc); | ||
116 | return; | 117 | return; |
117 | } | 118 | } |
118 | request_notifications (nc); | 119 | request_notifications (nc); |
diff --git a/src/peerinfo/test_peerinfo_api_notify_friend_only.c b/src/peerinfo/test_peerinfo_api_notify_friend_only.c index d0322713c..403ed4b71 100644 --- a/src/peerinfo/test_peerinfo_api_notify_friend_only.c +++ b/src/peerinfo/test_peerinfo_api_notify_friend_only.c | |||
@@ -127,15 +127,18 @@ address_generator (void *cls, size_t max, void *buf) | |||
127 | return ret; | 127 | return ret; |
128 | } | 128 | } |
129 | 129 | ||
130 | |||
130 | static void | 131 | static void |
131 | process_w_fo (void *cls, const struct GNUNET_PeerIdentity *peer, | 132 | process_w_fo (void *cls, |
132 | const struct GNUNET_HELLO_Message *hello, const char *err_msg) | 133 | const struct GNUNET_PeerIdentity *peer, |
134 | const struct GNUNET_HELLO_Message *hello, | ||
135 | const char *err_msg) | ||
133 | { | 136 | { |
134 | if (err_msg != NULL ) | 137 | if (err_msg != NULL) |
135 | { | 138 | { |
136 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 139 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
137 | _("Error in communication with PEERINFO service\n")); | 140 | _("Error in communication with PEERINFO service\n")); |
138 | GNUNET_SCHEDULER_add_now (&done, NULL ); | 141 | GNUNET_SCHEDULER_add_now (&done, NULL); |
139 | return; | 142 | return; |
140 | } | 143 | } |
141 | 144 | ||
@@ -160,7 +163,7 @@ process_w_fo (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
160 | if (0 == memcmp (&pid, peer, sizeof(pid))) | 163 | if (0 == memcmp (&pid, peer, sizeof(pid))) |
161 | { | 164 | { |
162 | res_cb_w_fo = GNUNET_YES; | 165 | res_cb_w_fo = GNUNET_YES; |
163 | GNUNET_SCHEDULER_add_now (&done, NULL ); | 166 | GNUNET_SCHEDULER_add_now (&done, NULL); |
164 | } | 167 | } |
165 | return; | 168 | return; |
166 | } | 169 | } |
@@ -170,11 +173,11 @@ static void | |||
170 | process_wo_fo (void *cls, const struct GNUNET_PeerIdentity *peer, | 173 | process_wo_fo (void *cls, const struct GNUNET_PeerIdentity *peer, |
171 | const struct GNUNET_HELLO_Message *hello, const char *err_msg) | 174 | const struct GNUNET_HELLO_Message *hello, const char *err_msg) |
172 | { | 175 | { |
173 | if (err_msg != NULL ) | 176 | if (err_msg != NULL) |
174 | { | 177 | { |
175 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 178 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
176 | _("Error in communication with PEERINFO service\n")); | 179 | _("Error in communication with PEERINFO service\n")); |
177 | GNUNET_SCHEDULER_add_now (&done, NULL ); | 180 | GNUNET_SCHEDULER_add_now (&done, NULL); |
178 | return; | 181 | return; |
179 | } | 182 | } |
180 | 183 | ||
@@ -204,6 +207,7 @@ process_wo_fo (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
204 | } | 207 | } |
205 | } | 208 | } |
206 | 209 | ||
210 | |||
207 | static void | 211 | static void |
208 | add_peer_done (void *cls, const char *emsg) | 212 | add_peer_done (void *cls, const char *emsg) |
209 | { | 213 | { |
@@ -215,10 +219,11 @@ add_peer_done (void *cls, const char *emsg) | |||
215 | { | 219 | { |
216 | GNUNET_break(0); | 220 | GNUNET_break(0); |
217 | GNUNET_SCHEDULER_cancel (timeout_task); | 221 | GNUNET_SCHEDULER_cancel (timeout_task); |
218 | timeout_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL ); | 222 | timeout_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); |
219 | } | 223 | } |
220 | } | 224 | } |
221 | 225 | ||
226 | |||
222 | static void | 227 | static void |
223 | add_peer () | 228 | add_peer () |
224 | { | 229 | { |
@@ -229,33 +234,37 @@ add_peer () | |||
229 | memset (&pid, 32, sizeof(pid)); | 234 | memset (&pid, 32, sizeof(pid)); |
230 | h2 = GNUNET_HELLO_create (&pid.public_key, &address_generator, &agc, | 235 | h2 = GNUNET_HELLO_create (&pid.public_key, &address_generator, &agc, |
231 | GNUNET_YES); | 236 | GNUNET_YES); |
232 | GNUNET_PEERINFO_add_peer (h, h2, &add_peer_done, NULL ); | 237 | GNUNET_PEERINFO_add_peer (h, h2, &add_peer_done, NULL); |
233 | GNUNET_free(h2); | 238 | GNUNET_free(h2); |
234 | 239 | ||
235 | } | 240 | } |
236 | 241 | ||
242 | |||
237 | static void | 243 | static void |
238 | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, | 244 | run (void *cls, |
239 | struct GNUNET_TESTING_Peer *peer) | 245 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
246 | struct GNUNET_TESTING_Peer *peer) | ||
240 | { | 247 | { |
241 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL ); | 248 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); |
242 | mycfg = cfg; | 249 | mycfg = cfg; |
243 | pnc_w_fo = GNUNET_PEERINFO_notify (mycfg, GNUNET_YES, &process_w_fo, NULL ); | 250 | pnc_w_fo = GNUNET_PEERINFO_notify (mycfg, GNUNET_YES, &process_w_fo, NULL); |
244 | pnc_wo_fo = GNUNET_PEERINFO_notify (mycfg, GNUNET_NO, &process_wo_fo, NULL ); | 251 | pnc_wo_fo = GNUNET_PEERINFO_notify (mycfg, GNUNET_NO, &process_wo_fo, NULL); |
245 | h = GNUNET_PEERINFO_connect (cfg); | 252 | h = GNUNET_PEERINFO_connect (cfg); |
246 | GNUNET_assert(NULL != h); | 253 | GNUNET_assert(NULL != h); |
247 | add_peer (); | 254 | add_peer (); |
248 | } | 255 | } |
249 | 256 | ||
257 | |||
250 | int | 258 | int |
251 | main (int argc, char *argv[]) | 259 | main (int argc, char *argv[]) |
252 | { | 260 | { |
253 | res_cb_w_fo = GNUNET_NO; | 261 | res_cb_w_fo = GNUNET_NO; |
254 | res_cb_wo_fo = GNUNET_NO; | 262 | res_cb_wo_fo = GNUNET_NO; |
255 | global_ret = 3; | 263 | global_ret = 3; |
256 | if (0 | 264 | if (0 != GNUNET_TESTING_service_run ("test-peerinfo-api-friend-only", |
257 | != GNUNET_TESTING_service_run ("test-peerinfo-api-friend-only", | 265 | "peerinfo", |
258 | "peerinfo", "test_peerinfo_api_data.conf", &run, NULL )) | 266 | "test_peerinfo_api_data.conf", |
267 | &run, NULL)) | ||
259 | return 1; | 268 | return 1; |
260 | return global_ret; | 269 | return global_ret; |
261 | } | 270 | } |
diff --git a/src/peerstore/gnunet-peerstore.c b/src/peerstore/gnunet-peerstore.c index 68ae1746f..25a4f0ff4 100644 --- a/src/peerstore/gnunet-peerstore.c +++ b/src/peerstore/gnunet-peerstore.c | |||
@@ -60,16 +60,15 @@ shutdown_task (void *cls) | |||
60 | * @param cfg configuration | 60 | * @param cfg configuration |
61 | */ | 61 | */ |
62 | static void | 62 | static void |
63 | run (void *cls, char *const *args, const char *cfgfile, | 63 | run (void *cls, |
64 | char *const *args, | ||
65 | const char *cfgfile, | ||
64 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 66 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
65 | { | 67 | { |
66 | 68 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, | |
67 | peerstore_handle = NULL; | 69 | NULL); |
68 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | ||
69 | NULL); | ||
70 | peerstore_handle = GNUNET_PEERSTORE_connect (cfg); | 70 | peerstore_handle = GNUNET_PEERSTORE_connect (cfg); |
71 | GNUNET_assert (NULL != peerstore_handle); | 71 | GNUNET_assert (NULL != peerstore_handle); |
72 | |||
73 | ret = 0; | 72 | ret = 0; |
74 | } | 73 | } |
75 | 74 | ||
diff --git a/src/peerstore/gnunet-service-peerstore.c b/src/peerstore/gnunet-service-peerstore.c index 3a2d928e3..048201c77 100644 --- a/src/peerstore/gnunet-service-peerstore.c +++ b/src/peerstore/gnunet-service-peerstore.c | |||
@@ -91,6 +91,11 @@ static struct ClientEntry *client_head; | |||
91 | static struct ClientEntry *client_tail; | 91 | static struct ClientEntry *client_tail; |
92 | 92 | ||
93 | /** | 93 | /** |
94 | * Task run to clean up expired records. | ||
95 | */ | ||
96 | static struct GNUNET_SCHEDULER_Task *expire_task; | ||
97 | |||
98 | /** | ||
94 | * Are we in the process of shutting down the service? #GNUNET_YES / #GNUNET_NO | 99 | * Are we in the process of shutting down the service? #GNUNET_YES / #GNUNET_NO |
95 | */ | 100 | */ |
96 | static int in_shutdown; | 101 | static int in_shutdown; |
@@ -117,6 +122,11 @@ do_shutdown () | |||
117 | GNUNET_CONTAINER_multihashmap_destroy (watchers); | 122 | GNUNET_CONTAINER_multihashmap_destroy (watchers); |
118 | watchers = NULL; | 123 | watchers = NULL; |
119 | } | 124 | } |
125 | if (NULL != expire_task) | ||
126 | { | ||
127 | GNUNET_SCHEDULER_cancel (expire_task); | ||
128 | expire_task = NULL; | ||
129 | } | ||
120 | GNUNET_SCHEDULER_shutdown (); | 130 | GNUNET_SCHEDULER_shutdown (); |
121 | } | 131 | } |
122 | 132 | ||
@@ -147,21 +157,18 @@ static void | |||
147 | cleanup_expired_records (void *cls) | 157 | cleanup_expired_records (void *cls) |
148 | { | 158 | { |
149 | int ret; | 159 | int ret; |
150 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
151 | 160 | ||
152 | tc = GNUNET_SCHEDULER_get_task_context (); | 161 | expire_task = NULL; |
153 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
154 | return; | ||
155 | GNUNET_assert (NULL != db); | 162 | GNUNET_assert (NULL != db); |
156 | ret = | 163 | ret = db->expire_records (db->cls, GNUNET_TIME_absolute_get (), |
157 | db->expire_records (db->cls, GNUNET_TIME_absolute_get (), | 164 | &expire_records_continuation, NULL); |
158 | expire_records_continuation, NULL); | ||
159 | if (GNUNET_OK != ret) | 165 | if (GNUNET_OK != ret) |
160 | { | 166 | { |
161 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 167 | GNUNET_assert (NULL == expire_task); |
162 | (GNUNET_TIME_UNIT_SECONDS, | 168 | expire_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
163 | EXPIRED_RECORDS_CLEANUP_INTERVAL), | 169 | (GNUNET_TIME_UNIT_SECONDS, |
164 | &cleanup_expired_records, NULL); | 170 | EXPIRED_RECORDS_CLEANUP_INTERVAL), |
171 | &cleanup_expired_records, NULL); | ||
165 | } | 172 | } |
166 | } | 173 | } |
167 | 174 | ||
@@ -173,14 +180,18 @@ cleanup_expired_records (void *cls) | |||
173 | * @param success count of records deleted or #GNUNET_SYSERR | 180 | * @param success count of records deleted or #GNUNET_SYSERR |
174 | */ | 181 | */ |
175 | static void | 182 | static void |
176 | expire_records_continuation (void *cls, int success) | 183 | expire_records_continuation (void *cls, |
184 | int success) | ||
177 | { | 185 | { |
178 | if (success > 0) | 186 | if (success > 0) |
179 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%d records expired.\n", success); | 187 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
180 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 188 | "%d records expired.\n", |
181 | (GNUNET_TIME_UNIT_SECONDS, | 189 | success); |
182 | EXPIRED_RECORDS_CLEANUP_INTERVAL), | 190 | GNUNET_assert (NULL == expire_task); |
183 | &cleanup_expired_records, NULL); | 191 | expire_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
192 | (GNUNET_TIME_UNIT_SECONDS, | ||
193 | EXPIRED_RECORDS_CLEANUP_INTERVAL), | ||
194 | &cleanup_expired_records, NULL); | ||
184 | } | 195 | } |
185 | 196 | ||
186 | 197 | ||
@@ -565,18 +576,20 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
565 | if (NULL == db) | 576 | if (NULL == db) |
566 | { | 577 | { |
567 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 578 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
568 | _("Could not load database backend `%s'\n"), db_lib_name); | 579 | _("Could not load database backend `%s'\n"), |
580 | db_lib_name); | ||
569 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | 581 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); |
570 | return; | 582 | return; |
571 | } | 583 | } |
572 | nc = GNUNET_SERVER_notification_context_create (server, 16); | 584 | nc = GNUNET_SERVER_notification_context_create (server, 16); |
573 | watchers = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO); | 585 | watchers = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO); |
574 | GNUNET_SCHEDULER_add_now (&cleanup_expired_records, NULL); | 586 | expire_task = GNUNET_SCHEDULER_add_now (&cleanup_expired_records, |
587 | NULL); | ||
575 | GNUNET_SERVER_add_handlers (server, handlers); | 588 | GNUNET_SERVER_add_handlers (server, handlers); |
576 | GNUNET_SERVER_connect_notify (server, &handle_client_connect, NULL); | 589 | GNUNET_SERVER_connect_notify (server, &handle_client_connect, NULL); |
577 | GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); | 590 | GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); |
578 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 591 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
579 | NULL); | 592 | NULL); |
580 | } | 593 | } |
581 | 594 | ||
582 | 595 | ||
diff --git a/src/peerstore/peerstore_api.c b/src/peerstore/peerstore_api.c index 14117a333..f1c5ccd32 100644 --- a/src/peerstore/peerstore_api.c +++ b/src/peerstore/peerstore_api.c | |||
@@ -213,7 +213,7 @@ struct GNUNET_PEERSTORE_IterateContext | |||
213 | * Task identifier for the function called | 213 | * Task identifier for the function called |
214 | * on iterate request timeout | 214 | * on iterate request timeout |
215 | */ | 215 | */ |
216 | struct GNUNET_SCHEDULER_Task * timeout_task; | 216 | struct GNUNET_SCHEDULER_Task *timeout_task; |
217 | 217 | ||
218 | }; | 218 | }; |
219 | 219 | ||
@@ -340,7 +340,9 @@ handle_client_error (void *cls, enum GNUNET_MQ_Error error) | |||
340 | * @return #GNUNET_YES (continue to iterate) | 340 | * @return #GNUNET_YES (continue to iterate) |
341 | */ | 341 | */ |
342 | static int | 342 | static int |
343 | rewatch_it (void *cls, const struct GNUNET_HashCode *key, void *value) | 343 | rewatch_it (void *cls, |
344 | const struct GNUNET_HashCode *key, | ||
345 | void *value) | ||
344 | { | 346 | { |
345 | struct GNUNET_PEERSTORE_Handle *h = cls; | 347 | struct GNUNET_PEERSTORE_Handle *h = cls; |
346 | struct GNUNET_PEERSTORE_WatchContext *wc = value; | 348 | struct GNUNET_PEERSTORE_WatchContext *wc = value; |
diff --git a/src/psyc/gnunet-service-psyc.c b/src/psyc/gnunet-service-psyc.c index 2b436aa21..0f2216428 100644 --- a/src/psyc/gnunet-service-psyc.c +++ b/src/psyc/gnunet-service-psyc.c | |||
@@ -2007,7 +2007,7 @@ transmit_notify (void *cls, size_t *data_size, void *data) | |||
2007 | 2007 | ||
2008 | if (NULL != chn->tmit_head) | 2008 | if (NULL != chn->tmit_head) |
2009 | { | 2009 | { |
2010 | GNUNET_SCHEDULER_add_now (schedule_transmit_message, chn); | 2010 | GNUNET_SCHEDULER_add_now (&schedule_transmit_message, chn); |
2011 | } | 2011 | } |
2012 | else if (GNUNET_YES == chn->is_disconnected | 2012 | else if (GNUNET_YES == chn->is_disconnected |
2013 | && tmit_msg->last_ptype < GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END) | 2013 | && tmit_msg->last_ptype < GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END) |
@@ -2645,8 +2645,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
2645 | nc = GNUNET_SERVER_notification_context_create (server, 1); | 2645 | nc = GNUNET_SERVER_notification_context_create (server, 1); |
2646 | GNUNET_SERVER_add_handlers (server, server_handlers); | 2646 | GNUNET_SERVER_add_handlers (server, server_handlers); |
2647 | GNUNET_SERVER_disconnect_notify (server, &client_disconnect, NULL); | 2647 | GNUNET_SERVER_disconnect_notify (server, &client_disconnect, NULL); |
2648 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 2648 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
2649 | &shutdown_task, NULL); | ||
2650 | } | 2649 | } |
2651 | 2650 | ||
2652 | 2651 | ||
diff --git a/src/psyc/test_psyc.c b/src/psyc/test_psyc.c index 1169b49d5..5ea83dd63 100644 --- a/src/psyc/test_psyc.c +++ b/src/psyc/test_psyc.c | |||
@@ -41,28 +41,28 @@ | |||
41 | /** | 41 | /** |
42 | * Return value from 'main'. | 42 | * Return value from 'main'. |
43 | */ | 43 | */ |
44 | int res; | 44 | static int res; |
45 | 45 | ||
46 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 46 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
47 | 47 | ||
48 | struct GNUNET_CORE_Handle *core; | 48 | static struct GNUNET_CORE_Handle *core; |
49 | struct GNUNET_PeerIdentity this_peer; | 49 | static struct GNUNET_PeerIdentity this_peer; |
50 | 50 | ||
51 | /** | 51 | /** |
52 | * Handle for task for timeout termination. | 52 | * Handle for task for timeout termination. |
53 | */ | 53 | */ |
54 | struct GNUNET_SCHEDULER_Task * end_badly_task; | 54 | static struct GNUNET_SCHEDULER_Task * end_badly_task; |
55 | 55 | ||
56 | struct GNUNET_PSYC_Master *mst; | 56 | static struct GNUNET_PSYC_Master *mst; |
57 | struct GNUNET_PSYC_Slave *slv; | 57 | static struct GNUNET_PSYC_Slave *slv; |
58 | 58 | ||
59 | struct GNUNET_PSYC_Channel *mst_chn, *slv_chn; | 59 | static struct GNUNET_PSYC_Channel *mst_chn, *slv_chn; |
60 | 60 | ||
61 | struct GNUNET_CRYPTO_EddsaPrivateKey *channel_key; | 61 | static struct GNUNET_CRYPTO_EddsaPrivateKey *channel_key; |
62 | struct GNUNET_CRYPTO_EcdsaPrivateKey *slave_key; | 62 | static struct GNUNET_CRYPTO_EcdsaPrivateKey *slave_key; |
63 | 63 | ||
64 | struct GNUNET_CRYPTO_EddsaPublicKey channel_pub_key; | 64 | static struct GNUNET_CRYPTO_EddsaPublicKey channel_pub_key; |
65 | struct GNUNET_CRYPTO_EcdsaPublicKey slave_pub_key; | 65 | static struct GNUNET_CRYPTO_EcdsaPublicKey slave_pub_key; |
66 | 66 | ||
67 | struct TransmitClosure | 67 | struct TransmitClosure |
68 | { | 68 | { |
@@ -79,9 +79,9 @@ struct TransmitClosure | |||
79 | uint8_t n; | 79 | uint8_t n; |
80 | }; | 80 | }; |
81 | 81 | ||
82 | struct TransmitClosure *tmit; | 82 | static struct TransmitClosure *tmit; |
83 | 83 | ||
84 | uint8_t join_req_count, end_count; | 84 | static uint8_t join_req_count, end_count; |
85 | 85 | ||
86 | enum | 86 | enum |
87 | { | 87 | { |
@@ -104,14 +104,15 @@ enum | |||
104 | } test; | 104 | } test; |
105 | 105 | ||
106 | 106 | ||
107 | void | 107 | static void |
108 | master_transmit (); | 108 | master_transmit (); |
109 | 109 | ||
110 | void | 110 | static void |
111 | master_history_replay_latest (); | 111 | master_history_replay_latest (); |
112 | 112 | ||
113 | 113 | ||
114 | void master_stopped (void *cls) | 114 | static void |
115 | master_stopped (void *cls) | ||
115 | { | 116 | { |
116 | if (NULL != tmit) | 117 | if (NULL != tmit) |
117 | { | 118 | { |
@@ -122,7 +123,9 @@ void master_stopped (void *cls) | |||
122 | GNUNET_SCHEDULER_shutdown (); | 123 | GNUNET_SCHEDULER_shutdown (); |
123 | } | 124 | } |
124 | 125 | ||
125 | void slave_parted (void *cls) | 126 | |
127 | static void | ||
128 | slave_parted (void *cls) | ||
126 | { | 129 | { |
127 | if (NULL != mst) | 130 | if (NULL != mst) |
128 | { | 131 | { |
@@ -133,10 +136,11 @@ void slave_parted (void *cls) | |||
133 | master_stopped (NULL); | 136 | master_stopped (NULL); |
134 | } | 137 | } |
135 | 138 | ||
139 | |||
136 | /** | 140 | /** |
137 | * Clean up all resources used. | 141 | * Clean up all resources used. |
138 | */ | 142 | */ |
139 | void | 143 | static void |
140 | cleanup () | 144 | cleanup () |
141 | { | 145 | { |
142 | if (NULL != core) | 146 | if (NULL != core) |
@@ -185,7 +189,7 @@ end_normally (void *cls) | |||
185 | /** | 189 | /** |
186 | * Finish the test case (successfully). | 190 | * Finish the test case (successfully). |
187 | */ | 191 | */ |
188 | void | 192 | static void |
189 | end () | 193 | end () |
190 | { | 194 | { |
191 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending tests.\n"); | 195 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending tests.\n"); |
@@ -200,7 +204,7 @@ end () | |||
200 | } | 204 | } |
201 | 205 | ||
202 | 206 | ||
203 | void | 207 | static void |
204 | master_message_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg) | 208 | master_message_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg) |
205 | { | 209 | { |
206 | GNUNET_assert (NULL != msg); | 210 | GNUNET_assert (NULL != msg); |
@@ -213,7 +217,7 @@ master_message_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg) | |||
213 | } | 217 | } |
214 | 218 | ||
215 | 219 | ||
216 | void | 220 | static void |
217 | master_message_part_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg, | 221 | master_message_part_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg, |
218 | const struct GNUNET_MessageHeader *pmsg) | 222 | const struct GNUNET_MessageHeader *pmsg) |
219 | { | 223 | { |
@@ -270,7 +274,7 @@ master_message_part_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg, | |||
270 | } | 274 | } |
271 | 275 | ||
272 | 276 | ||
273 | void | 277 | static void |
274 | slave_message_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg) | 278 | slave_message_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg) |
275 | { | 279 | { |
276 | GNUNET_assert (NULL != msg); | 280 | GNUNET_assert (NULL != msg); |
@@ -283,7 +287,7 @@ slave_message_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg) | |||
283 | } | 287 | } |
284 | 288 | ||
285 | 289 | ||
286 | void | 290 | static void |
287 | slave_message_part_cb (void *cls, | 291 | slave_message_part_cb (void *cls, |
288 | const struct GNUNET_PSYC_MessageHeader *msg, | 292 | const struct GNUNET_PSYC_MessageHeader *msg, |
289 | const struct GNUNET_MessageHeader *pmsg) | 293 | const struct GNUNET_MessageHeader *pmsg) |
@@ -326,7 +330,7 @@ slave_message_part_cb (void *cls, | |||
326 | } | 330 | } |
327 | 331 | ||
328 | 332 | ||
329 | void | 333 | static void |
330 | state_get_var (void *cls, const struct GNUNET_MessageHeader *mod, | 334 | state_get_var (void *cls, const struct GNUNET_MessageHeader *mod, |
331 | const char *name, const void *value, | 335 | const char *name, const void *value, |
332 | uint32_t value_size, uint32_t full_value_size) | 336 | uint32_t value_size, uint32_t full_value_size) |
@@ -338,7 +342,7 @@ state_get_var (void *cls, const struct GNUNET_MessageHeader *mod, | |||
338 | 342 | ||
339 | /*** Slave state_get_prefix() ***/ | 343 | /*** Slave state_get_prefix() ***/ |
340 | 344 | ||
341 | void | 345 | static void |
342 | slave_state_get_prefix_result (void *cls, int64_t result, | 346 | slave_state_get_prefix_result (void *cls, int64_t result, |
343 | const void *err_msg, uint16_t err_msg_size) | 347 | const void *err_msg, uint16_t err_msg_size) |
344 | { | 348 | { |
@@ -350,7 +354,7 @@ slave_state_get_prefix_result (void *cls, int64_t result, | |||
350 | } | 354 | } |
351 | 355 | ||
352 | 356 | ||
353 | void | 357 | static void |
354 | slave_state_get_prefix () | 358 | slave_state_get_prefix () |
355 | { | 359 | { |
356 | test = TEST_SLAVE_STATE_GET_PREFIX; | 360 | test = TEST_SLAVE_STATE_GET_PREFIX; |
@@ -362,7 +366,7 @@ slave_state_get_prefix () | |||
362 | /*** Master state_get_prefix() ***/ | 366 | /*** Master state_get_prefix() ***/ |
363 | 367 | ||
364 | 368 | ||
365 | void | 369 | static void |
366 | master_state_get_prefix_result (void *cls, int64_t result, | 370 | master_state_get_prefix_result (void *cls, int64_t result, |
367 | const void *err_msg, uint16_t err_msg_size) | 371 | const void *err_msg, uint16_t err_msg_size) |
368 | { | 372 | { |
@@ -373,7 +377,7 @@ master_state_get_prefix_result (void *cls, int64_t result, | |||
373 | } | 377 | } |
374 | 378 | ||
375 | 379 | ||
376 | void | 380 | static void |
377 | master_state_get_prefix () | 381 | master_state_get_prefix () |
378 | { | 382 | { |
379 | test = TEST_MASTER_STATE_GET_PREFIX; | 383 | test = TEST_MASTER_STATE_GET_PREFIX; |
@@ -385,7 +389,7 @@ master_state_get_prefix () | |||
385 | /*** Slave state_get() ***/ | 389 | /*** Slave state_get() ***/ |
386 | 390 | ||
387 | 391 | ||
388 | void | 392 | static void |
389 | slave_state_get_result (void *cls, int64_t result, | 393 | slave_state_get_result (void *cls, int64_t result, |
390 | const void *err_msg, uint16_t err_msg_size) | 394 | const void *err_msg, uint16_t err_msg_size) |
391 | { | 395 | { |
@@ -397,7 +401,7 @@ slave_state_get_result (void *cls, int64_t result, | |||
397 | } | 401 | } |
398 | 402 | ||
399 | 403 | ||
400 | void | 404 | static void |
401 | slave_state_get () | 405 | slave_state_get () |
402 | { | 406 | { |
403 | test = TEST_SLAVE_STATE_GET; | 407 | test = TEST_SLAVE_STATE_GET; |
@@ -409,7 +413,7 @@ slave_state_get () | |||
409 | /*** Master state_get() ***/ | 413 | /*** Master state_get() ***/ |
410 | 414 | ||
411 | 415 | ||
412 | void | 416 | static void |
413 | master_state_get_result (void *cls, int64_t result, | 417 | master_state_get_result (void *cls, int64_t result, |
414 | const void *err_msg, uint16_t err_msg_size) | 418 | const void *err_msg, uint16_t err_msg_size) |
415 | { | 419 | { |
@@ -421,7 +425,7 @@ master_state_get_result (void *cls, int64_t result, | |||
421 | } | 425 | } |
422 | 426 | ||
423 | 427 | ||
424 | void | 428 | static void |
425 | master_state_get () | 429 | master_state_get () |
426 | { | 430 | { |
427 | test = TEST_MASTER_STATE_GET; | 431 | test = TEST_MASTER_STATE_GET; |
@@ -432,7 +436,7 @@ master_state_get () | |||
432 | 436 | ||
433 | /*** Slave history_replay() ***/ | 437 | /*** Slave history_replay() ***/ |
434 | 438 | ||
435 | void | 439 | static void |
436 | slave_history_replay_result (void *cls, int64_t result, | 440 | slave_history_replay_result (void *cls, int64_t result, |
437 | const void *err_msg, uint16_t err_msg_size) | 441 | const void *err_msg, uint16_t err_msg_size) |
438 | { | 442 | { |
@@ -445,7 +449,7 @@ slave_history_replay_result (void *cls, int64_t result, | |||
445 | } | 449 | } |
446 | 450 | ||
447 | 451 | ||
448 | void | 452 | static void |
449 | slave_history_replay () | 453 | slave_history_replay () |
450 | { | 454 | { |
451 | test = TEST_SLAVE_HISTORY_REPLAY; | 455 | test = TEST_SLAVE_HISTORY_REPLAY; |
@@ -460,7 +464,7 @@ slave_history_replay () | |||
460 | /*** Master history_replay() ***/ | 464 | /*** Master history_replay() ***/ |
461 | 465 | ||
462 | 466 | ||
463 | void | 467 | static void |
464 | master_history_replay_result (void *cls, int64_t result, | 468 | master_history_replay_result (void *cls, int64_t result, |
465 | const void *err_msg, uint16_t err_msg_size) | 469 | const void *err_msg, uint16_t err_msg_size) |
466 | { | 470 | { |
@@ -473,7 +477,7 @@ master_history_replay_result (void *cls, int64_t result, | |||
473 | } | 477 | } |
474 | 478 | ||
475 | 479 | ||
476 | void | 480 | static void |
477 | master_history_replay () | 481 | master_history_replay () |
478 | { | 482 | { |
479 | test = TEST_MASTER_HISTORY_REPLAY; | 483 | test = TEST_MASTER_HISTORY_REPLAY; |
@@ -488,7 +492,7 @@ master_history_replay () | |||
488 | /*** Slave history_replay_latest() ***/ | 492 | /*** Slave history_replay_latest() ***/ |
489 | 493 | ||
490 | 494 | ||
491 | void | 495 | static void |
492 | slave_history_replay_latest_result (void *cls, int64_t result, | 496 | slave_history_replay_latest_result (void *cls, int64_t result, |
493 | const void *err_msg, uint16_t err_msg_size) | 497 | const void *err_msg, uint16_t err_msg_size) |
494 | { | 498 | { |
@@ -501,7 +505,7 @@ slave_history_replay_latest_result (void *cls, int64_t result, | |||
501 | } | 505 | } |
502 | 506 | ||
503 | 507 | ||
504 | void | 508 | static void |
505 | slave_history_replay_latest () | 509 | slave_history_replay_latest () |
506 | { | 510 | { |
507 | test = TEST_SLAVE_HISTORY_REPLAY_LATEST; | 511 | test = TEST_SLAVE_HISTORY_REPLAY_LATEST; |
@@ -517,7 +521,7 @@ slave_history_replay_latest () | |||
517 | /*** Master history_replay_latest() ***/ | 521 | /*** Master history_replay_latest() ***/ |
518 | 522 | ||
519 | 523 | ||
520 | void | 524 | static void |
521 | master_history_replay_latest_result (void *cls, int64_t result, | 525 | master_history_replay_latest_result (void *cls, int64_t result, |
522 | const void *err_msg, uint16_t err_msg_size) | 526 | const void *err_msg, uint16_t err_msg_size) |
523 | { | 527 | { |
@@ -530,7 +534,7 @@ master_history_replay_latest_result (void *cls, int64_t result, | |||
530 | } | 534 | } |
531 | 535 | ||
532 | 536 | ||
533 | void | 537 | static void |
534 | master_history_replay_latest () | 538 | master_history_replay_latest () |
535 | { | 539 | { |
536 | test = TEST_MASTER_HISTORY_REPLAY_LATEST; | 540 | test = TEST_MASTER_HISTORY_REPLAY_LATEST; |
@@ -555,7 +559,7 @@ transmit_resume (void *cls) | |||
555 | } | 559 | } |
556 | 560 | ||
557 | 561 | ||
558 | int | 562 | static int |
559 | tmit_notify_data (void *cls, uint16_t *data_size, void *data) | 563 | tmit_notify_data (void *cls, uint16_t *data_size, void *data) |
560 | { | 564 | { |
561 | struct TransmitClosure *tmit = cls; | 565 | struct TransmitClosure *tmit = cls; |
@@ -598,7 +602,7 @@ tmit_notify_data (void *cls, uint16_t *data_size, void *data) | |||
598 | } | 602 | } |
599 | 603 | ||
600 | 604 | ||
601 | int | 605 | static int |
602 | tmit_notify_mod (void *cls, uint16_t *data_size, void *data, uint8_t *oper, | 606 | tmit_notify_mod (void *cls, uint16_t *data_size, void *data, uint8_t *oper, |
603 | uint32_t *full_value_size) | 607 | uint32_t *full_value_size) |
604 | { | 608 | { |
@@ -678,7 +682,7 @@ static void | |||
678 | slave_join (); | 682 | slave_join (); |
679 | 683 | ||
680 | 684 | ||
681 | void | 685 | static void |
682 | slave_transmit () | 686 | slave_transmit () |
683 | { | 687 | { |
684 | test = TEST_SLAVE_TRANSMIT; | 688 | test = TEST_SLAVE_TRANSMIT; |
@@ -702,7 +706,7 @@ slave_transmit () | |||
702 | } | 706 | } |
703 | 707 | ||
704 | 708 | ||
705 | void | 709 | static void |
706 | slave_remove_cb (void *cls, int64_t result, | 710 | slave_remove_cb (void *cls, int64_t result, |
707 | const void *err_msg, uint16_t err_msg_size) | 711 | const void *err_msg, uint16_t err_msg_size) |
708 | { | 712 | { |
@@ -714,7 +718,7 @@ slave_remove_cb (void *cls, int64_t result, | |||
714 | } | 718 | } |
715 | 719 | ||
716 | 720 | ||
717 | void | 721 | static void |
718 | slave_remove () | 722 | slave_remove () |
719 | { | 723 | { |
720 | test = TEST_SLAVE_REMOVE; | 724 | test = TEST_SLAVE_REMOVE; |
@@ -724,7 +728,7 @@ slave_remove () | |||
724 | } | 728 | } |
725 | 729 | ||
726 | 730 | ||
727 | void | 731 | static void |
728 | slave_add_cb (void *cls, int64_t result, | 732 | slave_add_cb (void *cls, int64_t result, |
729 | const void *err_msg, uint16_t err_msg_size) | 733 | const void *err_msg, uint16_t err_msg_size) |
730 | { | 734 | { |
@@ -735,7 +739,7 @@ slave_add_cb (void *cls, int64_t result, | |||
735 | } | 739 | } |
736 | 740 | ||
737 | 741 | ||
738 | void | 742 | static void |
739 | slave_add () | 743 | slave_add () |
740 | { | 744 | { |
741 | test = TEST_SLAVE_ADD; | 745 | test = TEST_SLAVE_ADD; |
@@ -744,7 +748,8 @@ slave_add () | |||
744 | } | 748 | } |
745 | 749 | ||
746 | 750 | ||
747 | void first_slave_parted (void *cls) | 751 | static void |
752 | first_slave_parted (void *cls) | ||
748 | { | 753 | { |
749 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "First slave parted.\n"); | 754 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "First slave parted.\n"); |
750 | slave_join (TEST_SLAVE_JOIN_ACCEPT); | 755 | slave_join (TEST_SLAVE_JOIN_ACCEPT); |
@@ -754,7 +759,7 @@ void first_slave_parted (void *cls) | |||
754 | static void | 759 | static void |
755 | schedule_slave_part (void *cls) | 760 | schedule_slave_part (void *cls) |
756 | { | 761 | { |
757 | GNUNET_PSYC_slave_part (slv, GNUNET_NO, first_slave_parted, NULL); | 762 | GNUNET_PSYC_slave_part (slv, GNUNET_NO, &first_slave_parted, NULL); |
758 | } | 763 | } |
759 | 764 | ||
760 | 765 | ||
@@ -772,7 +777,7 @@ join_decision_cb (void *cls, | |||
772 | case TEST_SLAVE_JOIN_REJECT: | 777 | case TEST_SLAVE_JOIN_REJECT: |
773 | GNUNET_assert (0 == is_admitted); | 778 | GNUNET_assert (0 == is_admitted); |
774 | GNUNET_assert (1 == join_req_count); | 779 | GNUNET_assert (1 == join_req_count); |
775 | GNUNET_SCHEDULER_add_now (schedule_slave_part, NULL); | 780 | GNUNET_SCHEDULER_add_now (&schedule_slave_part, NULL); |
776 | break; | 781 | break; |
777 | 782 | ||
778 | case TEST_SLAVE_JOIN_ACCEPT: | 783 | case TEST_SLAVE_JOIN_ACCEPT: |
@@ -844,7 +849,7 @@ slave_join (int t) | |||
844 | } | 849 | } |
845 | 850 | ||
846 | 851 | ||
847 | void | 852 | static void |
848 | master_transmit () | 853 | master_transmit () |
849 | { | 854 | { |
850 | test = TEST_MASTER_TRANSMIT; | 855 | test = TEST_MASTER_TRANSMIT; |
@@ -899,7 +904,7 @@ master_transmit () | |||
899 | } | 904 | } |
900 | 905 | ||
901 | 906 | ||
902 | void | 907 | static void |
903 | master_start_cb (void *cls, int result, uint64_t max_message_id) | 908 | master_start_cb (void *cls, int result, uint64_t max_message_id) |
904 | { | 909 | { |
905 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 910 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -911,7 +916,7 @@ master_start_cb (void *cls, int result, uint64_t max_message_id) | |||
911 | } | 916 | } |
912 | 917 | ||
913 | 918 | ||
914 | void | 919 | static void |
915 | master_start () | 920 | master_start () |
916 | { | 921 | { |
917 | test = TEST_MASTER_START; | 922 | test = TEST_MASTER_START; |
@@ -931,7 +936,7 @@ schedule_master_start (void *cls) | |||
931 | } | 936 | } |
932 | 937 | ||
933 | 938 | ||
934 | void | 939 | static void |
935 | core_connected (void *cls, const struct GNUNET_PeerIdentity *my_identity) | 940 | core_connected (void *cls, const struct GNUNET_PeerIdentity *my_identity) |
936 | { | 941 | { |
937 | this_peer = *my_identity; | 942 | this_peer = *my_identity; |
@@ -953,7 +958,7 @@ core_connected (void *cls, const struct GNUNET_PeerIdentity *my_identity) | |||
953 | * @param cfg configuration we use (also to connect to PSYC service) | 958 | * @param cfg configuration we use (also to connect to PSYC service) |
954 | * @param peer handle to access more of the peer (not used) | 959 | * @param peer handle to access more of the peer (not used) |
955 | */ | 960 | */ |
956 | void | 961 | static void |
957 | #if DEBUG_TEST_PSYC | 962 | #if DEBUG_TEST_PSYC |
958 | run (void *cls, char *const *args, const char *cfgfile, | 963 | run (void *cls, char *const *args, const char *cfgfile, |
959 | const struct GNUNET_CONFIGURATION_Handle *c) | 964 | const struct GNUNET_CONFIGURATION_Handle *c) |
diff --git a/src/psycstore/gnunet-service-psycstore.c b/src/psycstore/gnunet-service-psycstore.c index 737cff422..e02f77714 100644 --- a/src/psycstore/gnunet-service-psycstore.c +++ b/src/psycstore/gnunet-service-psycstore.c | |||
@@ -946,11 +946,15 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
946 | GNUNET_CONFIGURATION_get_value_string (cfg, "psycstore", "database", | 946 | GNUNET_CONFIGURATION_get_value_string (cfg, "psycstore", "database", |
947 | &database)) | 947 | &database)) |
948 | { | 948 | { |
949 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No database backend configured\n"); | 949 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, |
950 | "psycstore", | ||
951 | "database"); | ||
950 | } | 952 | } |
951 | else | 953 | else |
952 | { | 954 | { |
953 | GNUNET_asprintf (&db_lib_name, "libgnunet_plugin_psycstore_%s", database); | 955 | GNUNET_asprintf (&db_lib_name, |
956 | "libgnunet_plugin_psycstore_%s", | ||
957 | database); | ||
954 | db = GNUNET_PLUGIN_load (db_lib_name, (void *) cfg); | 958 | db = GNUNET_PLUGIN_load (db_lib_name, (void *) cfg); |
955 | GNUNET_free (database); | 959 | GNUNET_free (database); |
956 | } | 960 | } |
@@ -966,8 +970,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
966 | stats = GNUNET_STATISTICS_create ("psycstore", cfg); | 970 | stats = GNUNET_STATISTICS_create ("psycstore", cfg); |
967 | GNUNET_SERVER_add_handlers (server, handlers); | 971 | GNUNET_SERVER_add_handlers (server, handlers); |
968 | nc = GNUNET_SERVER_notification_context_create (server, 1); | 972 | nc = GNUNET_SERVER_notification_context_create (server, 1); |
969 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 973 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
970 | NULL); | 974 | NULL); |
971 | } | 975 | } |
972 | 976 | ||
973 | 977 | ||
diff --git a/src/psycstore/psycstore_api.c b/src/psycstore/psycstore_api.c index b8f00a41c..234218fba 100644 --- a/src/psycstore/psycstore_api.c +++ b/src/psycstore/psycstore_api.c | |||
@@ -131,7 +131,7 @@ struct GNUNET_PSYCSTORE_Handle | |||
131 | /** | 131 | /** |
132 | * Task doing exponential back-off trying to reconnect. | 132 | * Task doing exponential back-off trying to reconnect. |
133 | */ | 133 | */ |
134 | struct GNUNET_SCHEDULER_Task * reconnect_task; | 134 | struct GNUNET_SCHEDULER_Task *reconnect_task; |
135 | 135 | ||
136 | /** | 136 | /** |
137 | * Time for next connect retry. | 137 | * Time for next connect retry. |
diff --git a/src/psycstore/test_psycstore.c b/src/psycstore/test_psycstore.c index 266ee5c1d..2582cbf3f 100644 --- a/src/psycstore/test_psycstore.c +++ b/src/psycstore/test_psycstore.c | |||
@@ -54,7 +54,7 @@ static struct GNUNET_PSYCSTORE_OperationHandle *op; | |||
54 | /** | 54 | /** |
55 | * Handle for task for timeout termination. | 55 | * Handle for task for timeout termination. |
56 | */ | 56 | */ |
57 | static struct GNUNET_SCHEDULER_Task * end_badly_task; | 57 | static struct GNUNET_SCHEDULER_Task *end_badly_task; |
58 | 58 | ||
59 | static struct GNUNET_CRYPTO_EddsaPrivateKey *channel_key; | 59 | static struct GNUNET_CRYPTO_EddsaPrivateKey *channel_key; |
60 | static struct GNUNET_CRYPTO_EcdsaPrivateKey *slave_key; | 60 | static struct GNUNET_CRYPTO_EcdsaPrivateKey *slave_key; |
@@ -141,7 +141,7 @@ end_normally (void *cls) | |||
141 | static void | 141 | static void |
142 | end () | 142 | end () |
143 | { | 143 | { |
144 | if (end_badly_task != NULL) | 144 | if (NULL != end_badly_task) |
145 | { | 145 | { |
146 | GNUNET_SCHEDULER_cancel (end_badly_task); | 146 | GNUNET_SCHEDULER_cancel (end_badly_task); |
147 | end_badly_task = NULL; | 147 | end_badly_task = NULL; |
diff --git a/src/pt/gnunet-daemon-pt.c b/src/pt/gnunet-daemon-pt.c index a86cbd316..02c0df3cc 100644 --- a/src/pt/gnunet-daemon-pt.c +++ b/src/pt/gnunet-daemon-pt.c | |||
@@ -228,7 +228,7 @@ struct RequestContext | |||
228 | /** | 228 | /** |
229 | * Task used to abort this operation with timeout. | 229 | * Task used to abort this operation with timeout. |
230 | */ | 230 | */ |
231 | struct GNUNET_SCHEDULER_Task * timeout_task; | 231 | struct GNUNET_SCHEDULER_Task *timeout_task; |
232 | 232 | ||
233 | /** | 233 | /** |
234 | * Length of the request message that follows this struct. | 234 | * Length of the request message that follows this struct. |
@@ -1244,7 +1244,7 @@ run (void *cls, char *const *args GNUNET_UNUSED, | |||
1244 | GNUNET_SCHEDULER_shutdown (); | 1244 | GNUNET_SCHEDULER_shutdown (); |
1245 | return; | 1245 | return; |
1246 | } | 1246 | } |
1247 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, cls); | 1247 | GNUNET_SCHEDULER_add_shutdown (&cleanup, cls); |
1248 | if (ipv4_pt || ipv6_pt) | 1248 | if (ipv4_pt || ipv6_pt) |
1249 | { | 1249 | { |
1250 | dns_post_handle | 1250 | dns_post_handle |
diff --git a/src/pt/test_gnunet_vpn.c b/src/pt/test_gnunet_vpn.c index 85b28fbf8..df87da30a 100644 --- a/src/pt/test_gnunet_vpn.c +++ b/src/pt/test_gnunet_vpn.c | |||
@@ -354,7 +354,8 @@ mhd_main () | |||
354 | 354 | ||
355 | 355 | ||
356 | static void | 356 | static void |
357 | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, | 357 | run (void *cls, |
358 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
358 | struct GNUNET_TESTING_Peer *peer) | 359 | struct GNUNET_TESTING_Peer *peer) |
359 | { | 360 | { |
360 | struct in_addr v4; | 361 | struct in_addr v4; |
diff --git a/src/regex/gnunet-daemon-regexprofiler.c b/src/regex/gnunet-daemon-regexprofiler.c index 1ff3b55e3..42fc8ace0 100644 --- a/src/regex/gnunet-daemon-regexprofiler.c +++ b/src/regex/gnunet-daemon-regexprofiler.c | |||
@@ -117,7 +117,11 @@ shutdown_task (void *cls) | |||
117 | REGEX_INTERNAL_announce_cancel (announce_handle); | 117 | REGEX_INTERNAL_announce_cancel (announce_handle); |
118 | announce_handle = NULL; | 118 | announce_handle = NULL; |
119 | } | 119 | } |
120 | 120 | if (NULL != reannounce_task) | |
121 | { | ||
122 | GNUNET_free (GNUNET_SCHEDULER_cancel (reannounce_task)); | ||
123 | reannounce_task = NULL; | ||
124 | } | ||
121 | if (NULL != dht_handle) | 125 | if (NULL != dht_handle) |
122 | { | 126 | { |
123 | GNUNET_DHT_disconnect (dht_handle); | 127 | GNUNET_DHT_disconnect (dht_handle); |
@@ -142,16 +146,8 @@ reannounce_regex (void *cls) | |||
142 | { | 146 | { |
143 | char *regex = cls; | 147 | char *regex = cls; |
144 | struct GNUNET_TIME_Relative random_delay; | 148 | struct GNUNET_TIME_Relative random_delay; |
145 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
146 | 149 | ||
147 | reannounce_task = NULL; | 150 | reannounce_task = NULL; |
148 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
149 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
150 | { | ||
151 | GNUNET_free (regex); | ||
152 | return; | ||
153 | } | ||
154 | |||
155 | if (0 == rounds--) | 151 | if (0 == rounds--) |
156 | { | 152 | { |
157 | global_ret = 0; | 153 | global_ret = 0; |
@@ -195,7 +191,7 @@ reannounce_regex (void *cls) | |||
195 | * @param regex regular expression to announce on this peer's cadet. | 191 | * @param regex regular expression to announce on this peer's cadet. |
196 | */ | 192 | */ |
197 | static void | 193 | static void |
198 | announce_regex (const char * regex) | 194 | announce_regex (const char *regex) |
199 | { | 195 | { |
200 | char *copy; | 196 | char *copy; |
201 | 197 | ||
@@ -210,7 +206,8 @@ announce_regex (const char * regex) | |||
210 | policy_filename); | 206 | policy_filename); |
211 | GNUNET_assert (NULL == reannounce_task); | 207 | GNUNET_assert (NULL == reannounce_task); |
212 | copy = GNUNET_strdup (regex); | 208 | copy = GNUNET_strdup (regex); |
213 | reannounce_task = GNUNET_SCHEDULER_add_now (reannounce_regex, (void *) copy); | 209 | reannounce_task = GNUNET_SCHEDULER_add_now (&reannounce_regex, |
210 | (void *) copy); | ||
214 | } | 211 | } |
215 | 212 | ||
216 | 213 | ||
@@ -347,14 +344,17 @@ run (void *cls, char *const *args GNUNET_UNUSED, | |||
347 | REGEX_TEST_free_from_file (components); | 344 | REGEX_TEST_free_from_file (components); |
348 | 345 | ||
349 | /* Announcing regexes from policy_filename */ | 346 | /* Announcing regexes from policy_filename */ |
350 | GNUNET_asprintf (&rx_with_pfx, "%s(%s)(0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f)*", regex_prefix, regex); | 347 | GNUNET_asprintf (&rx_with_pfx, |
348 | "%s(%s)(0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f)*", | ||
349 | regex_prefix, | ||
350 | regex); | ||
351 | announce_regex (rx_with_pfx); | 351 | announce_regex (rx_with_pfx); |
352 | GNUNET_free (regex); | 352 | GNUNET_free (regex); |
353 | GNUNET_free (rx_with_pfx); | 353 | GNUNET_free (rx_with_pfx); |
354 | 354 | ||
355 | /* Scheduled the task to clean up when shutdown is called */ | 355 | /* Scheduled the task to clean up when shutdown is called */ |
356 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 356 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
357 | NULL); | 357 | NULL); |
358 | } | 358 | } |
359 | 359 | ||
360 | 360 | ||
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c index 5938c99b1..db5432845 100644 --- a/src/regex/gnunet-regex-profiler.c +++ b/src/regex/gnunet-regex-profiler.c | |||
@@ -214,11 +214,6 @@ static struct GNUNET_CONFIGURATION_Handle *cfg; | |||
214 | static struct GNUNET_SCHEDULER_Task * abort_task; | 214 | static struct GNUNET_SCHEDULER_Task * abort_task; |
215 | 215 | ||
216 | /** | 216 | /** |
217 | * Shutdown task identifier | ||
218 | */ | ||
219 | static struct GNUNET_SCHEDULER_Task * shutdown_task; | ||
220 | |||
221 | /** | ||
222 | * Host registration task identifier | 217 | * Host registration task identifier |
223 | */ | 218 | */ |
224 | static struct GNUNET_SCHEDULER_Task * register_hosts_task; | 219 | static struct GNUNET_SCHEDULER_Task * register_hosts_task; |
@@ -408,12 +403,16 @@ do_shutdown (void *cls) | |||
408 | char output_buffer[512]; | 403 | char output_buffer[512]; |
409 | size_t size; | 404 | size_t size; |
410 | 405 | ||
411 | shutdown_task = NULL; | ||
412 | if (NULL != abort_task) | 406 | if (NULL != abort_task) |
407 | { | ||
413 | GNUNET_SCHEDULER_cancel (abort_task); | 408 | GNUNET_SCHEDULER_cancel (abort_task); |
409 | abort_task = NULL; | ||
410 | } | ||
414 | if (NULL != register_hosts_task) | 411 | if (NULL != register_hosts_task) |
412 | { | ||
415 | GNUNET_SCHEDULER_cancel (register_hosts_task); | 413 | GNUNET_SCHEDULER_cancel (register_hosts_task); |
416 | 414 | register_hosts_task = NULL; | |
415 | } | ||
417 | for (peer_cnt = 0; peer_cnt < num_peers; peer_cnt++) | 416 | for (peer_cnt = 0; peer_cnt < num_peers; peer_cnt++) |
418 | { | 417 | { |
419 | peer = &peers[peer_cnt]; | 418 | peer = &peers[peer_cnt]; |
@@ -441,8 +440,10 @@ do_shutdown (void *cls) | |||
441 | } | 440 | } |
442 | 441 | ||
443 | if (NULL != data_file) | 442 | if (NULL != data_file) |
443 | { | ||
444 | GNUNET_DISK_file_close (data_file); | 444 | GNUNET_DISK_file_close (data_file); |
445 | 445 | data_file = NULL; | |
446 | } | ||
446 | for (search_str_cnt = 0; | 447 | for (search_str_cnt = 0; |
447 | search_str_cnt < num_peers && NULL != search_strings; | 448 | search_str_cnt < num_peers && NULL != search_strings; |
448 | search_str_cnt++) | 449 | search_str_cnt++) |
@@ -450,18 +451,28 @@ do_shutdown (void *cls) | |||
450 | GNUNET_free_non_null (search_strings[search_str_cnt]); | 451 | GNUNET_free_non_null (search_strings[search_str_cnt]); |
451 | } | 452 | } |
452 | GNUNET_free_non_null (search_strings); | 453 | GNUNET_free_non_null (search_strings); |
454 | search_strings = NULL; | ||
453 | 455 | ||
454 | if (NULL != reg_handle) | 456 | if (NULL != reg_handle) |
457 | { | ||
455 | GNUNET_TESTBED_cancel_registration (reg_handle); | 458 | GNUNET_TESTBED_cancel_registration (reg_handle); |
456 | 459 | reg_handle = NULL; | |
460 | } | ||
457 | if (NULL != mc) | 461 | if (NULL != mc) |
462 | { | ||
458 | GNUNET_TESTBED_controller_disconnect (mc); | 463 | GNUNET_TESTBED_controller_disconnect (mc); |
464 | mc = NULL; | ||
465 | } | ||
459 | if (NULL != mc_proc) | 466 | if (NULL != mc_proc) |
467 | { | ||
460 | GNUNET_TESTBED_controller_stop (mc_proc); | 468 | GNUNET_TESTBED_controller_stop (mc_proc); |
469 | mc_proc = NULL; | ||
470 | } | ||
461 | if (NULL != cfg) | 471 | if (NULL != cfg) |
472 | { | ||
462 | GNUNET_CONFIGURATION_destroy (cfg); | 473 | GNUNET_CONFIGURATION_destroy (cfg); |
463 | 474 | cfg = NULL; | |
464 | GNUNET_SCHEDULER_shutdown (); /* Stop scheduler to shutdown testbed run */ | 475 | } |
465 | } | 476 | } |
466 | 477 | ||
467 | 478 | ||
@@ -475,12 +486,11 @@ do_abort (void *cls) | |||
475 | { | 486 | { |
476 | unsigned long i = (unsigned long) cls; | 487 | unsigned long i = (unsigned long) cls; |
477 | 488 | ||
478 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Aborting from line %lu...\n", i); | 489 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
490 | "Aborting from line %lu...\n", i); | ||
479 | abort_task = NULL; | 491 | abort_task = NULL; |
480 | result = GNUNET_SYSERR; | 492 | result = GNUNET_SYSERR; |
481 | if (NULL != shutdown_task) | 493 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
482 | GNUNET_SCHEDULER_cancel (shutdown_task); | ||
483 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
484 | } | 494 | } |
485 | 495 | ||
486 | 496 | ||
@@ -499,7 +509,8 @@ do_abort (void *cls) | |||
499 | * @return service handle to return in 'op_result', NULL on error | 509 | * @return service handle to return in 'op_result', NULL on error |
500 | */ | 510 | */ |
501 | static void * | 511 | static void * |
502 | stats_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) | 512 | stats_ca (void *cls, |
513 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
503 | { | 514 | { |
504 | return GNUNET_STATISTICS_create ("<driver>", cfg); | 515 | return GNUNET_STATISTICS_create ("<driver>", cfg); |
505 | } | 516 | } |
@@ -532,10 +543,12 @@ stats_da (void *cls, void *op_result) | |||
532 | * @param name the name of the datum | 543 | * @param name the name of the datum |
533 | * @param value the current value | 544 | * @param value the current value |
534 | * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not | 545 | * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not |
535 | * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration | 546 | * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration |
536 | */ | 547 | */ |
537 | static int | 548 | static int |
538 | stats_iterator (void *cls, const char *subsystem, const char *name, | 549 | stats_iterator (void *cls, |
550 | const char *subsystem, | ||
551 | const char *name, | ||
539 | uint64_t value, int is_persistent) | 552 | uint64_t value, int is_persistent) |
540 | { | 553 | { |
541 | struct RegexPeer *peer = cls; | 554 | struct RegexPeer *peer = cls; |
@@ -596,9 +609,9 @@ stats_cb (void *cls, | |||
596 | fprintf (stderr, "s"); | 609 | fprintf (stderr, "s"); |
597 | if (peer_cnt == num_peers) | 610 | if (peer_cnt == num_peers) |
598 | { | 611 | { |
599 | struct GNUNET_TIME_Relative delay = { 100 }; | 612 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
600 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "\nCollecting stats finished. Shutting down.\n"); | 613 | "\nCollecting stats finished. Shutting down.\n"); |
601 | shutdown_task = GNUNET_SCHEDULER_add_delayed (delay, &do_shutdown, NULL); | 614 | GNUNET_SCHEDULER_shutdown (); |
602 | result = GNUNET_OK; | 615 | result = GNUNET_OK; |
603 | } | 616 | } |
604 | else | 617 | else |
@@ -845,12 +858,8 @@ static void | |||
845 | find_timed_out (void *cls) | 858 | find_timed_out (void *cls) |
846 | { | 859 | { |
847 | struct RegexPeer *p = cls; | 860 | struct RegexPeer *p = cls; |
848 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
849 | 861 | ||
850 | p->timeout = NULL; | 862 | p->timeout = NULL; |
851 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
852 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
853 | return; | ||
854 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 863 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
855 | "Searching for string \"%s\" on peer %d timed out.\n", | 864 | "Searching for string \"%s\" on peer %d timed out.\n", |
856 | p->search_str, | 865 | p->search_str, |
@@ -869,12 +878,9 @@ static void | |||
869 | find_string (void *cls) | 878 | find_string (void *cls) |
870 | { | 879 | { |
871 | unsigned int search_peer = (unsigned int) (long) cls; | 880 | unsigned int search_peer = (unsigned int) (long) cls; |
872 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
873 | 881 | ||
874 | tc = GNUNET_SCHEDULER_get_task_context (); | 882 | if ( (search_peer >= num_peers) || |
875 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) || | 883 | (GNUNET_YES == in_shutdown) ) |
876 | search_peer >= num_peers || | ||
877 | GNUNET_YES == in_shutdown) | ||
878 | return; | 884 | return; |
879 | 885 | ||
880 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 886 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
@@ -893,14 +899,13 @@ find_string (void *cls) | |||
893 | &dht_da, | 899 | &dht_da, |
894 | &peers[search_peer]); | 900 | &peers[search_peer]); |
895 | GNUNET_assert (NULL != peers[search_peer].op_handle); | 901 | GNUNET_assert (NULL != peers[search_peer].op_handle); |
896 | peers[search_peer].timeout = GNUNET_SCHEDULER_add_delayed (FIND_TIMEOUT, | 902 | peers[search_peer].timeout |
897 | &find_timed_out, | 903 | = GNUNET_SCHEDULER_add_delayed (FIND_TIMEOUT, |
898 | &peers[search_peer]); | 904 | &find_timed_out, |
905 | &peers[search_peer]); | ||
899 | } | 906 | } |
900 | 907 | ||
901 | 908 | ||
902 | |||
903 | |||
904 | /** | 909 | /** |
905 | * Callback called when testbed has started the daemon we asked for. | 910 | * Callback called when testbed has started the daemon we asked for. |
906 | * | 911 | * |
@@ -909,7 +914,8 @@ find_string (void *cls) | |||
909 | * @param emsg NULL on success; otherwise an error description | 914 | * @param emsg NULL on success; otherwise an error description |
910 | */ | 915 | */ |
911 | static void | 916 | static void |
912 | daemon_started (void *cls, struct GNUNET_TESTBED_Operation *op, | 917 | daemon_started (void *cls, |
918 | struct GNUNET_TESTBED_Operation *op, | ||
913 | const char *emsg) | 919 | const char *emsg) |
914 | { | 920 | { |
915 | struct RegexPeer *peer = (struct RegexPeer *) cls; | 921 | struct RegexPeer *peer = (struct RegexPeer *) cls; |
@@ -961,8 +967,10 @@ do_announce (void *cls) | |||
961 | { | 967 | { |
962 | unsigned int i; | 968 | unsigned int i; |
963 | 969 | ||
964 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Starting announce.\n"); | 970 | if (GNUNET_YES == in_shutdown) |
965 | 971 | return; | |
972 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
973 | "Starting announce.\n"); | ||
966 | for (i = 0; i < init_parallel_searches; i++) | 974 | for (i = 0; i < init_parallel_searches; i++) |
967 | { | 975 | { |
968 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 976 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
@@ -982,10 +990,8 @@ static void | |||
982 | announce_next_regex (void *cls) | 990 | announce_next_regex (void *cls) |
983 | { | 991 | { |
984 | struct RegexPeer *peer; | 992 | struct RegexPeer *peer; |
985 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
986 | 993 | ||
987 | tc = GNUNET_SCHEDULER_get_task_context (); | 994 | if (GNUNET_YES == in_shutdown) |
988 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
989 | return; | 995 | return; |
990 | if (next_search >= num_peers) | 996 | if (next_search >= num_peers) |
991 | { | 997 | { |
@@ -1015,6 +1021,7 @@ announce_next_regex (void *cls) | |||
1015 | parallel_searches++; | 1021 | parallel_searches++; |
1016 | } | 1022 | } |
1017 | 1023 | ||
1024 | |||
1018 | /** | 1025 | /** |
1019 | * DHT connect callback. Called when we are connected to the dht service for | 1026 | * DHT connect callback. Called when we are connected to the dht service for |
1020 | * the peer in 'cls'. If successfull we connect to the stats service of this | 1027 | * the peer in 'cls'. If successfull we connect to the stats service of this |
@@ -1026,8 +1033,10 @@ announce_next_regex (void *cls) | |||
1026 | * @param emsg error message. | 1033 | * @param emsg error message. |
1027 | */ | 1034 | */ |
1028 | static void | 1035 | static void |
1029 | dht_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op, | 1036 | dht_connect_cb (void *cls, |
1030 | void *ca_result, const char *emsg) | 1037 | struct GNUNET_TESTBED_Operation *op, |
1038 | void *ca_result, | ||
1039 | const char *emsg) | ||
1031 | { | 1040 | { |
1032 | struct RegexPeer *peer = (struct RegexPeer *) cls; | 1041 | struct RegexPeer *peer = (struct RegexPeer *) cls; |
1033 | 1042 | ||
@@ -1194,10 +1203,12 @@ master_controller_cb (void *cls, | |||
1194 | * @param strings set of strings loaded from file. Caller needs to free this | 1203 | * @param strings set of strings loaded from file. Caller needs to free this |
1195 | * if number returned is greater than zero. | 1204 | * if number returned is greater than zero. |
1196 | * @param limit upper limit on the number of strings read from the file | 1205 | * @param limit upper limit on the number of strings read from the file |
1197 | * @return number of strings found in the file. GNUNET_SYSERR on error. | 1206 | * @return number of strings found in the file. #GNUNET_SYSERR on error. |
1198 | */ | 1207 | */ |
1199 | static int | 1208 | static int |
1200 | load_search_strings (const char *filename, char ***strings, unsigned int limit) | 1209 | load_search_strings (const char *filename, |
1210 | char ***strings, | ||
1211 | unsigned int limit) | ||
1201 | { | 1212 | { |
1202 | char *data; | 1213 | char *data; |
1203 | char *buf; | 1214 | char *buf; |
@@ -1268,7 +1279,9 @@ load_search_strings (const char *filename, char ***strings, unsigned int limit) | |||
1268 | * @param config configuration | 1279 | * @param config configuration |
1269 | */ | 1280 | */ |
1270 | static void | 1281 | static void |
1271 | run (void *cls, char *const *args, const char *cfgfile, | 1282 | run (void *cls, |
1283 | char *const *args, | ||
1284 | const char *cfgfile, | ||
1272 | const struct GNUNET_CONFIGURATION_Handle *config) | 1285 | const struct GNUNET_CONFIGURATION_Handle *config) |
1273 | { | 1286 | { |
1274 | unsigned int nsearchstrs; | 1287 | unsigned int nsearchstrs; |
@@ -1282,7 +1295,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1282 | { | 1295 | { |
1283 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1296 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1284 | _("No configuration file given. Exiting\n")); | 1297 | _("No configuration file given. Exiting\n")); |
1285 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 1298 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
1286 | return; | 1299 | return; |
1287 | } | 1300 | } |
1288 | cfg = GNUNET_CONFIGURATION_dup (config); | 1301 | cfg = GNUNET_CONFIGURATION_dup (config); |
@@ -1291,9 +1304,10 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1291 | "REGEX_PREFIX", | 1304 | "REGEX_PREFIX", |
1292 | ®ex_prefix)) | 1305 | ®ex_prefix)) |
1293 | { | 1306 | { |
1294 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1307 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, |
1295 | _("Configuration option \"regex_prefix\" missing. Exiting\n")); | 1308 | "regexprofiler", |
1296 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 1309 | "regex_prefix"); |
1310 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
1297 | return; | 1311 | return; |
1298 | } | 1312 | } |
1299 | if (GNUNET_OK != | 1313 | if (GNUNET_OK != |
@@ -1328,7 +1342,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1328 | { | 1342 | { |
1329 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1343 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1330 | _("Specified policies directory does not exist. Exiting.\n")); | 1344 | _("Specified policies directory does not exist. Exiting.\n")); |
1331 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 1345 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
1332 | return; | 1346 | return; |
1333 | } | 1347 | } |
1334 | if (0 >= (int) (num_peers = GNUNET_DISK_directory_scan (policy_dir, NULL, NULL))) | 1348 | if (0 >= (int) (num_peers = GNUNET_DISK_directory_scan (policy_dir, NULL, NULL))) |
@@ -1344,7 +1358,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1344 | { | 1358 | { |
1345 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1359 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1346 | _("No search strings file given. Exiting.\n")); | 1360 | _("No search strings file given. Exiting.\n")); |
1347 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 1361 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
1348 | return; | 1362 | return; |
1349 | } | 1363 | } |
1350 | nsearchstrs = load_search_strings (strings_file, | 1364 | nsearchstrs = load_search_strings (strings_file, |
@@ -1357,14 +1371,14 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1357 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1371 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1358 | "File (%s) does not contain enough strings (%u/%u).\n", | 1372 | "File (%s) does not contain enough strings (%u/%u).\n", |
1359 | strings_file, nsearchstrs, num_peers); | 1373 | strings_file, nsearchstrs, num_peers); |
1360 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 1374 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
1361 | return; | 1375 | return; |
1362 | } | 1376 | } |
1363 | if ( (0 == num_peers) || (NULL == search_strings)) | 1377 | if ( (0 == num_peers) || (NULL == search_strings)) |
1364 | { | 1378 | { |
1365 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1379 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1366 | _("Error loading search strings. Exiting.\n")); | 1380 | _("Error loading search strings. Exiting.\n")); |
1367 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 1381 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
1368 | return; | 1382 | return; |
1369 | } | 1383 | } |
1370 | for (i = 0; i < num_peers; i++) | 1384 | for (i = 0; i < num_peers; i++) |
diff --git a/src/regex/gnunet-regex-simulation-profiler.c b/src/regex/gnunet-regex-simulation-profiler.c index 27dfa773d..0f955f7b5 100644 --- a/src/regex/gnunet-regex-simulation-profiler.c +++ b/src/regex/gnunet-regex-simulation-profiler.c | |||
@@ -89,19 +89,9 @@ struct ProgressMeter | |||
89 | static struct ProgressMeter *meter; | 89 | static struct ProgressMeter *meter; |
90 | 90 | ||
91 | /** | 91 | /** |
92 | * Abort task identifier. | ||
93 | */ | ||
94 | static struct GNUNET_SCHEDULER_Task * abort_task; | ||
95 | |||
96 | /** | ||
97 | * Shutdown task identifier. | ||
98 | */ | ||
99 | static struct GNUNET_SCHEDULER_Task * shutdown_task; | ||
100 | |||
101 | /** | ||
102 | * Scan task identifier; | 92 | * Scan task identifier; |
103 | */ | 93 | */ |
104 | static struct GNUNET_SCHEDULER_Task * scan_task; | 94 | static struct GNUNET_SCHEDULER_Task *scan_task; |
105 | 95 | ||
106 | /** | 96 | /** |
107 | * Global testing status. | 97 | * Global testing status. |
@@ -240,8 +230,8 @@ update_meter (struct ProgressMeter *meter) | |||
240 | * | 230 | * |
241 | * @param meter the meter to reset | 231 | * @param meter the meter to reset |
242 | * | 232 | * |
243 | * @return GNUNET_YES if meter reset, | 233 | * @return #GNUNET_YES if meter reset, |
244 | * GNUNET_SYSERR on error | 234 | * #GNUNET_SYSERR on error |
245 | */ | 235 | */ |
246 | static int | 236 | static int |
247 | reset_meter (struct ProgressMeter *meter) | 237 | reset_meter (struct ProgressMeter *meter) |
@@ -274,21 +264,28 @@ free_meter (struct ProgressMeter *meter) | |||
274 | */ | 264 | */ |
275 | static void | 265 | static void |
276 | do_shutdown (void *cls) | 266 | do_shutdown (void *cls) |
277 | { | 267 | { |
278 | shutdown_task = NULL; | ||
279 | if (NULL != abort_task) | ||
280 | GNUNET_SCHEDULER_cancel (abort_task); | ||
281 | if (NULL != mysql_ctx) | 268 | if (NULL != mysql_ctx) |
269 | { | ||
282 | GNUNET_MYSQL_context_destroy (mysql_ctx); | 270 | GNUNET_MYSQL_context_destroy (mysql_ctx); |
271 | mysql_ctx = NULL; | ||
272 | } | ||
283 | if (NULL != meter) | 273 | if (NULL != meter) |
274 | { | ||
284 | free_meter (meter); | 275 | free_meter (meter); |
285 | 276 | meter = NULL; | |
286 | GNUNET_SCHEDULER_shutdown (); /* Stop scheduler to shutdown testbed run */ | 277 | } |
287 | } | 278 | } |
288 | 279 | ||
289 | 280 | ||
290 | /** | 281 | /** |
291 | * abort task to run on test timed out | 282 | * Abort task to run on test timed out. |
283 | * | ||
284 | * FIXME: this doesn't actually work, it used to cancel | ||
285 | * the already running 'scan_task', but now that should | ||
286 | * always be NULL and do nothing. We instead need to set | ||
287 | * a global variable and abort scan_task internally, not | ||
288 | * via scheduler. | ||
292 | * | 289 | * |
293 | * @param cls NULL | 290 | * @param cls NULL |
294 | */ | 291 | */ |
@@ -296,25 +293,29 @@ static void | |||
296 | do_abort (void *cls) | 293 | do_abort (void *cls) |
297 | { | 294 | { |
298 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Aborting\n"); | 295 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Aborting\n"); |
299 | abort_task = NULL; | 296 | if (NULL != scan_task) |
300 | GNUNET_SCHEDULER_cancel (scan_task); | 297 | { |
301 | scan_task = NULL; | 298 | GNUNET_SCHEDULER_cancel (scan_task); |
299 | scan_task = NULL; | ||
300 | } | ||
302 | result = GNUNET_SYSERR; | 301 | result = GNUNET_SYSERR; |
303 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 302 | GNUNET_SCHEDULER_shutdown (); |
304 | } | 303 | } |
305 | 304 | ||
306 | 305 | ||
307 | /** | 306 | /** |
308 | * Dummy function for prepared select. Always return GNUNET_OK. | 307 | * Dummy function for prepared select. Always returns #GNUNET_OK. |
309 | * | 308 | * |
310 | * @param cls closure | 309 | * @param cls closure |
311 | * @param num_values number of values. | 310 | * @param num_values number of values. |
312 | * @param values returned values from select stmt. | 311 | * @param values returned values from select stmt. |
313 | * | 312 | * |
314 | * @return GNUNET_OK | 313 | * @return #GNUNET_OK |
315 | */ | 314 | */ |
316 | static int | 315 | static int |
317 | return_ok (void *cls, unsigned int num_values, MYSQL_BIND * values) | 316 | return_ok (void *cls, |
317 | unsigned int num_values, | ||
318 | MYSQL_BIND * values) | ||
318 | { | 319 | { |
319 | return GNUNET_OK; | 320 | return GNUNET_OK; |
320 | } | 321 | } |
@@ -326,13 +327,16 @@ return_ok (void *cls, unsigned int num_values, MYSQL_BIND * values) | |||
326 | * @param cls closure. | 327 | * @param cls closure. |
327 | * @param key hash for current state. | 328 | * @param key hash for current state. |
328 | * @param proof proof for current state. | 329 | * @param proof proof for current state. |
329 | * @param accepting GNUNET_YES if this is an accepting state, GNUNET_NO if not. | 330 | * @param accepting #GNUNET_YES if this is an accepting state, #GNUNET_NO if not. |
330 | * @param num_edges number of edges leaving current state. | 331 | * @param num_edges number of edges leaving current state. |
331 | * @param edges edges leaving current state. | 332 | * @param edges edges leaving current state. |
332 | */ | 333 | */ |
333 | static void | 334 | static void |
334 | regex_iterator (void *cls, const struct GNUNET_HashCode *key, const char *proof, | 335 | regex_iterator (void *cls, |
335 | int accepting, unsigned int num_edges, | 336 | const struct GNUNET_HashCode *key, |
337 | const char *proof, | ||
338 | int accepting, | ||
339 | unsigned int num_edges, | ||
336 | const struct REGEX_BLOCK_Edge *edges) | 340 | const struct REGEX_BLOCK_Edge *edges) |
337 | { | 341 | { |
338 | unsigned int i; | 342 | unsigned int i; |
@@ -453,7 +457,7 @@ regex_iterator (void *cls, const struct GNUNET_HashCode *key, const char *proof, | |||
453 | * each state into a MySQL database. | 457 | * each state into a MySQL database. |
454 | * | 458 | * |
455 | * @param regex regular expression. | 459 | * @param regex regular expression. |
456 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure. | 460 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure. |
457 | */ | 461 | */ |
458 | static int | 462 | static int |
459 | announce_regex (const char *regex) | 463 | announce_regex (const char *regex) |
@@ -461,18 +465,20 @@ announce_regex (const char *regex) | |||
461 | struct REGEX_INTERNAL_Automaton *dfa; | 465 | struct REGEX_INTERNAL_Automaton *dfa; |
462 | 466 | ||
463 | dfa = | 467 | dfa = |
464 | REGEX_INTERNAL_construct_dfa (regex, strlen (regex), max_path_compression); | 468 | REGEX_INTERNAL_construct_dfa (regex, |
469 | strlen (regex), | ||
470 | max_path_compression); | ||
465 | 471 | ||
466 | if (NULL == dfa) | 472 | if (NULL == dfa) |
467 | { | 473 | { |
468 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create DFA for regex %s\n", | 474 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
475 | "Failed to create DFA for regex %s\n", | ||
469 | regex); | 476 | regex); |
470 | abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL); | 477 | GNUNET_SCHEDULER_add_now (&do_abort, NULL); |
471 | return GNUNET_SYSERR; | 478 | return GNUNET_SYSERR; |
472 | } | 479 | } |
473 | 480 | REGEX_INTERNAL_iterate_all_edges (dfa, | |
474 | REGEX_INTERNAL_iterate_all_edges (dfa, ®ex_iterator, NULL); | 481 | ®ex_iterator, NULL); |
475 | |||
476 | REGEX_INTERNAL_automaton_destroy (dfa); | 482 | REGEX_INTERNAL_automaton_destroy (dfa); |
477 | 483 | ||
478 | return GNUNET_OK; | 484 | return GNUNET_OK; |
@@ -484,8 +490,8 @@ announce_regex (const char *regex) | |||
484 | * | 490 | * |
485 | * @param cls closure | 491 | * @param cls closure |
486 | * @param filename complete filename (absolute path) | 492 | * @param filename complete filename (absolute path) |
487 | * @return GNUNET_OK to continue to iterate, | 493 | * @return #GNUNET_OK to continue to iterate, |
488 | * GNUNET_SYSERR to abort iteration with error! | 494 | * #GNUNET_SYSERR to abort iteration with error! |
489 | */ | 495 | */ |
490 | static int | 496 | static int |
491 | policy_filename_cb (void *cls, const char *filename) | 497 | policy_filename_cb (void *cls, const char *filename) |
@@ -498,17 +504,20 @@ policy_filename_cb (void *cls, const char *filename) | |||
498 | 504 | ||
499 | GNUNET_assert (NULL != filename); | 505 | GNUNET_assert (NULL != filename); |
500 | 506 | ||
501 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Announcing regexes from file %s\n", | 507 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
508 | "Announcing regexes from file %s\n", | ||
502 | filename); | 509 | filename); |
503 | 510 | ||
504 | if (GNUNET_YES != GNUNET_DISK_file_test (filename)) | 511 | if (GNUNET_YES != GNUNET_DISK_file_test (filename)) |
505 | { | 512 | { |
506 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Could not find policy file %s\n", | 513 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
514 | "Could not find policy file %s\n", | ||
507 | filename); | 515 | filename); |
508 | return GNUNET_OK; | 516 | return GNUNET_OK; |
509 | } | 517 | } |
510 | if (GNUNET_OK != | 518 | if (GNUNET_OK != |
511 | GNUNET_DISK_file_size (filename, &filesize, GNUNET_YES, GNUNET_YES)) | 519 | GNUNET_DISK_file_size (filename, &filesize, |
520 | GNUNET_YES, GNUNET_YES)) | ||
512 | filesize = 0; | 521 | filesize = 0; |
513 | if (0 == filesize) | 522 | if (0 == filesize) |
514 | { | 523 | { |
@@ -520,7 +529,8 @@ policy_filename_cb (void *cls, const char *filename) | |||
520 | if (filesize != GNUNET_DISK_fn_read (filename, data, filesize)) | 529 | if (filesize != GNUNET_DISK_fn_read (filename, data, filesize)) |
521 | { | 530 | { |
522 | GNUNET_free (data); | 531 | GNUNET_free (data); |
523 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Could not read policy file %s.\n", | 532 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
533 | "Could not read policy file %s.\n", | ||
524 | filename); | 534 | filename); |
525 | return GNUNET_OK; | 535 | return GNUNET_OK; |
526 | } | 536 | } |
@@ -545,11 +555,13 @@ policy_filename_cb (void *cls, const char *filename) | |||
545 | data[offset] = '\0'; | 555 | data[offset] = '\0'; |
546 | GNUNET_asprintf (®ex, "%s(%s)", regex_prefix, data); | 556 | GNUNET_asprintf (®ex, "%s(%s)", regex_prefix, data); |
547 | GNUNET_assert (NULL != regex); | 557 | GNUNET_assert (NULL != regex); |
548 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Announcing regex: %s\n", regex); | 558 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
559 | "Announcing regex: %s\n", regex); | ||
549 | 560 | ||
550 | if (GNUNET_OK != announce_regex (regex)) | 561 | if (GNUNET_OK != announce_regex (regex)) |
551 | { | 562 | { |
552 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not announce regex %s\n", | 563 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
564 | "Could not announce regex %s\n", | ||
553 | regex); | 565 | regex); |
554 | } | 566 | } |
555 | GNUNET_free (regex); | 567 | GNUNET_free (regex); |
@@ -571,6 +583,7 @@ do_directory_scan (void *cls) | |||
571 | char *stmt; | 583 | char *stmt; |
572 | 584 | ||
573 | /* Create an MySQL prepared statement for the inserts */ | 585 | /* Create an MySQL prepared statement for the inserts */ |
586 | scan_task = NULL; | ||
574 | GNUNET_asprintf (&stmt, INSERT_EDGE_STMT, table_name); | 587 | GNUNET_asprintf (&stmt, INSERT_EDGE_STMT, table_name); |
575 | stmt_handle = GNUNET_MYSQL_statement_prepare (mysql_ctx, stmt); | 588 | stmt_handle = GNUNET_MYSQL_statement_prepare (mysql_ctx, stmt); |
576 | GNUNET_free (stmt); | 589 | GNUNET_free (stmt); |
@@ -581,10 +594,13 @@ do_directory_scan (void *cls) | |||
581 | 594 | ||
582 | GNUNET_assert (NULL != stmt_handle); | 595 | GNUNET_assert (NULL != stmt_handle); |
583 | 596 | ||
584 | meter = | 597 | meter = create_meter (num_policy_files, |
585 | create_meter (num_policy_files, "Announcing policy files\n", GNUNET_YES); | 598 | "Announcing policy files\n", |
599 | GNUNET_YES); | ||
586 | start_time = GNUNET_TIME_absolute_get (); | 600 | start_time = GNUNET_TIME_absolute_get (); |
587 | GNUNET_DISK_directory_scan (policy_dir, &policy_filename_cb, stmt_handle); | 601 | GNUNET_DISK_directory_scan (policy_dir, |
602 | &policy_filename_cb, | ||
603 | stmt_handle); | ||
588 | duration = GNUNET_TIME_absolute_get_duration (start_time); | 604 | duration = GNUNET_TIME_absolute_get_duration (start_time); |
589 | reset_meter (meter); | 605 | reset_meter (meter); |
590 | free_meter (meter); | 606 | free_meter (meter); |
@@ -592,12 +608,13 @@ do_directory_scan (void *cls) | |||
592 | 608 | ||
593 | printf ("Announced %u files containing %u policies in %s\n" | 609 | printf ("Announced %u files containing %u policies in %s\n" |
594 | "Duplicate transitions: %llu\nMerged states: %llu\n", | 610 | "Duplicate transitions: %llu\nMerged states: %llu\n", |
595 | num_policy_files, num_policies, | 611 | num_policy_files, |
612 | num_policies, | ||
596 | GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_NO), | 613 | GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_NO), |
597 | num_merged_transitions, num_merged_states); | 614 | num_merged_transitions, |
598 | 615 | num_merged_states); | |
599 | result = GNUNET_OK; | 616 | result = GNUNET_OK; |
600 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 617 | GNUNET_SCHEDULER_shutdown (); |
601 | } | 618 | } |
602 | 619 | ||
603 | 620 | ||
@@ -610,7 +627,9 @@ do_directory_scan (void *cls) | |||
610 | * @param config configuration | 627 | * @param config configuration |
611 | */ | 628 | */ |
612 | static void | 629 | static void |
613 | run (void *cls, char *const *args, const char *cfgfile, | 630 | run (void *cls, |
631 | char *const *args, | ||
632 | const char *cfgfile, | ||
614 | const struct GNUNET_CONFIGURATION_Handle *config) | 633 | const struct GNUNET_CONFIGURATION_Handle *config) |
615 | { | 634 | { |
616 | if (NULL == args[0]) | 635 | if (NULL == args[0]) |
@@ -620,7 +639,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
620 | result = GNUNET_SYSERR; | 639 | result = GNUNET_SYSERR; |
621 | return; | 640 | return; |
622 | } | 641 | } |
623 | if (GNUNET_YES != GNUNET_DISK_directory_test (args[0], GNUNET_YES)) | 642 | if (GNUNET_YES != |
643 | GNUNET_DISK_directory_test (args[0], GNUNET_YES)) | ||
624 | { | 644 | { |
625 | fprintf (stderr, | 645 | fprintf (stderr, |
626 | _("Specified policies directory does not exist. Exiting.\n")); | 646 | _("Specified policies directory does not exist. Exiting.\n")); |
@@ -629,7 +649,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
629 | } | 649 | } |
630 | policy_dir = args[0]; | 650 | policy_dir = args[0]; |
631 | 651 | ||
632 | num_policy_files = GNUNET_DISK_directory_scan (policy_dir, NULL, NULL); | 652 | num_policy_files = GNUNET_DISK_directory_scan (policy_dir, |
653 | NULL, NULL); | ||
633 | meter = NULL; | 654 | meter = NULL; |
634 | 655 | ||
635 | if (NULL == table_name) | 656 | if (NULL == table_name) |
@@ -642,32 +663,29 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
642 | mysql_ctx = GNUNET_MYSQL_context_create (config, "regex-mysql"); | 663 | mysql_ctx = GNUNET_MYSQL_context_create (config, "regex-mysql"); |
643 | if (NULL == mysql_ctx) | 664 | if (NULL == mysql_ctx) |
644 | { | 665 | { |
645 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create mysql context\n"); | 666 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
667 | "Failed to create mysql context\n"); | ||
646 | result = GNUNET_SYSERR; | 668 | result = GNUNET_SYSERR; |
647 | return; | 669 | return; |
648 | } | 670 | } |
649 | 671 | ||
650 | if (GNUNET_OK != | 672 | if (GNUNET_OK != |
651 | GNUNET_CONFIGURATION_get_value_string (config, "regex-mysql", | 673 | GNUNET_CONFIGURATION_get_value_string (config, |
652 | "REGEX_PREFIX", ®ex_prefix)) | 674 | "regex-mysql", |
675 | "REGEX_PREFIX", | ||
676 | ®ex_prefix)) | ||
653 | { | 677 | { |
654 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 678 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, |
655 | _ | 679 | "regex-mysql", |
656 | ("%s service is lacking key configuration settings (%s). Exiting.\n"), | 680 | "REGEX_PREFIX"); |
657 | "regexprofiler", "regex_prefix"); | ||
658 | result = GNUNET_SYSERR; | 681 | result = GNUNET_SYSERR; |
659 | return; | 682 | return; |
660 | } | 683 | } |
661 | 684 | ||
662 | |||
663 | result = GNUNET_OK; | 685 | result = GNUNET_OK; |
664 | 686 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, | |
687 | NULL); | ||
665 | scan_task = GNUNET_SCHEDULER_add_now (&do_directory_scan, NULL); | 688 | scan_task = GNUNET_SCHEDULER_add_now (&do_directory_scan, NULL); |
666 | |||
667 | /* Scheduled the task to clean up when shutdown is called */ | ||
668 | shutdown_task = | ||
669 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &do_shutdown, | ||
670 | NULL); | ||
671 | } | 689 | } |
672 | 690 | ||
673 | 691 | ||
diff --git a/src/regex/gnunet-service-regex.c b/src/regex/gnunet-service-regex.c index a70876534..530e4f358 100644 --- a/src/regex/gnunet-service-regex.c +++ b/src/regex/gnunet-service-regex.c | |||
@@ -384,9 +384,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
384 | GNUNET_SCHEDULER_shutdown (); | 384 | GNUNET_SCHEDULER_shutdown (); |
385 | return; | 385 | return; |
386 | } | 386 | } |
387 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 387 | GNUNET_SCHEDULER_add_shutdown (&cleanup_task, |
388 | &cleanup_task, | 388 | NULL); |
389 | NULL); | ||
390 | nc = GNUNET_SERVER_notification_context_create (server, 1); | 389 | nc = GNUNET_SERVER_notification_context_create (server, 1); |
391 | stats = GNUNET_STATISTICS_create ("regex", cfg); | 390 | stats = GNUNET_STATISTICS_create ("regex", cfg); |
392 | GNUNET_SERVER_add_handlers (server, handlers); | 391 | GNUNET_SERVER_add_handlers (server, handlers); |
diff --git a/src/rest/gnunet-rest-server.c b/src/rest/gnunet-rest-server.c index 705fcbeb3..ffd65228a 100644 --- a/src/rest/gnunet-rest-server.c +++ b/src/rest/gnunet-rest-server.c | |||
@@ -61,7 +61,7 @@ | |||
61 | /** | 61 | /** |
62 | * The task ID | 62 | * The task ID |
63 | */ | 63 | */ |
64 | static struct GNUNET_SCHEDULER_Task * httpd_task; | 64 | static struct GNUNET_SCHEDULER_Task *httpd_task; |
65 | 65 | ||
66 | /** | 66 | /** |
67 | * The port the service is running on (default 7776) | 67 | * The port the service is running on (default 7776) |
@@ -396,6 +396,16 @@ kill_httpd () | |||
396 | GNUNET_SCHEDULER_cancel (httpd_task); | 396 | GNUNET_SCHEDULER_cancel (httpd_task); |
397 | httpd_task = NULL; | 397 | httpd_task = NULL; |
398 | } | 398 | } |
399 | if (NULL != ltask4) | ||
400 | { | ||
401 | GNUNET_SCHEDULER_cancel (ltask4); | ||
402 | ltask4 = NULL; | ||
403 | } | ||
404 | if (NULL != ltask6) | ||
405 | { | ||
406 | GNUNET_SCHEDULER_cancel (ltask6); | ||
407 | ltask6 = NULL; | ||
408 | } | ||
399 | } | 409 | } |
400 | 410 | ||
401 | 411 | ||
@@ -498,7 +508,6 @@ static void | |||
498 | do_accept (void *cls) | 508 | do_accept (void *cls) |
499 | { | 509 | { |
500 | struct GNUNET_NETWORK_Handle *lsock = cls; | 510 | struct GNUNET_NETWORK_Handle *lsock = cls; |
501 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
502 | struct GNUNET_NETWORK_Handle *s; | 511 | struct GNUNET_NETWORK_Handle *s; |
503 | int fd; | 512 | int fd; |
504 | const struct sockaddr *addr; | 513 | const struct sockaddr *addr; |
@@ -508,9 +517,6 @@ do_accept (void *cls) | |||
508 | ltask4 = NULL; | 517 | ltask4 = NULL; |
509 | else | 518 | else |
510 | ltask6 = NULL; | 519 | ltask6 = NULL; |
511 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
512 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
513 | return; | ||
514 | if (lsock == lsock4) | 520 | if (lsock == lsock4) |
515 | ltask4 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 521 | ltask4 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
516 | lsock, | 522 | lsock, |
@@ -770,8 +776,7 @@ run (void *cls, | |||
770 | (void *) cfg, | 776 | (void *) cfg, |
771 | &load_plugin, | 777 | &load_plugin, |
772 | NULL); | 778 | NULL); |
773 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 779 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
774 | &do_shutdown, NULL); | ||
775 | } | 780 | } |
776 | 781 | ||
777 | 782 | ||
diff --git a/src/revocation/gnunet-revocation.c b/src/revocation/gnunet-revocation.c index f68c18aa4..5e983a079 100644 --- a/src/revocation/gnunet-revocation.c +++ b/src/revocation/gnunet-revocation.c | |||
@@ -79,6 +79,11 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg; | |||
79 | */ | 79 | */ |
80 | static unsigned long long matching_bits; | 80 | static unsigned long long matching_bits; |
81 | 81 | ||
82 | /** | ||
83 | * Task used for proof-of-work calculation. | ||
84 | */ | ||
85 | static struct GNUNET_SCHEDULER_Task *pow_task; | ||
86 | |||
82 | 87 | ||
83 | /** | 88 | /** |
84 | * Function run if the user aborts with CTRL-C. | 89 | * Function run if the user aborts with CTRL-C. |
@@ -226,32 +231,60 @@ perform_revocation (const struct RevocationData *rd) | |||
226 | 231 | ||
227 | 232 | ||
228 | /** | 233 | /** |
234 | * Write the current state of the revocation data | ||
235 | * to disk. | ||
236 | * | ||
237 | * @param rd data to sync | ||
238 | */ | ||
239 | static void | ||
240 | sync_rd (const struct RevocationData *rd) | ||
241 | { | ||
242 | if ( (NULL != filename) && | ||
243 | (sizeof (struct RevocationData) == | ||
244 | GNUNET_DISK_fn_write (filename, | ||
245 | &rd, | ||
246 | sizeof (rd), | ||
247 | GNUNET_DISK_PERM_USER_READ | | ||
248 | GNUNET_DISK_PERM_USER_WRITE)) ) | ||
249 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | ||
250 | "write", | ||
251 | filename); | ||
252 | } | ||
253 | |||
254 | |||
255 | /** | ||
229 | * Perform the proof-of-work calculation. | 256 | * Perform the proof-of-work calculation. |
230 | * | 257 | * |
231 | * @param cls the `struct RevocationData` | 258 | * @param cls the `struct RevocationData` |
232 | */ | 259 | */ |
233 | static void | 260 | static void |
234 | calculate_pow (void *cls) | 261 | calculate_pow_shutdown (void *cls) |
235 | { | 262 | { |
236 | struct RevocationData *rd = cls; | 263 | struct RevocationData *rd = cls; |
237 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
238 | 264 | ||
239 | /* store temporary results */ | 265 | if (NULL != pow_task) |
240 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
241 | if ( (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) || | ||
242 | (0 == (rd->pow % 128) ) ) | ||
243 | { | 266 | { |
244 | if ( (NULL != filename) && | 267 | GNUNET_SCHEDULER_cancel (pow_task); |
245 | (sizeof (struct RevocationData) == | 268 | pow_task = NULL; |
246 | GNUNET_DISK_fn_write (filename, | ||
247 | &rd, | ||
248 | sizeof (rd), | ||
249 | GNUNET_DISK_PERM_USER_READ | | ||
250 | GNUNET_DISK_PERM_USER_WRITE)) ) | ||
251 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | ||
252 | "write", | ||
253 | filename); | ||
254 | } | 269 | } |
270 | sync_rd (rd); | ||
271 | GNUNET_free (rd); | ||
272 | } | ||
273 | |||
274 | |||
275 | /** | ||
276 | * Perform the proof-of-work calculation. | ||
277 | * | ||
278 | * @param cls the `struct RevocationData` | ||
279 | */ | ||
280 | static void | ||
281 | calculate_pow (void *cls) | ||
282 | { | ||
283 | struct RevocationData *rd = cls; | ||
284 | |||
285 | /* store temporary results */ | ||
286 | if (0 == (rd->pow % 128)) | ||
287 | sync_rd (rd); | ||
255 | /* display progress estimate */ | 288 | /* display progress estimate */ |
256 | if ( (0 == ((1 << matching_bits) / 100 / 50)) || | 289 | if ( (0 == ((1 << matching_bits) / 100 / 50)) || |
257 | (0 == (rd->pow % ((1 << matching_bits) / 100 / 50))) ) | 290 | (0 == (rd->pow % ((1 << matching_bits) / 100 / 50))) ) |
@@ -261,11 +294,6 @@ calculate_pow (void *cls) | |||
261 | (0 == (rd->pow % ((1 << matching_bits) / 100))) ) ) | 294 | (0 == (rd->pow % ((1 << matching_bits) / 100))) ) ) |
262 | FPRINTF (stderr, " - @ %3u%% (estimate)\n", | 295 | FPRINTF (stderr, " - @ %3u%% (estimate)\n", |
263 | (unsigned int) (rd->pow * 100) / (1 << matching_bits)); | 296 | (unsigned int) (rd->pow * 100) / (1 << matching_bits)); |
264 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | ||
265 | { | ||
266 | GNUNET_free (rd); | ||
267 | return; | ||
268 | } | ||
269 | /* actually do POW calculation */ | 297 | /* actually do POW calculation */ |
270 | rd->pow++; | 298 | rd->pow++; |
271 | if (GNUNET_OK == | 299 | if (GNUNET_OK == |
@@ -297,8 +325,8 @@ calculate_pow (void *cls) | |||
297 | GNUNET_free (rd); | 325 | GNUNET_free (rd); |
298 | return; | 326 | return; |
299 | } | 327 | } |
300 | GNUNET_SCHEDULER_add_now (&calculate_pow, | 328 | pow_task = GNUNET_SCHEDULER_add_now (&calculate_pow, |
301 | rd); | 329 | rd); |
302 | } | 330 | } |
303 | 331 | ||
304 | 332 | ||
@@ -371,8 +399,10 @@ ego_callback (void *cls, | |||
371 | FPRINTF (stderr, | 399 | FPRINTF (stderr, |
372 | "%s", | 400 | "%s", |
373 | _("Revocation certificate not ready, calculating proof of work\n")); | 401 | _("Revocation certificate not ready, calculating proof of work\n")); |
374 | GNUNET_SCHEDULER_add_now (&calculate_pow, | 402 | pow_task = GNUNET_SCHEDULER_add_now (&calculate_pow, |
375 | rd); | 403 | rd); |
404 | GNUNET_SCHEDULER_add_shutdown (&calculate_pow_shutdown, | ||
405 | rd); | ||
376 | } | 406 | } |
377 | 407 | ||
378 | 408 | ||
@@ -406,9 +436,8 @@ run (void *cls, | |||
406 | test_ego); | 436 | test_ego); |
407 | return; | 437 | return; |
408 | } | 438 | } |
409 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 439 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, |
410 | &do_shutdown, | 440 | NULL); |
411 | NULL); | ||
412 | q = GNUNET_REVOCATION_query (cfg, | 441 | q = GNUNET_REVOCATION_query (cfg, |
413 | &pk, | 442 | &pk, |
414 | &print_query_result, | 443 | &print_query_result, |
@@ -444,9 +473,8 @@ run (void *cls, | |||
444 | revoke_ego, | 473 | revoke_ego, |
445 | &ego_callback, | 474 | &ego_callback, |
446 | NULL); | 475 | NULL); |
447 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 476 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, |
448 | &do_shutdown, | 477 | NULL); |
449 | NULL); | ||
450 | return; | 478 | return; |
451 | } | 479 | } |
452 | if ( (NULL != filename) && | 480 | if ( (NULL != filename) && |
@@ -462,9 +490,8 @@ run (void *cls, | |||
462 | filename); | 490 | filename); |
463 | return; | 491 | return; |
464 | } | 492 | } |
465 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 493 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, |
466 | &do_shutdown, | 494 | NULL); |
467 | NULL); | ||
468 | if (GNUNET_YES != | 495 | if (GNUNET_YES != |
469 | GNUNET_REVOCATION_check_pow (&rd.key, | 496 | GNUNET_REVOCATION_check_pow (&rd.key, |
470 | rd.pow, | 497 | rd.pow, |
@@ -473,10 +500,11 @@ run (void *cls, | |||
473 | struct RevocationData *cp = GNUNET_new (struct RevocationData); | 500 | struct RevocationData *cp = GNUNET_new (struct RevocationData); |
474 | 501 | ||
475 | *cp = rd; | 502 | *cp = rd; |
476 | GNUNET_SCHEDULER_add_now (&calculate_pow, | 503 | pow_task = GNUNET_SCHEDULER_add_now (&calculate_pow, |
477 | cp); | 504 | cp); |
505 | GNUNET_SCHEDULER_add_shutdown (&calculate_pow_shutdown, | ||
506 | cp); | ||
478 | return; | 507 | return; |
479 | |||
480 | } | 508 | } |
481 | perform_revocation (&rd); | 509 | perform_revocation (&rd); |
482 | return; | 510 | return; |
diff --git a/src/revocation/gnunet-service-revocation.c b/src/revocation/gnunet-service-revocation.c index e41195d55..9f3162690 100644 --- a/src/revocation/gnunet-service-revocation.c +++ b/src/revocation/gnunet-service-revocation.c | |||
@@ -901,9 +901,8 @@ run (void *cls, | |||
901 | } | 901 | } |
902 | GNUNET_free (fn); | 902 | GNUNET_free (fn); |
903 | 903 | ||
904 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 904 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
905 | &shutdown_task, | 905 | NULL); |
906 | NULL); | ||
907 | peers = GNUNET_CONTAINER_multipeermap_create (128, | 906 | peers = GNUNET_CONTAINER_multipeermap_create (128, |
908 | GNUNET_YES); | 907 | GNUNET_YES); |
909 | GNUNET_SERVER_add_handlers (srv, handlers); | 908 | GNUNET_SERVER_add_handlers (srv, handlers); |
diff --git a/src/rps/gnunet-rps.c b/src/rps/gnunet-rps.c index 01be2aeb3..705c2c9b0 100644 --- a/src/rps/gnunet-rps.c +++ b/src/rps/gnunet-rps.c | |||
@@ -46,12 +46,6 @@ static struct GNUNET_PeerIdentity *peer_id; | |||
46 | 46 | ||
47 | 47 | ||
48 | /** | 48 | /** |
49 | * Shutdown task | ||
50 | */ | ||
51 | static struct GNUNET_SCHEDULER_Task *shutdown_task; | ||
52 | |||
53 | |||
54 | /** | ||
55 | * Set an option of type 'struct GNUNET_PeerIdentity *' from the command line. | 49 | * Set an option of type 'struct GNUNET_PeerIdentity *' from the command line. |
56 | * A pointer to this function should be passed as part of the | 50 | * A pointer to this function should be passed as part of the |
57 | * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options | 51 | * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options |
@@ -96,7 +90,6 @@ GNUNET_GETOPT_set_peerid (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
96 | static void | 90 | static void |
97 | do_shutdown (void *cls) | 91 | do_shutdown (void *cls) |
98 | { | 92 | { |
99 | shutdown_task = NULL; | ||
100 | if (NULL != req_handle) | 93 | if (NULL != req_handle) |
101 | GNUNET_RPS_request_cancel (req_handle); | 94 | GNUNET_RPS_request_cancel (req_handle); |
102 | GNUNET_RPS_disconnect (rps_handle); | 95 | GNUNET_RPS_disconnect (rps_handle); |
@@ -126,8 +119,7 @@ reply_handle (void *cls, | |||
126 | } | 119 | } |
127 | ret = 0; | 120 | ret = 0; |
128 | 121 | ||
129 | GNUNET_SCHEDULER_cancel (shutdown_task); | 122 | GNUNET_SCHEDULER_shutdown (); |
130 | GNUNET_SCHEDULER_add_now (do_shutdown, NULL); | ||
131 | } | 123 | } |
132 | 124 | ||
133 | 125 | ||
@@ -156,15 +148,14 @@ run (void *cls, | |||
156 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 148 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
157 | "Requesting %u PeerIDs\n", num_peers); | 149 | "Requesting %u PeerIDs\n", num_peers); |
158 | req_handle = GNUNET_RPS_request_peers (rps_handle, num_peers, reply_handle, NULL); | 150 | req_handle = GNUNET_RPS_request_peers (rps_handle, num_peers, reply_handle, NULL); |
159 | shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 151 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
160 | &do_shutdown, NULL); | ||
161 | } | 152 | } |
162 | else | 153 | else |
163 | { /* Seed PeerID */ | 154 | { /* Seed PeerID */ |
164 | GNUNET_RPS_seed_ids (rps_handle, 1, peer_id); | 155 | GNUNET_RPS_seed_ids (rps_handle, 1, peer_id); |
165 | FPRINTF (stdout, "Seeded PeerID %s\n", GNUNET_i2s_full (peer_id)); | 156 | FPRINTF (stdout, "Seeded PeerID %s\n", GNUNET_i2s_full (peer_id)); |
166 | ret = 0; | 157 | ret = 0; |
167 | GNUNET_SCHEDULER_add_now (do_shutdown, NULL); | 158 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
168 | } | 159 | } |
169 | } | 160 | } |
170 | 161 | ||
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index af06cf1bd..91d4840bb 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) | 3 | Copyright (C) 2013-2015 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -149,16 +149,14 @@ static struct RPS_Sampler *prot_sampler; | |||
149 | */ | 149 | */ |
150 | static struct RPS_Sampler *client_sampler; | 150 | static struct RPS_Sampler *client_sampler; |
151 | 151 | ||
152 | |||
153 | /** | 152 | /** |
154 | * Name to log view to | 153 | * Name to log view to |
155 | */ | 154 | */ |
156 | static char *file_name_view_log; | 155 | static char *file_name_view_log; |
157 | 156 | ||
158 | |||
159 | /** | 157 | /** |
160 | * The size of sampler we need to be able to satisfy the client's need of | 158 | * The size of sampler we need to be able to satisfy the client's need |
161 | * random peers. | 159 | * of random peers. |
162 | */ | 160 | */ |
163 | static unsigned int sampler_size_client_need; | 161 | static unsigned int sampler_size_client_need; |
164 | 162 | ||
@@ -170,7 +168,6 @@ static unsigned int sampler_size_client_need; | |||
170 | */ | 168 | */ |
171 | static unsigned int sampler_size_est_need; | 169 | static unsigned int sampler_size_est_need; |
172 | 170 | ||
173 | |||
174 | /** | 171 | /** |
175 | * Percentage of total peer number in the view | 172 | * Percentage of total peer number in the view |
176 | * to send random PUSHes to | 173 | * to send random PUSHes to |
@@ -184,12 +181,6 @@ static float alpha; | |||
184 | static float beta; | 181 | static float beta; |
185 | 182 | ||
186 | /** | 183 | /** |
187 | * The percentage gamma of history updates. | ||
188 | * Simply 1 - alpha - beta | ||
189 | */ | ||
190 | |||
191 | |||
192 | /** | ||
193 | * Identifier for the main task that runs periodically. | 184 | * Identifier for the main task that runs periodically. |
194 | */ | 185 | */ |
195 | static struct GNUNET_SCHEDULER_Task *do_round_task; | 186 | static struct GNUNET_SCHEDULER_Task *do_round_task; |
@@ -199,8 +190,6 @@ static struct GNUNET_SCHEDULER_Task *do_round_task; | |||
199 | */ | 190 | */ |
200 | static struct GNUNET_TIME_Relative round_interval; | 191 | static struct GNUNET_TIME_Relative round_interval; |
201 | 192 | ||
202 | |||
203 | |||
204 | /** | 193 | /** |
205 | * List to store peers received through pushes temporary. | 194 | * List to store peers received through pushes temporary. |
206 | */ | 195 | */ |
@@ -211,7 +200,6 @@ static struct CustomPeerMap *push_map; | |||
211 | */ | 200 | */ |
212 | static struct CustomPeerMap *pull_map; | 201 | static struct CustomPeerMap *pull_map; |
213 | 202 | ||
214 | |||
215 | /** | 203 | /** |
216 | * Handler to NSE. | 204 | * Handler to NSE. |
217 | */ | 205 | */ |
@@ -230,8 +218,7 @@ static struct GNUNET_PEERINFO_Handle *peerinfo_handle; | |||
230 | /** | 218 | /** |
231 | * Handle for cancellation of iteration over peers. | 219 | * Handle for cancellation of iteration over peers. |
232 | */ | 220 | */ |
233 | struct GNUNET_PEERINFO_NotifyContext *peerinfo_notify_handle; | 221 | static struct GNUNET_PEERINFO_NotifyContext *peerinfo_notify_handle; |
234 | |||
235 | 222 | ||
236 | /** | 223 | /** |
237 | * Request counter. | 224 | * Request counter. |
@@ -263,13 +250,12 @@ static struct GNUNET_TIME_Relative request_deltas[REQUEST_DELTAS_SIZE]; | |||
263 | /** | 250 | /** |
264 | * The prediction of the rate of requests | 251 | * The prediction of the rate of requests |
265 | */ | 252 | */ |
266 | static struct GNUNET_TIME_Relative request_rate; | 253 | static struct GNUNET_TIME_Relative request_rate; |
267 | |||
268 | 254 | ||
269 | /** | 255 | /** |
270 | * Number of history update tasks. | 256 | * Number of history update tasks. |
271 | */ | 257 | */ |
272 | uint32_t num_hist_update_tasks; | 258 | static uint32_t num_hist_update_tasks; |
273 | 259 | ||
274 | 260 | ||
275 | #ifdef ENABLE_MALICIOUS | 261 | #ifdef ENABLE_MALICIOUS |
@@ -281,18 +267,18 @@ uint32_t num_hist_update_tasks; | |||
281 | * 2 Try to partition the network | 267 | * 2 Try to partition the network |
282 | * 3 Combined attack | 268 | * 3 Combined attack |
283 | */ | 269 | */ |
284 | uint32_t mal_type = 0; | 270 | static uint32_t mal_type; |
285 | 271 | ||
286 | /** | 272 | /** |
287 | * Other malicious peers | 273 | * Other malicious peers |
288 | */ | 274 | */ |
289 | static struct GNUNET_PeerIdentity *mal_peers = NULL; | 275 | static struct GNUNET_PeerIdentity *mal_peers; |
290 | 276 | ||
291 | /** | 277 | /** |
292 | * Hashmap of malicious peers used as set. | 278 | * Hashmap of malicious peers used as set. |
293 | * Used to more efficiently check whether we know that peer. | 279 | * Used to more efficiently check whether we know that peer. |
294 | */ | 280 | */ |
295 | static struct GNUNET_CONTAINER_MultiPeerMap *mal_peer_set = NULL; | 281 | static struct GNUNET_CONTAINER_MultiPeerMap *mal_peer_set; |
296 | 282 | ||
297 | /** | 283 | /** |
298 | * Number of other malicious peers | 284 | * Number of other malicious peers |
@@ -320,26 +306,25 @@ struct AttackedPeer | |||
320 | /** | 306 | /** |
321 | * If type is 2 this is the DLL of attacked peers | 307 | * If type is 2 this is the DLL of attacked peers |
322 | */ | 308 | */ |
323 | static struct AttackedPeer *att_peers_head = NULL; | 309 | static struct AttackedPeer *att_peers_head; |
324 | static struct AttackedPeer *att_peers_tail = NULL; | 310 | static struct AttackedPeer *att_peers_tail; |
325 | 311 | ||
326 | /** | 312 | /** |
327 | * This index is used to point to an attacked peer to | 313 | * This index is used to point to an attacked peer to |
328 | * implement the round-robin-ish way to select attacked peers. | 314 | * implement the round-robin-ish way to select attacked peers. |
329 | */ | 315 | */ |
330 | static struct AttackedPeer *att_peer_index = NULL; | 316 | static struct AttackedPeer *att_peer_index; |
331 | 317 | ||
332 | /** | 318 | /** |
333 | * Hashmap of attacked peers used as set. | 319 | * Hashmap of attacked peers used as set. |
334 | * Used to more efficiently check whether we know that peer. | 320 | * Used to more efficiently check whether we know that peer. |
335 | */ | 321 | */ |
336 | static struct GNUNET_CONTAINER_MultiPeerMap *att_peer_set = NULL; | 322 | static struct GNUNET_CONTAINER_MultiPeerMap *att_peer_set; |
337 | 323 | ||
338 | /** | 324 | /** |
339 | * Number of attacked peers | 325 | * Number of attacked peers |
340 | */ | 326 | */ |
341 | static uint32_t num_attacked_peers = 0; | 327 | static uint32_t num_attacked_peers; |
342 | |||
343 | 328 | ||
344 | /** | 329 | /** |
345 | * If type is 1 this is the attacked peer | 330 | * If type is 1 this is the attacked peer |
@@ -362,10 +347,6 @@ static uint32_t push_limit = 10000; | |||
362 | ***********************************************************************/ | 347 | ***********************************************************************/ |
363 | 348 | ||
364 | 349 | ||
365 | |||
366 | |||
367 | |||
368 | |||
369 | /*********************************************************************** | 350 | /*********************************************************************** |
370 | * Util functions | 351 | * Util functions |
371 | ***********************************************************************/ | 352 | ***********************************************************************/ |
@@ -374,8 +355,9 @@ static uint32_t push_limit = 10000; | |||
374 | /** | 355 | /** |
375 | * Print peerlist to log. | 356 | * Print peerlist to log. |
376 | */ | 357 | */ |
377 | void | 358 | static void |
378 | print_peer_list (struct GNUNET_PeerIdentity *list, unsigned int len) | 359 | print_peer_list (struct GNUNET_PeerIdentity *list, |
360 | unsigned int len) | ||
379 | { | 361 | { |
380 | unsigned int i; | 362 | unsigned int i; |
381 | 363 | ||
@@ -395,7 +377,7 @@ print_peer_list (struct GNUNET_PeerIdentity *list, unsigned int len) | |||
395 | /** | 377 | /** |
396 | * Remove peer from list. | 378 | * Remove peer from list. |
397 | */ | 379 | */ |
398 | void | 380 | static void |
399 | rem_from_list (struct GNUNET_PeerIdentity **peer_list, | 381 | rem_from_list (struct GNUNET_PeerIdentity **peer_list, |
400 | unsigned int *list_size, | 382 | unsigned int *list_size, |
401 | const struct GNUNET_PeerIdentity *peer) | 383 | const struct GNUNET_PeerIdentity *peer) |
@@ -429,9 +411,10 @@ rem_from_list (struct GNUNET_PeerIdentity **peer_list, | |||
429 | 411 | ||
430 | /** | 412 | /** |
431 | * Sum all time relatives of an array. | 413 | * Sum all time relatives of an array. |
432 | */ | 414 | */ |
433 | struct GNUNET_TIME_Relative | 415 | static struct GNUNET_TIME_Relative |
434 | T_relative_sum (const struct GNUNET_TIME_Relative *rel_array, uint32_t arr_size) | 416 | T_relative_sum (const struct GNUNET_TIME_Relative *rel_array, |
417 | uint32_t arr_size) | ||
435 | { | 418 | { |
436 | struct GNUNET_TIME_Relative sum; | 419 | struct GNUNET_TIME_Relative sum; |
437 | uint32_t i; | 420 | uint32_t i; |
@@ -448,18 +431,23 @@ T_relative_sum (const struct GNUNET_TIME_Relative *rel_array, uint32_t arr_size) | |||
448 | /** | 431 | /** |
449 | * Compute the average of given time relatives. | 432 | * Compute the average of given time relatives. |
450 | */ | 433 | */ |
451 | struct GNUNET_TIME_Relative | 434 | static struct GNUNET_TIME_Relative |
452 | T_relative_avg (const struct GNUNET_TIME_Relative *rel_array, uint32_t arr_size) | 435 | T_relative_avg (const struct GNUNET_TIME_Relative *rel_array, |
436 | uint32_t arr_size) | ||
453 | { | 437 | { |
454 | return GNUNET_TIME_relative_divide (T_relative_sum (rel_array, arr_size), arr_size); | 438 | return GNUNET_TIME_relative_divide (T_relative_sum (rel_array, |
439 | arr_size), | ||
440 | arr_size); | ||
455 | } | 441 | } |
456 | 442 | ||
457 | 443 | ||
458 | /** | 444 | /** |
459 | * Put random peer from sampler into the view as history update. | 445 | * Put random peer from sampler into the view as history update. |
460 | */ | 446 | */ |
461 | void | 447 | static void |
462 | hist_update (void *cls, struct GNUNET_PeerIdentity *ids, uint32_t num_peers) | 448 | hist_update (void *cls, |
449 | struct GNUNET_PeerIdentity *ids, | ||
450 | uint32_t num_peers) | ||
463 | { | 451 | { |
464 | unsigned int i; | 452 | unsigned int i; |
465 | 453 | ||
@@ -475,7 +463,6 @@ hist_update (void *cls, struct GNUNET_PeerIdentity *ids, uint32_t num_peers) | |||
475 | } | 463 | } |
476 | 464 | ||
477 | 465 | ||
478 | |||
479 | /** | 466 | /** |
480 | * Wrapper around #RPS_sampler_resize() | 467 | * Wrapper around #RPS_sampler_resize() |
481 | * | 468 | * |
@@ -526,7 +513,7 @@ client_resize_wrapper () | |||
526 | * | 513 | * |
527 | * Called every time we receive a request from the client. | 514 | * Called every time we receive a request from the client. |
528 | */ | 515 | */ |
529 | void | 516 | static void |
530 | est_request_rate() | 517 | est_request_rate() |
531 | { | 518 | { |
532 | struct GNUNET_TIME_Relative max_round_duration; | 519 | struct GNUNET_TIME_Relative max_round_duration; |
@@ -647,28 +634,33 @@ send_pull_reply (const struct GNUNET_PeerIdentity *peer_id, | |||
647 | * | 634 | * |
648 | * Called once we know a peer is live. | 635 | * Called once we know a peer is live. |
649 | */ | 636 | */ |
650 | void | 637 | static void |
651 | insert_in_pull_map (void *cls, const struct GNUNET_PeerIdentity *peer) | 638 | insert_in_pull_map (void *cls, |
639 | const struct GNUNET_PeerIdentity *peer) | ||
652 | { | 640 | { |
653 | CustomPeerMap_put (pull_map, peer); | 641 | CustomPeerMap_put (pull_map, peer); |
654 | } | 642 | } |
655 | 643 | ||
644 | |||
656 | /** | 645 | /** |
657 | * Insert PeerID in #view | 646 | * Insert PeerID in #view |
658 | * | 647 | * |
659 | * Called once we know a peer is live. | 648 | * Called once we know a peer is live. |
660 | */ | 649 | */ |
661 | void | 650 | static void |
662 | insert_in_view (void *cls, const struct GNUNET_PeerIdentity *peer) | 651 | insert_in_view (void *cls, |
652 | const struct GNUNET_PeerIdentity *peer) | ||
663 | { | 653 | { |
664 | View_put (peer); | 654 | View_put (peer); |
665 | } | 655 | } |
666 | 656 | ||
657 | |||
667 | /** | 658 | /** |
668 | * Update sampler with given PeerID. | 659 | * Update sampler with given PeerID. |
669 | */ | 660 | */ |
670 | void | 661 | static void |
671 | insert_in_sampler (void *cls, const struct GNUNET_PeerIdentity *peer) | 662 | insert_in_sampler (void *cls, |
663 | const struct GNUNET_PeerIdentity *peer) | ||
672 | { | 664 | { |
673 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 665 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
674 | "Updating samplers with peer %s from insert_in_sampler()\n", | 666 | "Updating samplers with peer %s from insert_in_sampler()\n", |
@@ -875,6 +867,7 @@ destroy_reply_cls (struct ReplyCls *rep_cls) | |||
875 | GNUNET_free (rep_cls); | 867 | GNUNET_free (rep_cls); |
876 | } | 868 | } |
877 | 869 | ||
870 | |||
878 | static void | 871 | static void |
879 | destroy_cli_ctx (struct ClientContext *cli_ctx) | 872 | destroy_cli_ctx (struct ClientContext *cli_ctx) |
880 | { | 873 | { |
@@ -899,8 +892,9 @@ destroy_cli_ctx (struct ClientContext *cli_ctx) | |||
899 | * Updates sizes of sampler list and view and adapt those lists | 892 | * Updates sizes of sampler list and view and adapt those lists |
900 | * accordingly. | 893 | * accordingly. |
901 | */ | 894 | */ |
902 | void | 895 | static void |
903 | nse_callback (void *cls, struct GNUNET_TIME_Absolute timestamp, | 896 | nse_callback (void *cls, |
897 | struct GNUNET_TIME_Absolute timestamp, | ||
904 | double logestimate, double std_dev) | 898 | double logestimate, double std_dev) |
905 | { | 899 | { |
906 | double estimate; | 900 | double estimate; |
@@ -933,7 +927,7 @@ nse_callback (void *cls, struct GNUNET_TIME_Absolute timestamp, | |||
933 | * | 927 | * |
934 | * Sends those to the requesting client. | 928 | * Sends those to the requesting client. |
935 | */ | 929 | */ |
936 | void | 930 | static void |
937 | client_respond (void *cls, | 931 | client_respond (void *cls, |
938 | struct GNUNET_PeerIdentity *peer_ids, | 932 | struct GNUNET_PeerIdentity *peer_ids, |
939 | uint32_t num_peers) | 933 | uint32_t num_peers) |
@@ -1080,7 +1074,7 @@ handle_client_request_cancel (void *cls, | |||
1080 | * @param client identification of the client | 1074 | * @param client identification of the client |
1081 | * @param message the actual message | 1075 | * @param message the actual message |
1082 | */ | 1076 | */ |
1083 | static void | 1077 | static void |
1084 | handle_client_seed (void *cls, | 1078 | handle_client_seed (void *cls, |
1085 | struct GNUNET_SERVER_Client *client, | 1079 | struct GNUNET_SERVER_Client *client, |
1086 | const struct GNUNET_MessageHeader *message) | 1080 | const struct GNUNET_MessageHeader *message) |
@@ -1136,7 +1130,7 @@ handle_client_seed (void *cls, | |||
1136 | ////GNUNET_free (peers); | 1130 | ////GNUNET_free (peers); |
1137 | 1131 | ||
1138 | GNUNET_SERVER_receive_done (client, | 1132 | GNUNET_SERVER_receive_done (client, |
1139 | GNUNET_OK); | 1133 | GNUNET_OK); |
1140 | } | 1134 | } |
1141 | 1135 | ||
1142 | 1136 | ||
@@ -1153,9 +1147,9 @@ handle_client_seed (void *cls, | |||
1153 | */ | 1147 | */ |
1154 | static int | 1148 | static int |
1155 | handle_peer_push (void *cls, | 1149 | handle_peer_push (void *cls, |
1156 | struct GNUNET_CADET_Channel *channel, | 1150 | struct GNUNET_CADET_Channel *channel, |
1157 | void **channel_ctx, | 1151 | void **channel_ctx, |
1158 | const struct GNUNET_MessageHeader *msg) | 1152 | const struct GNUNET_MessageHeader *msg) |
1159 | { | 1153 | { |
1160 | const struct GNUNET_PeerIdentity *peer; | 1154 | const struct GNUNET_PeerIdentity *peer; |
1161 | 1155 | ||
@@ -1165,9 +1159,11 @@ handle_peer_push (void *cls, | |||
1165 | GNUNET_CADET_channel_get_info (channel, GNUNET_CADET_OPTION_PEER); | 1159 | GNUNET_CADET_channel_get_info (channel, GNUNET_CADET_OPTION_PEER); |
1166 | // FIXME wait for cadet to change this function | 1160 | // FIXME wait for cadet to change this function |
1167 | 1161 | ||
1168 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Received PUSH (%s)\n", GNUNET_i2s (peer)); | 1162 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1163 | "Received PUSH (%s)\n", | ||
1164 | GNUNET_i2s (peer)); | ||
1169 | 1165 | ||
1170 | #ifdef ENABLE_MALICIOUS | 1166 | #ifdef ENABLE_MALICIOUS |
1171 | struct AttackedPeer *tmp_att_peer; | 1167 | struct AttackedPeer *tmp_att_peer; |
1172 | 1168 | ||
1173 | tmp_att_peer = GNUNET_new (struct AttackedPeer); | 1169 | tmp_att_peer = GNUNET_new (struct AttackedPeer); |
@@ -1220,9 +1216,9 @@ handle_peer_push (void *cls, | |||
1220 | */ | 1216 | */ |
1221 | static int | 1217 | static int |
1222 | handle_peer_pull_request (void *cls, | 1218 | handle_peer_pull_request (void *cls, |
1223 | struct GNUNET_CADET_Channel *channel, | 1219 | struct GNUNET_CADET_Channel *channel, |
1224 | void **channel_ctx, | 1220 | void **channel_ctx, |
1225 | const struct GNUNET_MessageHeader *msg) | 1221 | const struct GNUNET_MessageHeader *msg) |
1226 | { | 1222 | { |
1227 | struct GNUNET_PeerIdentity *peer; | 1223 | struct GNUNET_PeerIdentity *peer; |
1228 | const struct GNUNET_PeerIdentity *view_array; | 1224 | const struct GNUNET_PeerIdentity *view_array; |
@@ -1272,7 +1268,7 @@ handle_peer_pull_request (void *cls, | |||
1272 | * @param channel_ctx The context associated with this channel | 1268 | * @param channel_ctx The context associated with this channel |
1273 | * @param msg The message header | 1269 | * @param msg The message header |
1274 | */ | 1270 | */ |
1275 | static int | 1271 | static int |
1276 | handle_peer_pull_reply (void *cls, | 1272 | handle_peer_pull_reply (void *cls, |
1277 | struct GNUNET_CADET_Channel *channel, | 1273 | struct GNUNET_CADET_Channel *channel, |
1278 | void **channel_ctx, | 1274 | void **channel_ctx, |
@@ -1404,7 +1400,8 @@ handle_peer_pull_reply (void *cls, | |||
1404 | * @param spread the inverse amount of deviation from the mean | 1400 | * @param spread the inverse amount of deviation from the mean |
1405 | */ | 1401 | */ |
1406 | static struct GNUNET_TIME_Relative | 1402 | static struct GNUNET_TIME_Relative |
1407 | compute_rand_delay (struct GNUNET_TIME_Relative mean, unsigned int spread) | 1403 | compute_rand_delay (struct GNUNET_TIME_Relative mean, |
1404 | unsigned int spread) | ||
1408 | { | 1405 | { |
1409 | struct GNUNET_TIME_Relative half_interval; | 1406 | struct GNUNET_TIME_Relative half_interval; |
1410 | struct GNUNET_TIME_Relative ret; | 1407 | struct GNUNET_TIME_Relative ret; |
@@ -1496,7 +1493,7 @@ do_mal_round (void *cls); | |||
1496 | * @param client The client that sent the message | 1493 | * @param client The client that sent the message |
1497 | * @param msg The message header | 1494 | * @param msg The message header |
1498 | */ | 1495 | */ |
1499 | static void | 1496 | static void |
1500 | handle_client_act_malicious (void *cls, | 1497 | handle_client_act_malicious (void *cls, |
1501 | struct GNUNET_SERVER_Client *client, | 1498 | struct GNUNET_SERVER_Client *client, |
1502 | const struct GNUNET_MessageHeader *msg) | 1499 | const struct GNUNET_MessageHeader *msg) |
@@ -1613,8 +1610,8 @@ handle_client_act_malicious (void *cls, | |||
1613 | { | 1610 | { |
1614 | GNUNET_break (0); | 1611 | GNUNET_break (0); |
1615 | } | 1612 | } |
1616 | 1613 | GNUNET_SERVER_receive_done (client, | |
1617 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1614 | GNUNET_OK); |
1618 | } | 1615 | } |
1619 | 1616 | ||
1620 | 1617 | ||
@@ -1631,7 +1628,8 @@ do_mal_round (void *cls) | |||
1631 | struct GNUNET_TIME_Relative time_next_round; | 1628 | struct GNUNET_TIME_Relative time_next_round; |
1632 | struct AttackedPeer *tmp_att_peer; | 1629 | struct AttackedPeer *tmp_att_peer; |
1633 | 1630 | ||
1634 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Going to execute next round maliciously type %" PRIu32 ".\n", | 1631 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1632 | "Going to execute next round maliciously type %" PRIu32 ".\n", | ||
1635 | mal_type); | 1633 | mal_type); |
1636 | do_round_task = NULL; | 1634 | do_round_task = NULL; |
1637 | GNUNET_assert (mal_type <= 3); | 1635 | GNUNET_assert (mal_type <= 3); |
@@ -1744,7 +1742,8 @@ do_mal_round (void *cls) | |||
1744 | //do_round_task = GNUNET_SCHEDULER_add_delayed (round_interval, &do_mal_round, | 1742 | //do_round_task = GNUNET_SCHEDULER_add_delayed (round_interval, &do_mal_round, |
1745 | //NULL); | 1743 | //NULL); |
1746 | GNUNET_assert (NULL == do_round_task); | 1744 | GNUNET_assert (NULL == do_round_task); |
1747 | do_round_task = GNUNET_SCHEDULER_add_delayed (time_next_round, &do_mal_round, NULL); | 1745 | do_round_task = GNUNET_SCHEDULER_add_delayed (time_next_round, |
1746 | &do_mal_round, NULL); | ||
1748 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Finished round\n"); | 1747 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Finished round\n"); |
1749 | } | 1748 | } |
1750 | #endif /* ENABLE_MALICIOUS */ | 1749 | #endif /* ENABLE_MALICIOUS */ |
@@ -1758,8 +1757,6 @@ do_mal_round (void *cls) | |||
1758 | static void | 1757 | static void |
1759 | do_round (void *cls) | 1758 | do_round (void *cls) |
1760 | { | 1759 | { |
1761 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Going to execute next round.\n"); | ||
1762 | |||
1763 | uint32_t i; | 1760 | uint32_t i; |
1764 | const struct GNUNET_PeerIdentity *view_array; | 1761 | const struct GNUNET_PeerIdentity *view_array; |
1765 | unsigned int *permut; | 1762 | unsigned int *permut; |
@@ -1770,6 +1767,8 @@ do_round (void *cls) | |||
1770 | struct GNUNET_PeerIdentity peer; | 1767 | struct GNUNET_PeerIdentity peer; |
1771 | struct GNUNET_PeerIdentity *update_peer; | 1768 | struct GNUNET_PeerIdentity *update_peer; |
1772 | 1769 | ||
1770 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1771 | "Going to execute next round.\n"); | ||
1773 | do_round_task = NULL; | 1772 | do_round_task = NULL; |
1774 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1773 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1775 | "Printing view:\n"); | 1774 | "Printing view:\n"); |
@@ -1967,7 +1966,8 @@ do_round (void *cls) | |||
1967 | time_next_round = compute_rand_delay (round_interval, 2); | 1966 | time_next_round = compute_rand_delay (round_interval, 2); |
1968 | 1967 | ||
1969 | /* Schedule next round */ | 1968 | /* Schedule next round */ |
1970 | do_round_task = GNUNET_SCHEDULER_add_delayed (time_next_round, &do_round, NULL); | 1969 | do_round_task = GNUNET_SCHEDULER_add_delayed (time_next_round, |
1970 | &do_round, NULL); | ||
1971 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Finished round\n"); | 1971 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Finished round\n"); |
1972 | } | 1972 | } |
1973 | 1973 | ||
@@ -2036,9 +2036,8 @@ process_peerinfo_peers (void *cls, | |||
2036 | static void | 2036 | static void |
2037 | shutdown_task (void *cls) | 2037 | shutdown_task (void *cls) |
2038 | { | 2038 | { |
2039 | 2039 | LOG (GNUNET_ERROR_TYPE_DEBUG, | |
2040 | LOG (GNUNET_ERROR_TYPE_DEBUG, "RPS is going down\n"); | 2040 | "RPS is going down\n"); |
2041 | |||
2042 | GNUNET_PEERINFO_notify_cancel (peerinfo_notify_handle); | 2041 | GNUNET_PEERINFO_notify_cancel (peerinfo_notify_handle); |
2043 | GNUNET_PEERINFO_disconnect (peerinfo_handle); | 2042 | GNUNET_PEERINFO_disconnect (peerinfo_handle); |
2044 | 2043 | ||
@@ -2153,9 +2152,8 @@ rps_start (struct GNUNET_SERVER_Handle *server) | |||
2153 | do_round_task = GNUNET_SCHEDULER_add_now (&do_round, NULL); | 2152 | do_round_task = GNUNET_SCHEDULER_add_now (&do_round, NULL); |
2154 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Scheduled first round\n"); | 2153 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Scheduled first round\n"); |
2155 | 2154 | ||
2156 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 2155 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
2157 | &shutdown_task, | 2156 | NULL); |
2158 | NULL); | ||
2159 | } | 2157 | } |
2160 | 2158 | ||
2161 | 2159 | ||
diff --git a/src/rps/gnunet-service-rps_sampler.c b/src/rps/gnunet-service-rps_sampler.c index e5f6595bb..2ac6054f4 100644 --- a/src/rps/gnunet-service-rps_sampler.c +++ b/src/rps/gnunet-service-rps_sampler.c | |||
@@ -533,12 +533,8 @@ sampler_get_rand_peer (void *cls) | |||
533 | struct GetPeerCls *gpc = cls; | 533 | struct GetPeerCls *gpc = cls; |
534 | uint32_t r_index; | 534 | uint32_t r_index; |
535 | struct RPS_Sampler *sampler; | 535 | struct RPS_Sampler *sampler; |
536 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
537 | 536 | ||
538 | gpc->get_peer_task = NULL; | 537 | gpc->get_peer_task = NULL; |
539 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
540 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
541 | return; | ||
542 | sampler = gpc->req_handle->sampler; | 538 | sampler = gpc->req_handle->sampler; |
543 | 539 | ||
544 | /**; | 540 | /**; |
@@ -588,12 +584,8 @@ sampler_mod_get_rand_peer (void *cls) | |||
588 | struct RPS_SamplerElement *s_elem; | 584 | struct RPS_SamplerElement *s_elem; |
589 | struct GNUNET_TIME_Relative last_request_diff; | 585 | struct GNUNET_TIME_Relative last_request_diff; |
590 | struct RPS_Sampler *sampler; | 586 | struct RPS_Sampler *sampler; |
591 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
592 | 587 | ||
593 | gpc->get_peer_task = NULL; | 588 | gpc->get_peer_task = NULL; |
594 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
595 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
596 | return; | ||
597 | sampler = gpc->req_handle->sampler; | 589 | sampler = gpc->req_handle->sampler; |
598 | 590 | ||
599 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Single peer was requested\n"); | 591 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Single peer was requested\n"); |
@@ -607,7 +599,8 @@ sampler_mod_get_rand_peer (void *cls) | |||
607 | 599 | ||
608 | if (EMPTY == s_elem->is_empty) | 600 | if (EMPTY == s_elem->is_empty) |
609 | { | 601 | { |
610 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sampler_mod element empty, rescheduling.\n"); | 602 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
603 | "Sampler_mod element empty, rescheduling.\n"); | ||
611 | GNUNET_assert (NULL == gpc->get_peer_task); | 604 | GNUNET_assert (NULL == gpc->get_peer_task); |
612 | gpc->get_peer_task = | 605 | gpc->get_peer_task = |
613 | GNUNET_SCHEDULER_add_delayed (sampler->max_round_interval, | 606 | GNUNET_SCHEDULER_add_delayed (sampler->max_round_interval, |
@@ -708,7 +701,8 @@ RPS_sampler_get_n_rand_peers (struct RPS_Sampler *sampler, | |||
708 | req_handle->gpc_tail, | 701 | req_handle->gpc_tail, |
709 | gpc); | 702 | gpc); |
710 | // maybe add a little delay | 703 | // maybe add a little delay |
711 | gpc->get_peer_task = GNUNET_SCHEDULER_add_now (sampler->get_peers, gpc); | 704 | gpc->get_peer_task = GNUNET_SCHEDULER_add_now (sampler->get_peers, |
705 | gpc); | ||
712 | } | 706 | } |
713 | return req_handle; | 707 | return req_handle; |
714 | } | 708 | } |
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c index aca58d55e..128a81f21 100644 --- a/src/rps/test_rps.c +++ b/src/rps/test_rps.c | |||
@@ -38,7 +38,7 @@ | |||
38 | /** | 38 | /** |
39 | * How many peers do we start? | 39 | * How many peers do we start? |
40 | */ | 40 | */ |
41 | uint32_t num_peers; | 41 | static uint32_t num_peers; |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * How long do we run the test? | 44 | * How long do we run the test? |
@@ -256,19 +256,12 @@ static unsigned int num_peers_online; | |||
256 | */ | 256 | */ |
257 | static int ok; | 257 | static int ok; |
258 | 258 | ||
259 | |||
260 | /** | 259 | /** |
261 | * Identifier for the churn task that runs periodically | 260 | * Identifier for the churn task that runs periodically |
262 | */ | 261 | */ |
263 | static struct GNUNET_SCHEDULER_Task *churn_task; | 262 | static struct GNUNET_SCHEDULER_Task *churn_task; |
264 | 263 | ||
265 | /** | 264 | /** |
266 | * Identifier for the churn task that runs periodically | ||
267 | */ | ||
268 | static struct GNUNET_SCHEDULER_Task *shutdown_task; | ||
269 | |||
270 | |||
271 | /** | ||
272 | * Called to initialise the given RPSPeer | 265 | * Called to initialise the given RPSPeer |
273 | */ | 266 | */ |
274 | typedef void (*InitPeer) (struct RPSPeer *rps_peer); | 267 | typedef void (*InitPeer) (struct RPSPeer *rps_peer); |
@@ -362,7 +355,7 @@ static int in_shutdown; | |||
362 | * Append arguments to file | 355 | * Append arguments to file |
363 | */ | 356 | */ |
364 | static void | 357 | static void |
365 | tofile_ (const char *file_name, char *line) | 358 | tofile_ (const char *file_name, const char *line) |
366 | { | 359 | { |
367 | struct GNUNET_DISK_FileHandle *f; | 360 | struct GNUNET_DISK_FileHandle *f; |
368 | /* char output_buffer[512]; */ | 361 | /* char output_buffer[512]; */ |
@@ -754,8 +747,7 @@ default_reply_handle (void *cls, | |||
754 | 747 | ||
755 | if (0 == evaluate ()) | 748 | if (0 == evaluate ()) |
756 | { | 749 | { |
757 | GNUNET_SCHEDULER_cancel (shutdown_task); | 750 | GNUNET_SCHEDULER_shutdown (); |
758 | shutdown_task = GNUNET_SCHEDULER_add_now (&shutdown_op, NULL); | ||
759 | } | 751 | } |
760 | } | 752 | } |
761 | 753 | ||
@@ -1388,7 +1380,7 @@ run (void *cls, | |||
1388 | 1380 | ||
1389 | if (NULL != churn_task) | 1381 | if (NULL != churn_task) |
1390 | GNUNET_SCHEDULER_cancel (churn_task); | 1382 | GNUNET_SCHEDULER_cancel (churn_task); |
1391 | shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL); | 1383 | GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL); |
1392 | } | 1384 | } |
1393 | 1385 | ||
1394 | 1386 | ||
diff --git a/src/scalarproduct/gnunet-scalarproduct.c b/src/scalarproduct/gnunet-scalarproduct.c index 5811ee57b..aa894b61d 100644 --- a/src/scalarproduct/gnunet-scalarproduct.c +++ b/src/scalarproduct/gnunet-scalarproduct.c | |||
@@ -327,9 +327,8 @@ run (void *cls, | |||
327 | return; | 327 | return; |
328 | } | 328 | } |
329 | GNUNET_free (elements); | 329 | GNUNET_free (elements); |
330 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 330 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
331 | &shutdown_task, | 331 | NULL); |
332 | NULL); | ||
333 | ret = 0; | 332 | ret = 0; |
334 | } | 333 | } |
335 | 334 | ||
diff --git a/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c b/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c index c22b4e09e..7485d5de1 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c +++ b/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c | |||
@@ -1193,9 +1193,8 @@ run (void *cls, | |||
1193 | GNUNET_SCHEDULER_shutdown (); | 1193 | GNUNET_SCHEDULER_shutdown (); |
1194 | return; | 1194 | return; |
1195 | } | 1195 | } |
1196 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1196 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
1197 | &shutdown_task, | 1197 | NULL); |
1198 | NULL); | ||
1199 | 1198 | ||
1200 | } | 1199 | } |
1201 | 1200 | ||
diff --git a/src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c b/src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c index 41cf7d1a8..3162d1252 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c +++ b/src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c | |||
@@ -1251,9 +1251,8 @@ run (void *cls, | |||
1251 | GNUNET_SCHEDULER_shutdown (); | 1251 | GNUNET_SCHEDULER_shutdown (); |
1252 | return; | 1252 | return; |
1253 | } | 1253 | } |
1254 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1254 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
1255 | &shutdown_task, | 1255 | NULL); |
1256 | NULL); | ||
1257 | } | 1256 | } |
1258 | 1257 | ||
1259 | 1258 | ||
diff --git a/src/scalarproduct/gnunet-service-scalarproduct_alice.c b/src/scalarproduct/gnunet-service-scalarproduct_alice.c index 0b7ba00d5..7eb2d006c 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct_alice.c +++ b/src/scalarproduct/gnunet-service-scalarproduct_alice.c | |||
@@ -1418,9 +1418,8 @@ run (void *cls, | |||
1418 | GNUNET_SCHEDULER_shutdown (); | 1418 | GNUNET_SCHEDULER_shutdown (); |
1419 | return; | 1419 | return; |
1420 | } | 1420 | } |
1421 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1421 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
1422 | &shutdown_task, | 1422 | NULL); |
1423 | NULL); | ||
1424 | 1423 | ||
1425 | } | 1424 | } |
1426 | 1425 | ||
diff --git a/src/scalarproduct/gnunet-service-scalarproduct_bob.c b/src/scalarproduct/gnunet-service-scalarproduct_bob.c index c9db1e9ae..8d97ea1b6 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct_bob.c +++ b/src/scalarproduct/gnunet-service-scalarproduct_bob.c | |||
@@ -1548,9 +1548,8 @@ run (void *cls, | |||
1548 | GNUNET_SCHEDULER_shutdown (); | 1548 | GNUNET_SCHEDULER_shutdown (); |
1549 | return; | 1549 | return; |
1550 | } | 1550 | } |
1551 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1551 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
1552 | &shutdown_task, | 1552 | NULL); |
1553 | NULL); | ||
1554 | } | 1553 | } |
1555 | 1554 | ||
1556 | 1555 | ||
diff --git a/src/secretsharing/gnunet-secretsharing-profiler.c b/src/secretsharing/gnunet-secretsharing-profiler.c index 917431df4..34f959d1a 100644 --- a/src/secretsharing/gnunet-secretsharing-profiler.c +++ b/src/secretsharing/gnunet-secretsharing-profiler.c | |||
@@ -530,8 +530,7 @@ test_master (void *cls, | |||
530 | 530 | ||
531 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "test master\n"); | 531 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "test master\n"); |
532 | 532 | ||
533 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 533 | GNUNET_SCHEDULER_add_shutdown (&handle_shutdown, NULL); |
534 | &handle_shutdown, NULL); | ||
535 | 534 | ||
536 | peers = started_peers; | 535 | peers = started_peers; |
537 | 536 | ||
diff --git a/src/secretsharing/gnunet-service-secretsharing.c b/src/secretsharing/gnunet-service-secretsharing.c index 6babe209a..a264bfdd5 100644 --- a/src/secretsharing/gnunet-service-secretsharing.c +++ b/src/secretsharing/gnunet-service-secretsharing.c | |||
@@ -2255,8 +2255,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
2255 | } | 2255 | } |
2256 | GNUNET_SERVER_add_handlers (server, handlers); | 2256 | GNUNET_SERVER_add_handlers (server, handlers); |
2257 | GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); | 2257 | GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); |
2258 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task, | 2258 | GNUNET_SCHEDULER_add_shutdown (&cleanup_task, |
2259 | NULL); | 2259 | NULL); |
2260 | } | 2260 | } |
2261 | 2261 | ||
2262 | 2262 | ||
diff --git a/src/secretsharing/test_secretsharing_api.c b/src/secretsharing/test_secretsharing_api.c index 5057d5c33..341a33b84 100644 --- a/src/secretsharing/test_secretsharing_api.c +++ b/src/secretsharing/test_secretsharing_api.c | |||
@@ -68,8 +68,7 @@ run (void *cls, | |||
68 | struct GNUNET_TIME_Absolute start; | 68 | struct GNUNET_TIME_Absolute start; |
69 | struct GNUNET_TIME_Absolute deadline; | 69 | struct GNUNET_TIME_Absolute deadline; |
70 | 70 | ||
71 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 71 | GNUNET_SCHEDULER_add_shutdown (&handle_shutdown, NULL); |
72 | handle_shutdown, NULL); | ||
73 | 72 | ||
74 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "testing secretsharing api\n"); | 73 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "testing secretsharing api\n"); |
75 | 74 | ||
diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c index e9555928a..2aad60309 100644 --- a/src/set/gnunet-service-set.c +++ b/src/set/gnunet-service-set.c | |||
@@ -1710,7 +1710,6 @@ handle_client_accept (void *cls, | |||
1710 | * Called to clean up, after a shutdown has been requested. | 1710 | * Called to clean up, after a shutdown has been requested. |
1711 | * | 1711 | * |
1712 | * @param cls closure | 1712 | * @param cls closure |
1713 | * @param tc context information (why was this task triggered now) | ||
1714 | */ | 1713 | */ |
1715 | static void | 1714 | static void |
1716 | shutdown_task (void *cls) | 1715 | shutdown_task (void *cls) |
@@ -1740,7 +1739,6 @@ shutdown_task (void *cls) | |||
1740 | * - we suggested an operation to our listener, | 1739 | * - we suggested an operation to our listener, |
1741 | * but did not receive a response in time | 1740 | * but did not receive a response in time |
1742 | * - we got the channel from a peer but no #GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST | 1741 | * - we got the channel from a peer but no #GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST |
1743 | * - shutdown (obviously) | ||
1744 | * | 1742 | * |
1745 | * @param cls channel context | 1743 | * @param cls channel context |
1746 | * @param tc context information (why was this task triggered now) | 1744 | * @param tc context information (why was this task triggered now) |
@@ -1749,13 +1747,9 @@ static void | |||
1749 | incoming_timeout_cb (void *cls) | 1747 | incoming_timeout_cb (void *cls) |
1750 | { | 1748 | { |
1751 | struct Operation *incoming = cls; | 1749 | struct Operation *incoming = cls; |
1752 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
1753 | 1750 | ||
1754 | incoming->timeout_task = NULL; | 1751 | incoming->timeout_task = NULL; |
1755 | GNUNET_assert (GNUNET_YES == incoming->is_incoming); | 1752 | GNUNET_assert (GNUNET_YES == incoming->is_incoming); |
1756 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
1757 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
1758 | return; | ||
1759 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1753 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1760 | "Remote peer's incoming request timed out\n"); | 1754 | "Remote peer's incoming request timed out\n"); |
1761 | incoming_destroy (incoming); | 1755 | incoming_destroy (incoming); |
@@ -1997,8 +1991,7 @@ run (void *cls, | |||
1997 | static const uint32_t cadet_ports[] = {GNUNET_APPLICATION_TYPE_SET, 0}; | 1991 | static const uint32_t cadet_ports[] = {GNUNET_APPLICATION_TYPE_SET, 0}; |
1998 | 1992 | ||
1999 | configuration = cfg; | 1993 | configuration = cfg; |
2000 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1994 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
2001 | &shutdown_task, NULL); | ||
2002 | GNUNET_SERVER_disconnect_notify (server, | 1995 | GNUNET_SERVER_disconnect_notify (server, |
2003 | &handle_client_disconnect, NULL); | 1996 | &handle_client_disconnect, NULL); |
2004 | GNUNET_SERVER_add_handlers (server, | 1997 | GNUNET_SERVER_add_handlers (server, |
diff --git a/src/set/gnunet-set-profiler.c b/src/set/gnunet-set-profiler.c index ff76b27ce..186a2763e 100644 --- a/src/set/gnunet-set-profiler.c +++ b/src/set/gnunet-set-profiler.c | |||
@@ -299,7 +299,7 @@ run (void *cls, | |||
299 | 299 | ||
300 | statistics = GNUNET_STATISTICS_create ("set-profiler", cfg); | 300 | statistics = GNUNET_STATISTICS_create ("set-profiler", cfg); |
301 | 301 | ||
302 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, handle_shutdown, NULL); | 302 | GNUNET_SCHEDULER_add_shutdown (&handle_shutdown, NULL); |
303 | 303 | ||
304 | info1.id = "a"; | 304 | info1.id = "a"; |
305 | info2.id = "b"; | 305 | info2.id = "b"; |
diff --git a/src/set/set_api.c b/src/set/set_api.c index 772140269..794ae57b7 100644 --- a/src/set/set_api.c +++ b/src/set/set_api.c | |||
@@ -230,7 +230,7 @@ struct GNUNET_SET_ListenHandle | |||
230 | /** | 230 | /** |
231 | * Task for reconnecting when the listener fails. | 231 | * Task for reconnecting when the listener fails. |
232 | */ | 232 | */ |
233 | struct GNUNET_SCHEDULER_Task * reconnect_task; | 233 | struct GNUNET_SCHEDULER_Task *reconnect_task; |
234 | 234 | ||
235 | /** | 235 | /** |
236 | * Operation we listen for. | 236 | * Operation we listen for. |
@@ -891,15 +891,7 @@ listen_connect (void *cls) | |||
891 | struct GNUNET_SET_ListenHandle *lh = cls; | 891 | struct GNUNET_SET_ListenHandle *lh = cls; |
892 | struct GNUNET_MQ_Envelope *mqm; | 892 | struct GNUNET_MQ_Envelope *mqm; |
893 | struct GNUNET_SET_ListenMessage *msg; | 893 | struct GNUNET_SET_ListenMessage *msg; |
894 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
895 | 894 | ||
896 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
897 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
898 | { | ||
899 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
900 | "Listener not reconnecting due to shutdown\n"); | ||
901 | return; | ||
902 | } | ||
903 | lh->reconnect_task = NULL; | 895 | lh->reconnect_task = NULL; |
904 | GNUNET_assert (NULL == lh->client); | 896 | GNUNET_assert (NULL == lh->client); |
905 | lh->client = GNUNET_CLIENT_connect ("set", lh->cfg); | 897 | lh->client = GNUNET_CLIENT_connect ("set", lh->cfg); |
diff --git a/src/set/test_set_api.c b/src/set/test_set_api.c index b5c21f8a3..d04877b39 100644 --- a/src/set/test_set_api.c +++ b/src/set/test_set_api.c | |||
@@ -44,6 +44,8 @@ static unsigned int iter_count; | |||
44 | 44 | ||
45 | static int ret; | 45 | static int ret; |
46 | 46 | ||
47 | static struct GNUNET_SCHEDULER_Task *tt; | ||
48 | |||
47 | 49 | ||
48 | static void | 50 | static void |
49 | result_cb_set1 (void *cls, | 51 | result_cb_set1 (void *cls, |
@@ -61,6 +63,8 @@ result_cb_set1 (void *cls, | |||
61 | fprintf (stderr, | 63 | fprintf (stderr, |
62 | "set 1: received failure status!\n"); | 64 | "set 1: received failure status!\n"); |
63 | ret = 1; | 65 | ret = 1; |
66 | GNUNET_SCHEDULER_cancel (tt); | ||
67 | tt = NULL; | ||
64 | GNUNET_SCHEDULER_shutdown (); | 68 | GNUNET_SCHEDULER_shutdown (); |
65 | break; | 69 | break; |
66 | case GNUNET_SET_STATUS_DONE: | 70 | case GNUNET_SET_STATUS_DONE: |
@@ -69,7 +73,11 @@ result_cb_set1 (void *cls, | |||
69 | GNUNET_SET_destroy (set1); | 73 | GNUNET_SET_destroy (set1); |
70 | set1 = NULL; | 74 | set1 = NULL; |
71 | if (NULL == set2) | 75 | if (NULL == set2) |
76 | { | ||
77 | GNUNET_SCHEDULER_cancel (tt); | ||
78 | tt = NULL; | ||
72 | GNUNET_SCHEDULER_shutdown (); | 79 | GNUNET_SCHEDULER_shutdown (); |
80 | } | ||
73 | break; | 81 | break; |
74 | default: | 82 | default: |
75 | GNUNET_assert (0); | 83 | GNUNET_assert (0); |
@@ -100,7 +108,11 @@ result_cb_set2 (void *cls, | |||
100 | GNUNET_SET_destroy (set2); | 108 | GNUNET_SET_destroy (set2); |
101 | set2 = NULL; | 109 | set2 = NULL; |
102 | if (NULL == set1) | 110 | if (NULL == set1) |
111 | { | ||
112 | GNUNET_SCHEDULER_cancel (tt); | ||
113 | tt = NULL; | ||
103 | GNUNET_SCHEDULER_shutdown (); | 114 | GNUNET_SCHEDULER_shutdown (); |
115 | } | ||
104 | break; | 116 | break; |
105 | default: | 117 | default: |
106 | GNUNET_assert (0); | 118 | GNUNET_assert (0); |
@@ -250,11 +262,7 @@ test_iter () | |||
250 | static void | 262 | static void |
251 | timeout_fail (void *cls) | 263 | timeout_fail (void *cls) |
252 | { | 264 | { |
253 | const struct GNUNET_SCHEDULER_TaskContext *tc; | 265 | tt = NULL; |
254 | |||
255 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
256 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
257 | return; | ||
258 | GNUNET_SCHEDULER_shutdown (); | 266 | GNUNET_SCHEDULER_shutdown (); |
259 | ret = 1; | 267 | ret = 1; |
260 | } | 268 | } |
@@ -276,8 +284,8 @@ run (void *cls, | |||
276 | 284 | ||
277 | struct GNUNET_SET_OperationHandle *my_oh; | 285 | struct GNUNET_SET_OperationHandle *my_oh; |
278 | 286 | ||
279 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), | 287 | tt = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), |
280 | &timeout_fail, NULL); | 288 | &timeout_fail, NULL); |
281 | 289 | ||
282 | config = cfg; | 290 | config = cfg; |
283 | GNUNET_CRYPTO_get_peer_identity (cfg, &local_id); | 291 | GNUNET_CRYPTO_get_peer_identity (cfg, &local_id); |
diff --git a/src/set/test_set_union_copy.c b/src/set/test_set_union_copy.c index fdf6bf9df..7fedf426b 100644 --- a/src/set/test_set_union_copy.c +++ b/src/set/test_set_union_copy.c | |||
@@ -42,6 +42,8 @@ static struct GNUNET_SET_Handle *set2; | |||
42 | 42 | ||
43 | static const struct GNUNET_CONFIGURATION_Handle *config; | 43 | static const struct GNUNET_CONFIGURATION_Handle *config; |
44 | 44 | ||
45 | static struct GNUNET_SCHEDULER_Task *tt; | ||
46 | |||
45 | 47 | ||
46 | static void | 48 | static void |
47 | add_element_str (struct GNUNET_SET_Handle *set, char *str) | 49 | add_element_str (struct GNUNET_SET_Handle *set, char *str) |
@@ -77,11 +79,7 @@ remove_element_str (struct GNUNET_SET_Handle *set, char *str) | |||
77 | static void | 79 | static void |
78 | timeout_fail (void *cls) | 80 | timeout_fail (void *cls) |
79 | { | 81 | { |
80 | const struct GNUNET_SCHEDULER_TaskContext *tc; | 82 | tt = NULL; |
81 | |||
82 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
83 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
84 | return; | ||
85 | GNUNET_SCHEDULER_shutdown (); | 83 | GNUNET_SCHEDULER_shutdown (); |
86 | ret = 1; | 84 | ret = 1; |
87 | } | 85 | } |
@@ -125,8 +123,7 @@ check_count_iter (void *cls, | |||
125 | } | 123 | } |
126 | 124 | ||
127 | 125 | ||
128 | 126 | static void | |
129 | void | ||
130 | check_count (struct GNUNET_SET_Handle *set, | 127 | check_count (struct GNUNET_SET_Handle *set, |
131 | char *what, | 128 | char *what, |
132 | unsigned int expected_count, | 129 | unsigned int expected_count, |
@@ -145,24 +142,28 @@ check_count (struct GNUNET_SET_Handle *set, | |||
145 | } | 142 | } |
146 | 143 | ||
147 | 144 | ||
148 | void test_done (void *cls) | 145 | static void |
146 | test_done (void *cls) | ||
149 | { | 147 | { |
150 | if (NULL != set1) | 148 | if (NULL != set1) |
151 | GNUNET_SET_destroy (set1); | 149 | GNUNET_SET_destroy (set1); |
152 | if (NULL != set2) | 150 | if (NULL != set2) |
153 | GNUNET_SET_destroy (set2); | 151 | GNUNET_SET_destroy (set2); |
154 | 152 | GNUNET_SCHEDULER_cancel (tt); | |
153 | tt = NULL; | ||
155 | GNUNET_SCHEDULER_shutdown (); | 154 | GNUNET_SCHEDULER_shutdown (); |
156 | } | 155 | } |
157 | 156 | ||
158 | 157 | ||
159 | void check_new_set_count (void *cls) | 158 | static void |
159 | check_new_set_count (void *cls) | ||
160 | { | 160 | { |
161 | check_count (set2, "new set", 4, &test_done, NULL); | 161 | check_count (set2, "new set", 4, &test_done, NULL); |
162 | } | 162 | } |
163 | 163 | ||
164 | 164 | ||
165 | void copy_done (void *cls, struct GNUNET_SET_Handle *new_set) | 165 | static void |
166 | copy_done (void *cls, struct GNUNET_SET_Handle *new_set) | ||
166 | { | 167 | { |
167 | printf ("copy done\n"); | 168 | printf ("copy done\n"); |
168 | set2 = new_set; | 169 | set2 = new_set; |
@@ -177,7 +178,8 @@ void copy_done (void *cls, struct GNUNET_SET_Handle *new_set) | |||
177 | } | 178 | } |
178 | 179 | ||
179 | 180 | ||
180 | void test_copy (void *cls) | 181 | static void |
182 | test_copy (void *cls) | ||
181 | { | 183 | { |
182 | printf ("about to copy\n"); | 184 | printf ("about to copy\n"); |
183 | GNUNET_SET_copy_lazy (set1, copy_done, NULL); | 185 | GNUNET_SET_copy_lazy (set1, copy_done, NULL); |
@@ -198,9 +200,9 @@ run (void *cls, | |||
198 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 200 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
199 | struct GNUNET_TESTING_Peer *peer) | 201 | struct GNUNET_TESTING_Peer *peer) |
200 | { | 202 | { |
201 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), | 203 | tt = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), |
202 | &timeout_fail, | 204 | &timeout_fail, |
203 | NULL); | 205 | NULL); |
204 | 206 | ||
205 | config = cfg; | 207 | config = cfg; |
206 | GNUNET_TESTING_peer_get_identity (peer, | 208 | GNUNET_TESTING_peer_get_identity (peer, |
diff --git a/src/set/test_set_union_result_symmetric.c b/src/set/test_set_union_result_symmetric.c index b312bcb4c..77fec71c6 100644 --- a/src/set/test_set_union_result_symmetric.c +++ b/src/set/test_set_union_result_symmetric.c | |||
@@ -297,11 +297,6 @@ test_iter () | |||
297 | static void | 297 | static void |
298 | timeout_fail (void *cls) | 298 | timeout_fail (void *cls) |
299 | { | 299 | { |
300 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
301 | |||
302 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
303 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
304 | return; | ||
305 | GNUNET_SCHEDULER_shutdown (); | 300 | GNUNET_SCHEDULER_shutdown (); |
306 | ret = 1; | 301 | ret = 1; |
307 | } | 302 | } |
diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c index 1746a82ca..03a113d7e 100644 --- a/src/social/gnunet-service-social.c +++ b/src/social/gnunet-service-social.c | |||
@@ -408,8 +408,13 @@ static int | |||
408 | psyc_transmit_message (struct Place *plc); | 408 | psyc_transmit_message (struct Place *plc); |
409 | 409 | ||
410 | 410 | ||
411 | /** | ||
412 | * Clean up place data structures after a client disconnected. | ||
413 | * | ||
414 | * @param cls the `struct Place` to clean up | ||
415 | */ | ||
411 | static void | 416 | static void |
412 | cleanup_place (struct Place *plc); | 417 | cleanup_place (void *cls); |
413 | 418 | ||
414 | 419 | ||
415 | static struct MessageTransmitQueue * | 420 | static struct MessageTransmitQueue * |
@@ -426,7 +431,9 @@ place_entry_cleanup (void *cls, | |||
426 | const struct GNUNET_HashCode *key, | 431 | const struct GNUNET_HashCode *key, |
427 | void *value) | 432 | void *value) |
428 | { | 433 | { |
429 | cleanup_place (value); | 434 | struct Place *plc = value; |
435 | |||
436 | cleanup_place (plc); | ||
430 | return GNUNET_YES; | 437 | return GNUNET_YES; |
431 | } | 438 | } |
432 | 439 | ||
@@ -524,10 +531,14 @@ cleanup_guest (struct Guest *gst) | |||
524 | 531 | ||
525 | /** | 532 | /** |
526 | * Clean up place data structures after a client disconnected. | 533 | * Clean up place data structures after a client disconnected. |
534 | * | ||
535 | * @param cls the `struct Place` to clean up | ||
527 | */ | 536 | */ |
528 | static void | 537 | static void |
529 | cleanup_place (struct Place *plc) | 538 | cleanup_place (void *cls) |
530 | { | 539 | { |
540 | struct Place *plc = cls; | ||
541 | |||
531 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 542 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
532 | "%p Cleaning up place %s\n", | 543 | "%p Cleaning up place %s\n", |
533 | plc, GNUNET_h2s (&plc->pub_key_hash)); | 544 | plc, GNUNET_h2s (&plc->pub_key_hash)); |
@@ -541,13 +552,6 @@ cleanup_place (struct Place *plc) | |||
541 | } | 552 | } |
542 | 553 | ||
543 | 554 | ||
544 | static void | ||
545 | schedule_cleanup_place (void *cls) | ||
546 | { | ||
547 | cleanup_place (cls); | ||
548 | } | ||
549 | |||
550 | |||
551 | /** | 555 | /** |
552 | * Called whenever a client is disconnected. | 556 | * Called whenever a client is disconnected. |
553 | * Frees our resources associated with that client. | 557 | * Frees our resources associated with that client. |
@@ -2329,7 +2333,7 @@ psyc_transmit_notify_data (void *cls, uint16_t *data_size, void *data) | |||
2329 | tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg); | 2333 | tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg); |
2330 | plc->is_disconnected = GNUNET_YES; | 2334 | plc->is_disconnected = GNUNET_YES; |
2331 | GNUNET_SERVER_client_disconnect (tmit_frag->client); | 2335 | GNUNET_SERVER_client_disconnect (tmit_frag->client); |
2332 | GNUNET_SCHEDULER_add_now (&schedule_cleanup_place, plc); | 2336 | GNUNET_SCHEDULER_add_now (&cleanup_place, plc); |
2333 | return ret; | 2337 | return ret; |
2334 | } | 2338 | } |
2335 | else | 2339 | else |
@@ -2489,7 +2493,7 @@ psyc_transmit_notify_mod (void *cls, uint16_t *data_size, void *data, | |||
2489 | tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg); | 2493 | tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg); |
2490 | plc->is_disconnected = GNUNET_YES; | 2494 | plc->is_disconnected = GNUNET_YES; |
2491 | GNUNET_SERVER_client_disconnect (tmit_frag->client); | 2495 | GNUNET_SERVER_client_disconnect (tmit_frag->client); |
2492 | GNUNET_SCHEDULER_add_now (&schedule_cleanup_place, plc); | 2496 | GNUNET_SCHEDULER_add_now (&cleanup_place, plc); |
2493 | } | 2497 | } |
2494 | else | 2498 | else |
2495 | { | 2499 | { |
@@ -3480,8 +3484,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
3480 | nc = GNUNET_SERVER_notification_context_create (server, 1); | 3484 | nc = GNUNET_SERVER_notification_context_create (server, 1); |
3481 | GNUNET_SERVER_add_handlers (server, handlers); | 3485 | GNUNET_SERVER_add_handlers (server, handlers); |
3482 | GNUNET_SERVER_disconnect_notify (server, &client_disconnect, NULL); | 3486 | GNUNET_SERVER_disconnect_notify (server, &client_disconnect, NULL); |
3483 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 3487 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
3484 | &shutdown_task, NULL); | ||
3485 | } | 3488 | } |
3486 | 3489 | ||
3487 | 3490 | ||
diff --git a/src/social/test_social.c b/src/social/test_social.c index 5eeb20196..e2639f4d6 100644 --- a/src/social/test_social.c +++ b/src/social/test_social.c | |||
@@ -267,16 +267,17 @@ end () | |||
267 | GNUNET_SCHEDULER_cancel (end_badly_task); | 267 | GNUNET_SCHEDULER_cancel (end_badly_task); |
268 | end_badly_task = NULL; | 268 | end_badly_task = NULL; |
269 | } | 269 | } |
270 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS, | 270 | GNUNET_SCHEDULER_add_now (&end_normally, NULL); |
271 | &end_normally, NULL); | ||
272 | } | 271 | } |
273 | 272 | ||
274 | 273 | ||
275 | static void | 274 | static void |
276 | transmit_resume (void *cls) | 275 | transmit_resume (void *cls) |
277 | { | 276 | { |
278 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmission resumed.\n"); | ||
279 | struct TransmitClosure *tmit = cls; | 277 | struct TransmitClosure *tmit = cls; |
278 | |||
279 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
280 | "Transmission resumed.\n"); | ||
280 | if (NULL != tmit->host_ann) | 281 | if (NULL != tmit->host_ann) |
281 | GNUNET_SOCIAL_host_announce_resume (tmit->host_ann); | 282 | GNUNET_SOCIAL_host_announce_resume (tmit->host_ann); |
282 | else | 283 | else |
@@ -357,14 +358,14 @@ host_farewell2 (void *cls, | |||
357 | { | 358 | { |
358 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 359 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
359 | "Nym left the place again.\n"); | 360 | "Nym left the place again.\n"); |
360 | GNUNET_SCHEDULER_add_now (schedule_host_leave, NULL); | 361 | GNUNET_SCHEDULER_add_now (&schedule_host_leave, NULL); |
361 | } | 362 | } |
362 | 363 | ||
363 | 364 | ||
364 | static void | 365 | static void |
365 | host_reconnected (void *cls, int result, | 366 | host_reconnected (void *cls, int result, |
366 | const struct GNUNET_CRYPTO_EddsaPublicKey *home_pub_key, | 367 | const struct GNUNET_CRYPTO_EddsaPublicKey *home_pub_key, |
367 | uint64_t max_message_id) | 368 | uint64_t max_message_id) |
368 | { | 369 | { |
369 | place_pub_key = *home_pub_key; | 370 | place_pub_key = *home_pub_key; |
370 | GNUNET_CRYPTO_hash (&place_pub_key, sizeof (place_pub_key), &place_pub_hash); | 371 | GNUNET_CRYPTO_hash (&place_pub_key, sizeof (place_pub_key), &place_pub_hash); |
@@ -375,7 +376,7 @@ host_reconnected (void *cls, int result, | |||
375 | is_host_reconnected = GNUNET_YES; | 376 | is_host_reconnected = GNUNET_YES; |
376 | if (GNUNET_YES == is_guest_reconnected) | 377 | if (GNUNET_YES == is_guest_reconnected) |
377 | { | 378 | { |
378 | GNUNET_SCHEDULER_add_now (schedule_guest_leave, NULL); | 379 | GNUNET_SCHEDULER_add_now (&schedule_guest_leave, NULL); |
379 | } | 380 | } |
380 | } | 381 | } |
381 | 382 | ||
@@ -393,7 +394,7 @@ guest_reconnected (void *cls, int result, | |||
393 | is_guest_reconnected = GNUNET_YES; | 394 | is_guest_reconnected = GNUNET_YES; |
394 | if (GNUNET_YES == is_host_reconnected) | 395 | if (GNUNET_YES == is_host_reconnected) |
395 | { | 396 | { |
396 | GNUNET_SCHEDULER_add_now (schedule_guest_leave, NULL); | 397 | GNUNET_SCHEDULER_add_now (&schedule_guest_leave, NULL); |
397 | } | 398 | } |
398 | } | 399 | } |
399 | 400 | ||
@@ -583,8 +584,10 @@ schedule_guest_leave (void *cls) | |||
583 | 584 | ||
584 | 585 | ||
585 | static void | 586 | static void |
586 | guest_look_for_result (void *cls, int64_t result_code, | 587 | guest_look_for_result (void *cls, |
587 | const void *data, uint16_t data_size) | 588 | int64_t result_code, |
589 | const void *data, | ||
590 | uint16_t data_size) | ||
588 | { | 591 | { |
589 | struct ResultClosure *rcls = cls; | 592 | struct ResultClosure *rcls = cls; |
590 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 593 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -1047,7 +1050,7 @@ guest_recv_entry_decision (void *cls, | |||
1047 | break; | 1050 | break; |
1048 | 1051 | ||
1049 | case TEST_GUEST_ENTER_BY_NAME: | 1052 | case TEST_GUEST_ENTER_BY_NAME: |
1050 | GNUNET_SCHEDULER_add_now (schedule_reconnect, NULL); | 1053 | GNUNET_SCHEDULER_add_now (&schedule_reconnect, NULL); |
1051 | break; | 1054 | break; |
1052 | 1055 | ||
1053 | default: | 1056 | default: |
@@ -1313,7 +1316,8 @@ run (void *cls, | |||
1313 | #endif | 1316 | #endif |
1314 | { | 1317 | { |
1315 | cfg = c; | 1318 | cfg = c; |
1316 | end_badly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | 1319 | end_badly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
1320 | &end_badly, NULL); | ||
1317 | 1321 | ||
1318 | core = GNUNET_CORE_connect (cfg, NULL, &core_connected, NULL, NULL, | 1322 | core = GNUNET_CORE_connect (cfg, NULL, &core_connected, NULL, NULL, |
1319 | NULL, GNUNET_NO, NULL, GNUNET_NO, NULL); | 1323 | NULL, GNUNET_NO, NULL, GNUNET_NO, NULL); |
diff --git a/src/statistics/gnunet-service-statistics.c b/src/statistics/gnunet-service-statistics.c index 0126f149b..adec5a96d 100644 --- a/src/statistics/gnunet-service-statistics.c +++ b/src/statistics/gnunet-service-statistics.c | |||
@@ -1053,9 +1053,8 @@ run (void *cls, | |||
1053 | &handle_client_disconnect, | 1053 | &handle_client_disconnect, |
1054 | NULL); | 1054 | NULL); |
1055 | load (server); | 1055 | load (server); |
1056 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1056 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
1057 | &shutdown_task, | 1057 | NULL); |
1058 | NULL); | ||
1059 | } | 1058 | } |
1060 | 1059 | ||
1061 | 1060 | ||
diff --git a/src/statistics/gnunet-statistics.c b/src/statistics/gnunet-statistics.c index 2bf5959e3..f21da6059 100644 --- a/src/statistics/gnunet-statistics.c +++ b/src/statistics/gnunet-statistics.c | |||
@@ -180,7 +180,6 @@ shutdown_task (void *cls) | |||
180 | * Main task that does the actual work. | 180 | * Main task that does the actual work. |
181 | * | 181 | * |
182 | * @param cls closure with our configuration | 182 | * @param cls closure with our configuration |
183 | * @param tc schedueler context | ||
184 | */ | 183 | */ |
185 | static void | 184 | static void |
186 | main_task (void *cls) | 185 | main_task (void *cls) |
@@ -221,7 +220,8 @@ main_task (void *cls) | |||
221 | if (GNUNET_NO == watch) | 220 | if (GNUNET_NO == watch) |
222 | { | 221 | { |
223 | if (NULL == | 222 | if (NULL == |
224 | GNUNET_STATISTICS_get (h, subsystem, name, GET_TIMEOUT, &cleanup, | 223 | GNUNET_STATISTICS_get (h, subsystem, name, GET_TIMEOUT, |
224 | &cleanup, | ||
225 | &printer, h)) | 225 | &printer, h)) |
226 | cleanup (h, GNUNET_SYSERR); | 226 | cleanup (h, GNUNET_SYSERR); |
227 | } | 227 | } |
@@ -235,15 +235,15 @@ main_task (void *cls) | |||
235 | ret = 1; | 235 | ret = 1; |
236 | return; | 236 | return; |
237 | } | 237 | } |
238 | if (GNUNET_OK != GNUNET_STATISTICS_watch (h, subsystem, name, &printer, h)) | 238 | if (GNUNET_OK != GNUNET_STATISTICS_watch (h, subsystem, name, |
239 | &printer, h)) | ||
239 | { | 240 | { |
240 | fprintf (stderr, _("Failed to initialize watch routine\n")); | 241 | fprintf (stderr, _("Failed to initialize watch routine\n")); |
241 | GNUNET_SCHEDULER_add_now (&shutdown_task, h); | 242 | GNUNET_SCHEDULER_add_now (&shutdown_task, h); |
242 | return; | 243 | return; |
243 | } | 244 | } |
244 | } | 245 | } |
245 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 246 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, h); |
246 | &shutdown_task, h); | ||
247 | } | 247 | } |
248 | 248 | ||
249 | 249 | ||
diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c index 2b491df72..32b973eec 100644 --- a/src/statistics/statistics_api.c +++ b/src/statistics/statistics_api.c | |||
@@ -1217,7 +1217,8 @@ GNUNET_STATISTICS_get (struct GNUNET_STATISTICS_Handle *handle, | |||
1217 | ai->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, | 1217 | ai->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, |
1218 | &run_get_timeout, | 1218 | &run_get_timeout, |
1219 | ai); | 1219 | ai); |
1220 | GNUNET_CONTAINER_DLL_insert_tail (handle->action_head, handle->action_tail, | 1220 | GNUNET_CONTAINER_DLL_insert_tail (handle->action_head, |
1221 | handle->action_tail, | ||
1221 | ai); | 1222 | ai); |
1222 | schedule_action (handle); | 1223 | schedule_action (handle); |
1223 | return ai; | 1224 | return ai; |
diff --git a/src/statistics/test_statistics_api_watch.c b/src/statistics/test_statistics_api_watch.c index c7fe54b1f..9b004d1d5 100644 --- a/src/statistics/test_statistics_api_watch.c +++ b/src/statistics/test_statistics_api_watch.c | |||
@@ -55,7 +55,10 @@ normal_shutdown (void *cls) | |||
55 | 55 | ||
56 | 56 | ||
57 | static int | 57 | static int |
58 | watch_1 (void *cls, const char *subsystem, const char *name, uint64_t value, | 58 | watch_1 (void *cls, |
59 | const char *subsystem, | ||
60 | const char *name, | ||
61 | uint64_t value, | ||
59 | int is_persistent) | 62 | int is_persistent) |
60 | { | 63 | { |
61 | GNUNET_assert (value == 42); | 64 | GNUNET_assert (value == 42); |
@@ -71,7 +74,10 @@ watch_1 (void *cls, const char *subsystem, const char *name, uint64_t value, | |||
71 | 74 | ||
72 | 75 | ||
73 | static int | 76 | static int |
74 | watch_2 (void *cls, const char *subsystem, const char *name, uint64_t value, | 77 | watch_2 (void *cls, |
78 | const char *subsystem, | ||
79 | const char *name, | ||
80 | uint64_t value, | ||
75 | int is_persistent) | 81 | int is_persistent) |
76 | { | 82 | { |
77 | GNUNET_assert (value == 43); | 83 | GNUNET_assert (value == 43); |
@@ -87,7 +93,9 @@ watch_2 (void *cls, const char *subsystem, const char *name, uint64_t value, | |||
87 | 93 | ||
88 | 94 | ||
89 | static void | 95 | static void |
90 | run (void *cls, char *const *args, const char *cfgfile, | 96 | run (void *cls, |
97 | char *const *args, | ||
98 | const char *cfgfile, | ||
91 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 99 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
92 | { | 100 | { |
93 | h = GNUNET_STATISTICS_create ("dummy", cfg); | 101 | h = GNUNET_STATISTICS_create ("dummy", cfg); |
@@ -101,7 +109,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
101 | GNUNET_STATISTICS_set (h2, "test-1", 42, GNUNET_NO); | 109 | GNUNET_STATISTICS_set (h2, "test-1", 42, GNUNET_NO); |
102 | GNUNET_STATISTICS_set (h2, "test-2", 43, GNUNET_NO); | 110 | GNUNET_STATISTICS_set (h2, "test-2", 43, GNUNET_NO); |
103 | shutdown_task = | 111 | shutdown_task = |
104 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &force_shutdown, | 112 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, |
113 | &force_shutdown, | ||
105 | NULL); | 114 | NULL); |
106 | } | 115 | } |
107 | 116 | ||
diff --git a/src/template/gnunet-service-template.c b/src/template/gnunet-service-template.c index 556d44bd8..6ff63c073 100644 --- a/src/template/gnunet-service-template.c +++ b/src/template/gnunet-service-template.c | |||
@@ -47,7 +47,8 @@ cleanup_task (void *cls) | |||
47 | * @param cfg configuration to use | 47 | * @param cfg configuration to use |
48 | */ | 48 | */ |
49 | static void | 49 | static void |
50 | run (void *cls, struct GNUNET_SERVER_Handle *server, | 50 | run (void *cls, |
51 | struct GNUNET_SERVER_Handle *server, | ||
51 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 52 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
52 | { | 53 | { |
53 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { | 54 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { |
@@ -56,8 +57,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
56 | }; | 57 | }; |
57 | /* FIXME: do setup here */ | 58 | /* FIXME: do setup here */ |
58 | GNUNET_SERVER_add_handlers (server, handlers); | 59 | GNUNET_SERVER_add_handlers (server, handlers); |
59 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task, | 60 | GNUNET_SCHEDULER_add_shutdown (&cleanup_task, |
60 | NULL); | 61 | NULL); |
61 | } | 62 | } |
62 | 63 | ||
63 | 64 | ||
diff --git a/src/testbed/gnunet-daemon-latency-logger.c b/src/testbed/gnunet-daemon-latency-logger.c index 9652721a1..b2c7b1043 100644 --- a/src/testbed/gnunet-daemon-latency-logger.c +++ b/src/testbed/gnunet-daemon-latency-logger.c | |||
@@ -89,17 +89,12 @@ static struct sqlite3 *db; | |||
89 | /** | 89 | /** |
90 | * Handle to the ATS performance subsystem | 90 | * Handle to the ATS performance subsystem |
91 | */ | 91 | */ |
92 | struct GNUNET_ATS_PerformanceHandle *ats; | 92 | static struct GNUNET_ATS_PerformanceHandle *ats; |
93 | 93 | ||
94 | /** | 94 | /** |
95 | * Prepared statement for inserting values into the database table | 95 | * Prepared statement for inserting values into the database table |
96 | */ | 96 | */ |
97 | struct sqlite3_stmt *stmt_insert; | 97 | static struct sqlite3_stmt *stmt_insert; |
98 | |||
99 | /** | ||
100 | * Shutdown task identifier | ||
101 | */ | ||
102 | struct GNUNET_SCHEDULER_Task * shutdown_task; | ||
103 | 98 | ||
104 | 99 | ||
105 | /** | 100 | /** |
@@ -136,7 +131,6 @@ free_iterator (void *cls, | |||
136 | static void | 131 | static void |
137 | do_shutdown (void *cls) | 132 | do_shutdown (void *cls) |
138 | { | 133 | { |
139 | shutdown_task = NULL; | ||
140 | GNUNET_ATS_performance_done (ats); | 134 | GNUNET_ATS_performance_done (ats); |
141 | ats = NULL; | 135 | ats = NULL; |
142 | if (NULL != stmt_insert) | 136 | if (NULL != stmt_insert) |
@@ -298,8 +292,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
298 | dbfile = NULL; | 292 | dbfile = NULL; |
299 | ats = GNUNET_ATS_performance_init (c, &addr_info_cb, NULL); | 293 | ats = GNUNET_ATS_performance_init (c, &addr_info_cb, NULL); |
300 | map = GNUNET_CONTAINER_multipeermap_create (30, GNUNET_YES); | 294 | map = GNUNET_CONTAINER_multipeermap_create (30, GNUNET_YES); |
301 | shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 295 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
302 | &do_shutdown, NULL); | ||
303 | } | 296 | } |
304 | 297 | ||
305 | 298 | ||
diff --git a/src/testbed/gnunet-daemon-testbed-blacklist.c b/src/testbed/gnunet-daemon-testbed-blacklist.c index 0e0c7ebd5..0cb83aacf 100644 --- a/src/testbed/gnunet-daemon-testbed-blacklist.c +++ b/src/testbed/gnunet-daemon-testbed-blacklist.c | |||
@@ -67,12 +67,7 @@ static struct GNUNET_PeerIdentity *ilist; | |||
67 | * The blacklist handle we obtain from transport when we register ourselves for | 67 | * The blacklist handle we obtain from transport when we register ourselves for |
68 | * access control | 68 | * access control |
69 | */ | 69 | */ |
70 | struct GNUNET_TRANSPORT_Blacklist *bh; | 70 | static struct GNUNET_TRANSPORT_Blacklist *bh; |
71 | |||
72 | /** | ||
73 | * Task for shutdown | ||
74 | */ | ||
75 | static struct GNUNET_SCHEDULER_Task * shutdown_task; | ||
76 | 71 | ||
77 | /** | 72 | /** |
78 | * Are we allowing or denying access from peers | 73 | * Are we allowing or denying access from peers |
@@ -81,26 +76,6 @@ static int mode; | |||
81 | 76 | ||
82 | 77 | ||
83 | /** | 78 | /** |
84 | * @ingroup hashmap | ||
85 | * Iterator over hash map entries. | ||
86 | * | ||
87 | * @param cls closure | ||
88 | * @param key current key code | ||
89 | * @param value value in the hash map | ||
90 | * @return #GNUNET_YES if we should continue to | ||
91 | * iterate, | ||
92 | * #GNUNET_NO if not. | ||
93 | */ | ||
94 | static int | ||
95 | iterator (void *cls, const struct GNUNET_PeerIdentity *key, void *value) | ||
96 | { | ||
97 | GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multipeermap_remove (map, key, | ||
98 | value)); | ||
99 | return GNUNET_YES; | ||
100 | } | ||
101 | |||
102 | |||
103 | /** | ||
104 | * Cleaup and destroy the map | 79 | * Cleaup and destroy the map |
105 | */ | 80 | */ |
106 | static void | 81 | static void |
@@ -108,9 +83,6 @@ cleanup_map () | |||
108 | { | 83 | { |
109 | if (NULL != map) | 84 | if (NULL != map) |
110 | { | 85 | { |
111 | GNUNET_assert (GNUNET_SYSERR != GNUNET_CONTAINER_multipeermap_iterate (map, | ||
112 | &iterator, | ||
113 | NULL)); | ||
114 | GNUNET_CONTAINER_multipeermap_destroy (map); | 86 | GNUNET_CONTAINER_multipeermap_destroy (map); |
115 | map = NULL; | 87 | map = NULL; |
116 | } | 88 | } |
@@ -161,14 +133,16 @@ check_access (void *cls, const struct GNUNET_PeerIdentity * pid) | |||
161 | * @param cfg the configuration for connecting to the peer's transport service | 133 | * @param cfg the configuration for connecting to the peer's transport service |
162 | */ | 134 | */ |
163 | static void | 135 | static void |
164 | setup_ac (const char *fname, const struct GNUNET_CONFIGURATION_Handle *cfg) | 136 | setup_ac (const char *fname, |
137 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
165 | { | 138 | { |
166 | uint64_t fsize; | 139 | uint64_t fsize; |
167 | unsigned int npeers; | 140 | unsigned int npeers; |
168 | unsigned int cnt; | 141 | unsigned int cnt; |
169 | 142 | ||
170 | GNUNET_assert (GNUNET_OK != GNUNET_DISK_file_size (fname, &fsize, GNUNET_NO, | 143 | GNUNET_assert (GNUNET_OK != |
171 | GNUNET_YES)); | 144 | GNUNET_DISK_file_size (fname, &fsize, GNUNET_NO, |
145 | GNUNET_YES)); | ||
172 | if (0 != (fsize % sizeof (struct GNUNET_PeerIdentity))) | 146 | if (0 != (fsize % sizeof (struct GNUNET_PeerIdentity))) |
173 | { | 147 | { |
174 | GNUNET_break (0); | 148 | GNUNET_break (0); |
@@ -183,17 +157,17 @@ setup_ac (const char *fname, const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
183 | } | 157 | } |
184 | for (cnt = 0; cnt < npeers; cnt++) | 158 | for (cnt = 0; cnt < npeers; cnt++) |
185 | { | 159 | { |
186 | if (GNUNET_SYSERR == GNUNET_CONTAINER_multipeermap_put (map, &ilist[cnt], | 160 | if (GNUNET_SYSERR == |
187 | &ilist[cnt], | 161 | GNUNET_CONTAINER_multipeermap_put (map, &ilist[cnt], |
188 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) | 162 | &ilist[cnt], |
163 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) | ||
189 | { | 164 | { |
190 | cleanup_map (); | 165 | cleanup_map (); |
191 | GNUNET_free (ilist); | 166 | GNUNET_free (ilist); |
192 | return; | 167 | return; |
193 | } | 168 | } |
194 | } | 169 | } |
195 | shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 170 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
196 | &do_shutdown, NULL); | ||
197 | bh = GNUNET_TRANSPORT_blacklist (cfg, &check_access, NULL); | 171 | bh = GNUNET_TRANSPORT_blacklist (cfg, &check_access, NULL); |
198 | } | 172 | } |
199 | 173 | ||
@@ -207,15 +181,18 @@ setup_ac (const char *fname, const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
207 | * @param c configuration | 181 | * @param c configuration |
208 | */ | 182 | */ |
209 | static void | 183 | static void |
210 | run (void *cls, char *const *args, const char *cfgfile, | 184 | run (void *cls, |
185 | char *const *args, | ||
186 | const char *cfgfile, | ||
211 | const struct GNUNET_CONFIGURATION_Handle *c) | 187 | const struct GNUNET_CONFIGURATION_Handle *c) |
212 | { | 188 | { |
213 | char *shome; | 189 | char *shome; |
214 | char *fname; | 190 | char *fname; |
215 | 191 | ||
216 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (c, "PATHS", | 192 | if (GNUNET_OK != |
217 | "GNUNET_HOME", | 193 | GNUNET_CONFIGURATION_get_value_filename (c, "PATHS", |
218 | &shome)) | 194 | "GNUNET_HOME", |
195 | &shome)) | ||
219 | { | 196 | { |
220 | GNUNET_break (0); | 197 | GNUNET_break (0); |
221 | return; | 198 | return; |
@@ -260,13 +237,15 @@ main (int argc, char *const *argv) | |||
260 | }; | 237 | }; |
261 | int ret; | 238 | int ret; |
262 | 239 | ||
263 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 240 | if (GNUNET_OK != |
241 | GNUNET_STRINGS_get_utf8_args (argc, argv, | ||
242 | &argc, &argv)) | ||
264 | return 2; | 243 | return 2; |
265 | ret = | 244 | ret = |
266 | (GNUNET_OK == | 245 | (GNUNET_OK == |
267 | GNUNET_PROGRAM_run (argc, argv, "gnunet-daemon-testbed-blacklist", | 246 | GNUNET_PROGRAM_run (argc, argv, |
268 | _ | 247 | "gnunet-daemon-testbed-blacklist", |
269 | ("Daemon to restrict incoming transport layer connections during testbed deployments"), | 248 | _("Daemon to restrict incoming transport layer connections during testbed deployments"), |
270 | options, &run, NULL)) ? 0 : 1; | 249 | options, &run, NULL)) ? 0 : 1; |
271 | GNUNET_free ((void*) argv); | 250 | GNUNET_free ((void*) argv); |
272 | return ret; | 251 | return ret; |
diff --git a/src/testbed/gnunet-daemon-testbed-underlay.c b/src/testbed/gnunet-daemon-testbed-underlay.c index ce0cc46d9..663ab2d08 100644 --- a/src/testbed/gnunet-daemon-testbed-underlay.c +++ b/src/testbed/gnunet-daemon-testbed-underlay.c | |||
@@ -101,11 +101,6 @@ static struct GNUNET_TRANSPORT_Handle *transport; | |||
101 | */ | 101 | */ |
102 | static unsigned int num_hostkeys; | 102 | static unsigned int num_hostkeys; |
103 | 103 | ||
104 | /** | ||
105 | * Task for shutdown | ||
106 | */ | ||
107 | static struct GNUNET_SCHEDULER_Task * shutdown_task; | ||
108 | |||
109 | 104 | ||
110 | /** | 105 | /** |
111 | * @ingroup hashmap | 106 | * @ingroup hashmap |
@@ -439,12 +434,10 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
439 | GNUNET_free (wl_entry); | 434 | GNUNET_free (wl_entry); |
440 | } | 435 | } |
441 | bh = GNUNET_TRANSPORT_blacklist (c, &check_access, NULL); | 436 | bh = GNUNET_TRANSPORT_blacklist (c, &check_access, NULL); |
442 | shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 437 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
443 | &do_shutdown, NULL); | ||
444 | 438 | ||
445 | close_db: | 439 | close_db: |
446 | GNUNET_break (SQLITE_OK == sqlite3_close (db)); | 440 | GNUNET_break (SQLITE_OK == sqlite3_close (db)); |
447 | return; | ||
448 | } | 441 | } |
449 | 442 | ||
450 | 443 | ||
diff --git a/src/testbed/gnunet-helper-testbed.c b/src/testbed/gnunet-helper-testbed.c index b43f10983..e27e21588 100644 --- a/src/testbed/gnunet-helper-testbed.c +++ b/src/testbed/gnunet-helper-testbed.c | |||
@@ -124,12 +124,12 @@ static struct GNUNET_DISK_PipeHandle *sigpipe; | |||
124 | /** | 124 | /** |
125 | * Task identifier for the read task | 125 | * Task identifier for the read task |
126 | */ | 126 | */ |
127 | static struct GNUNET_SCHEDULER_Task * read_task_id; | 127 | static struct GNUNET_SCHEDULER_Task *read_task_id; |
128 | 128 | ||
129 | /** | 129 | /** |
130 | * Task identifier for the write task | 130 | * Task identifier for the write task |
131 | */ | 131 | */ |
132 | static struct GNUNET_SCHEDULER_Task * write_task_id; | 132 | static struct GNUNET_SCHEDULER_Task *write_task_id; |
133 | 133 | ||
134 | /** | 134 | /** |
135 | * Task to kill the child | 135 | * Task to kill the child |
@@ -137,11 +137,6 @@ static struct GNUNET_SCHEDULER_Task * write_task_id; | |||
137 | static struct GNUNET_SCHEDULER_Task * child_death_task_id; | 137 | static struct GNUNET_SCHEDULER_Task * child_death_task_id; |
138 | 138 | ||
139 | /** | 139 | /** |
140 | * shutdown task id | ||
141 | */ | ||
142 | static struct GNUNET_SCHEDULER_Task * shutdown_task_id; | ||
143 | |||
144 | /** | ||
145 | * Are we done reading messages from stdin? | 140 | * Are we done reading messages from stdin? |
146 | */ | 141 | */ |
147 | static int done_reading; | 142 | static int done_reading; |
@@ -161,7 +156,6 @@ static void | |||
161 | shutdown_task (void *cls) | 156 | shutdown_task (void *cls) |
162 | { | 157 | { |
163 | LOG_DEBUG ("Shutting down\n"); | 158 | LOG_DEBUG ("Shutting down\n"); |
164 | shutdown_task_id = NULL; | ||
165 | if (NULL != testbed) | 159 | if (NULL != testbed) |
166 | { | 160 | { |
167 | LOG_DEBUG ("Killing testbed\n"); | 161 | LOG_DEBUG ("Killing testbed\n"); |
@@ -174,8 +168,12 @@ shutdown_task (void *cls) | |||
174 | } | 168 | } |
175 | if (NULL != write_task_id) | 169 | if (NULL != write_task_id) |
176 | { | 170 | { |
177 | GNUNET_SCHEDULER_cancel (write_task_id); | 171 | struct WriteContext *wc; |
172 | |||
173 | wc = GNUNET_SCHEDULER_cancel (write_task_id); | ||
178 | write_task_id = NULL; | 174 | write_task_id = NULL; |
175 | GNUNET_free (wc->data); | ||
176 | GNUNET_free (wc); | ||
179 | } | 177 | } |
180 | if (NULL != child_death_task_id) | 178 | if (NULL != child_death_task_id) |
181 | { | 179 | { |
@@ -203,18 +201,6 @@ shutdown_task (void *cls) | |||
203 | 201 | ||
204 | 202 | ||
205 | /** | 203 | /** |
206 | * Scheduler shutdown task to be run now. | ||
207 | */ | ||
208 | static void | ||
209 | shutdown_now (void) | ||
210 | { | ||
211 | if (NULL != shutdown_task_id) | ||
212 | GNUNET_SCHEDULER_cancel (shutdown_task_id); | ||
213 | shutdown_task_id = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | ||
214 | } | ||
215 | |||
216 | |||
217 | /** | ||
218 | * Task to write to the standard out | 204 | * Task to write to the standard out |
219 | * | 205 | * |
220 | * @param cls the WriteContext | 206 | * @param cls the WriteContext |
@@ -224,23 +210,16 @@ write_task (void *cls) | |||
224 | { | 210 | { |
225 | struct WriteContext *wc = cls; | 211 | struct WriteContext *wc = cls; |
226 | ssize_t bytes_wrote; | 212 | ssize_t bytes_wrote; |
227 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
228 | 213 | ||
229 | GNUNET_assert (NULL != wc); | 214 | GNUNET_assert (NULL != wc); |
230 | write_task_id = NULL; | 215 | write_task_id = NULL; |
231 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
232 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | ||
233 | { | ||
234 | GNUNET_free (wc->data); | ||
235 | GNUNET_free (wc); | ||
236 | return; | ||
237 | } | ||
238 | bytes_wrote = | 216 | bytes_wrote = |
239 | GNUNET_DISK_file_write (stdout_fd, wc->data + wc->pos, | 217 | GNUNET_DISK_file_write (stdout_fd, wc->data + wc->pos, |
240 | wc->length - wc->pos); | 218 | wc->length - wc->pos); |
241 | if (GNUNET_SYSERR == bytes_wrote) | 219 | if (GNUNET_SYSERR == bytes_wrote) |
242 | { | 220 | { |
243 | LOG (GNUNET_ERROR_TYPE_WARNING, "Cannot reply back configuration\n"); | 221 | LOG (GNUNET_ERROR_TYPE_WARNING, |
222 | "Cannot reply back configuration\n"); | ||
244 | GNUNET_free (wc->data); | 223 | GNUNET_free (wc->data); |
245 | GNUNET_free (wc); | 224 | GNUNET_free (wc); |
246 | return; | 225 | return; |
@@ -253,7 +232,8 @@ write_task (void *cls) | |||
253 | return; | 232 | return; |
254 | } | 233 | } |
255 | write_task_id = | 234 | write_task_id = |
256 | GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, stdout_fd, | 235 | GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, |
236 | stdout_fd, | ||
257 | &write_task, wc); | 237 | &write_task, wc); |
258 | } | 238 | } |
259 | 239 | ||
@@ -272,18 +252,9 @@ child_death_task (void *cls) | |||
272 | enum GNUNET_OS_ProcessStatusType type; | 252 | enum GNUNET_OS_ProcessStatusType type; |
273 | unsigned long code; | 253 | unsigned long code; |
274 | int ret; | 254 | int ret; |
275 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
276 | 255 | ||
277 | pr = GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ); | 256 | pr = GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ); |
278 | child_death_task_id = NULL; | 257 | child_death_task_id = NULL; |
279 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
280 | if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) | ||
281 | { | ||
282 | child_death_task_id = | ||
283 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | ||
284 | pr, &child_death_task, NULL); | ||
285 | return; | ||
286 | } | ||
287 | /* consume the signal */ | 258 | /* consume the signal */ |
288 | GNUNET_break (0 < GNUNET_DISK_file_read (pr, &c, sizeof (c))); | 259 | GNUNET_break (0 < GNUNET_DISK_file_read (pr, &c, sizeof (c))); |
289 | LOG_DEBUG ("Got SIGCHLD\n"); | 260 | LOG_DEBUG ("Got SIGCHLD\n"); |
@@ -302,7 +273,7 @@ child_death_task (void *cls) | |||
302 | if (0 != PLIBC_KILL (0, GNUNET_TERM_SIG)) | 273 | if (0 != PLIBC_KILL (0, GNUNET_TERM_SIG)) |
303 | { | 274 | { |
304 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "signal"); | 275 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "signal"); |
305 | shutdown_now (); /* Couldn't send the signal, we shutdown frowning */ | 276 | GNUNET_SCHEDULER_shutdown (); /* Couldn't send the signal, we shutdown frowning */ |
306 | } | 277 | } |
307 | return; | 278 | return; |
308 | } | 279 | } |
@@ -499,7 +470,8 @@ tokenizer_cb (void *cls, void *client, | |||
499 | reply->config_size = htons ((uint16_t) config_size); | 470 | reply->config_size = htons ((uint16_t) config_size); |
500 | wc->data = reply; | 471 | wc->data = reply; |
501 | write_task_id = | 472 | write_task_id = |
502 | GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, stdout_fd, | 473 | GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, |
474 | stdout_fd, | ||
503 | &write_task, wc); | 475 | &write_task, wc); |
504 | child_death_task_id = | 476 | child_death_task_id = |
505 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | 477 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
@@ -510,7 +482,7 @@ tokenizer_cb (void *cls, void *client, | |||
510 | 482 | ||
511 | error: | 483 | error: |
512 | status = GNUNET_SYSERR; | 484 | status = GNUNET_SYSERR; |
513 | shutdown_now (); | 485 | GNUNET_SCHEDULER_shutdown (); |
514 | return GNUNET_SYSERR; | 486 | return GNUNET_SYSERR; |
515 | } | 487 | } |
516 | 488 | ||
@@ -525,24 +497,20 @@ read_task (void *cls) | |||
525 | { | 497 | { |
526 | char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE]; | 498 | char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE]; |
527 | ssize_t sread; | 499 | ssize_t sread; |
528 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
529 | 500 | ||
530 | read_task_id = NULL; | 501 | read_task_id = NULL; |
531 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
532 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | ||
533 | return; | ||
534 | sread = GNUNET_DISK_file_read (stdin_fd, buf, sizeof (buf)); | 502 | sread = GNUNET_DISK_file_read (stdin_fd, buf, sizeof (buf)); |
535 | if ((GNUNET_SYSERR == sread) || (0 == sread)) | 503 | if ((GNUNET_SYSERR == sread) || (0 == sread)) |
536 | { | 504 | { |
537 | LOG_DEBUG ("STDIN closed\n"); | 505 | LOG_DEBUG ("STDIN closed\n"); |
538 | shutdown_now (); | 506 | GNUNET_SCHEDULER_shutdown (); |
539 | return; | 507 | return; |
540 | } | 508 | } |
541 | if (GNUNET_YES == done_reading) | 509 | if (GNUNET_YES == done_reading) |
542 | { | 510 | { |
543 | /* didn't expect any more data! */ | 511 | /* didn't expect any more data! */ |
544 | GNUNET_break_op (0); | 512 | GNUNET_break_op (0); |
545 | shutdown_now (); | 513 | GNUNET_SCHEDULER_shutdown (); |
546 | return; | 514 | return; |
547 | } | 515 | } |
548 | LOG_DEBUG ("Read %u bytes\n", sread); | 516 | LOG_DEBUG ("Read %u bytes\n", sread); |
@@ -551,11 +519,12 @@ read_task (void *cls) | |||
551 | GNUNET_NO)) | 519 | GNUNET_NO)) |
552 | { | 520 | { |
553 | GNUNET_break (0); | 521 | GNUNET_break (0); |
554 | shutdown_now (); | 522 | GNUNET_SCHEDULER_shutdown (); |
555 | return; | 523 | return; |
556 | } | 524 | } |
557 | read_task_id = /* No timeout while reading */ | 525 | read_task_id = /* No timeout while reading */ |
558 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, stdin_fd, | 526 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
527 | stdin_fd, | ||
559 | &read_task, NULL); | 528 | &read_task, NULL); |
560 | } | 529 | } |
561 | 530 | ||
@@ -569,7 +538,9 @@ read_task (void *cls) | |||
569 | * @param cfg configuration | 538 | * @param cfg configuration |
570 | */ | 539 | */ |
571 | static void | 540 | static void |
572 | run (void *cls, char *const *args, const char *cfgfile, | 541 | run (void *cls, |
542 | char *const *args, | ||
543 | const char *cfgfile, | ||
573 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 544 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
574 | { | 545 | { |
575 | LOG_DEBUG ("Starting testbed helper...\n"); | 546 | LOG_DEBUG ("Starting testbed helper...\n"); |
@@ -577,11 +548,11 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
577 | stdin_fd = GNUNET_DISK_get_handle_from_native (stdin); | 548 | stdin_fd = GNUNET_DISK_get_handle_from_native (stdin); |
578 | stdout_fd = GNUNET_DISK_get_handle_from_native (stdout); | 549 | stdout_fd = GNUNET_DISK_get_handle_from_native (stdout); |
579 | read_task_id = | 550 | read_task_id = |
580 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, stdin_fd, | 551 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
552 | stdin_fd, | ||
581 | &read_task, NULL); | 553 | &read_task, NULL); |
582 | shutdown_task_id = | 554 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
583 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 555 | NULL); |
584 | NULL); | ||
585 | } | 556 | } |
586 | 557 | ||
587 | 558 | ||
diff --git a/src/testbed/gnunet-service-test-barriers.c b/src/testbed/gnunet-service-test-barriers.c index 281172cbf..ce5249696 100644 --- a/src/testbed/gnunet-service-test-barriers.c +++ b/src/testbed/gnunet-service-test-barriers.c | |||
@@ -39,7 +39,9 @@ | |||
39 | /** | 39 | /** |
40 | * Our barrier wait handle | 40 | * Our barrier wait handle |
41 | */ | 41 | */ |
42 | struct GNUNET_TESTBED_BarrierWaitHandle *wh; | 42 | static struct GNUNET_TESTBED_BarrierWaitHandle *wh; |
43 | |||
44 | static struct GNUNET_SCHEDULER_Task *tt; | ||
43 | 45 | ||
44 | 46 | ||
45 | /** | 47 | /** |
@@ -51,8 +53,15 @@ static void | |||
51 | do_shutdown (void *cls) | 53 | do_shutdown (void *cls) |
52 | { | 54 | { |
53 | if (NULL != wh) | 55 | if (NULL != wh) |
56 | { | ||
54 | GNUNET_TESTBED_barrier_wait_cancel (wh); | 57 | GNUNET_TESTBED_barrier_wait_cancel (wh); |
55 | wh = NULL; | 58 | wh = NULL; |
59 | } | ||
60 | if (NULL != tt) | ||
61 | { | ||
62 | GNUNET_SCHEDULER_cancel (tt); | ||
63 | tt = NULL; | ||
64 | } | ||
56 | } | 65 | } |
57 | 66 | ||
58 | 67 | ||
@@ -63,8 +72,8 @@ do_shutdown (void *cls) | |||
63 | * | 72 | * |
64 | * @param cls NULL | 73 | * @param cls NULL |
65 | * @param name the barrier name | 74 | * @param name the barrier name |
66 | * @param status GNUNET_SYSERR in case of error while waiting for the barrier; | 75 | * @param status #GNUNET_SYSERR in case of error while waiting for the barrier; |
67 | * GNUNET_OK if the barrier is crossed | 76 | * #GNUNET_OK if the barrier is crossed |
68 | */ | 77 | */ |
69 | static void | 78 | static void |
70 | barrier_wait_cb (void *cls, const char *name, int status) | 79 | barrier_wait_cb (void *cls, const char *name, int status) |
@@ -84,12 +93,10 @@ barrier_wait_cb (void *cls, const char *name, int status) | |||
84 | static void | 93 | static void |
85 | do_wait (void *cls) | 94 | do_wait (void *cls) |
86 | { | 95 | { |
87 | const struct GNUNET_SCHEDULER_TaskContext *tc; | 96 | tt = NULL; |
88 | 97 | wh = GNUNET_TESTBED_barrier_wait (TEST_BARRIER_NAME, | |
89 | tc = GNUNET_SCHEDULER_get_task_context (); | 98 | &barrier_wait_cb, |
90 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | 99 | NULL); |
91 | return; | ||
92 | wh = GNUNET_TESTBED_barrier_wait (TEST_BARRIER_NAME, &barrier_wait_cb, NULL); | ||
93 | GNUNET_break (NULL != wh); | 100 | GNUNET_break (NULL != wh); |
94 | } | 101 | } |
95 | 102 | ||
@@ -103,17 +110,18 @@ do_wait (void *cls) | |||
103 | * @param config the configuration file handle | 110 | * @param config the configuration file handle |
104 | */ | 111 | */ |
105 | static void | 112 | static void |
106 | run (void *cls, char *const *args, const char *cfgfile, | 113 | run (void *cls, |
114 | char *const *args, | ||
115 | const char *cfgfile, | ||
107 | const struct GNUNET_CONFIGURATION_Handle *config) | 116 | const struct GNUNET_CONFIGURATION_Handle *config) |
108 | { | 117 | { |
109 | unsigned int rsec; | 118 | unsigned int rsec; |
110 | 119 | ||
111 | rsec = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, 10); | 120 | rsec = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, 10); |
112 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 121 | tt = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
113 | (GNUNET_TIME_UNIT_SECONDS, rsec), | 122 | (GNUNET_TIME_UNIT_SECONDS, rsec), |
114 | &do_wait, NULL); | 123 | &do_wait, NULL); |
115 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 124 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
116 | &do_shutdown, NULL); | ||
117 | } | 125 | } |
118 | 126 | ||
119 | 127 | ||
@@ -121,7 +129,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
121 | /** | 129 | /** |
122 | * Main | 130 | * Main |
123 | */ | 131 | */ |
124 | int main (int argc, char **argv) | 132 | int |
133 | main (int argc, char **argv) | ||
125 | { | 134 | { |
126 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 135 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
127 | GNUNET_GETOPT_OPTION_END | 136 | GNUNET_GETOPT_OPTION_END |
diff --git a/src/testbed/gnunet-service-testbed-logger.c b/src/testbed/gnunet-service-testbed-logger.c index ab5b17460..0f9fab01b 100644 --- a/src/testbed/gnunet-service-testbed-logger.c +++ b/src/testbed/gnunet-service-testbed-logger.c | |||
@@ -81,11 +81,6 @@ static struct MessageQueue *mq_tail; | |||
81 | struct GNUNET_BIO_WriteHandle *bio; | 81 | struct GNUNET_BIO_WriteHandle *bio; |
82 | 82 | ||
83 | /** | 83 | /** |
84 | * The shutdown task handle | ||
85 | */ | ||
86 | static struct GNUNET_SCHEDULER_Task * shutdown_task_id; | ||
87 | |||
88 | /** | ||
89 | * The number of connections we have | 84 | * The number of connections we have |
90 | */ | 85 | */ |
91 | static unsigned int nconn; | 86 | static unsigned int nconn; |
@@ -95,15 +90,17 @@ static unsigned int nconn; | |||
95 | */ | 90 | */ |
96 | static int in_shutdown; | 91 | static int in_shutdown; |
97 | 92 | ||
93 | |||
98 | /** | 94 | /** |
99 | * Message handler for GNUNET_MESSAGE_TYPE_TESTBED_ADDHOST messages | 95 | * Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_ADDHOST messages |
100 | * | 96 | * |
101 | * @param cls NULL | 97 | * @param cls NULL |
102 | * @param client identification of the client | 98 | * @param client identification of the client |
103 | * @param msg the actual message | 99 | * @param msg the actual message |
104 | */ | 100 | */ |
105 | static void | 101 | static void |
106 | handle_log_msg (void *cls, struct GNUNET_SERVER_Client *client, | 102 | handle_log_msg (void *cls, |
103 | struct GNUNET_SERVER_Client *client, | ||
107 | const struct GNUNET_MessageHeader *msg) | 104 | const struct GNUNET_MessageHeader *msg) |
108 | { | 105 | { |
109 | uint16_t ms; | 106 | uint16_t ms; |
@@ -125,21 +122,20 @@ shutdown_task (void *cls) | |||
125 | { | 122 | { |
126 | struct MessageQueue *mq_entry; | 123 | struct MessageQueue *mq_entry; |
127 | 124 | ||
128 | shutdown_task_id = NULL; | ||
129 | in_shutdown = GNUNET_YES; | 125 | in_shutdown = GNUNET_YES; |
130 | if (0 != nconn) | 126 | if (0 != nconn) |
131 | { | 127 | { |
132 | /* Delay shutdown if there are active connections */ | 128 | /* Delay shutdown if there are active connections */ |
133 | shutdown_task_id = GNUNET_SCHEDULER_add_delayed | 129 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
134 | (GNUNET_TIME_UNIT_FOREVER_REL, | ||
135 | &shutdown_task, NULL); | ||
136 | return; | 130 | return; |
137 | } | 131 | } |
138 | while (NULL != (mq_entry = mq_head)) | 132 | while (NULL != (mq_entry = mq_head)) |
139 | { | 133 | { |
140 | GNUNET_free (mq_entry->msg); | 134 | GNUNET_free (mq_entry->msg); |
141 | GNUNET_SERVER_client_drop (mq_entry->client); | 135 | GNUNET_SERVER_client_drop (mq_entry->client); |
142 | GNUNET_CONTAINER_DLL_remove (mq_head, mq_tail, mq_entry); | 136 | GNUNET_CONTAINER_DLL_remove (mq_head, |
137 | mq_tail, | ||
138 | mq_entry); | ||
143 | GNUNET_free (mq_entry); | 139 | GNUNET_free (mq_entry); |
144 | } | 140 | } |
145 | GNUNET_break (GNUNET_OK == GNUNET_BIO_write_close (bio)); | 141 | GNUNET_break (GNUNET_OK == GNUNET_BIO_write_close (bio)); |
@@ -147,7 +143,7 @@ shutdown_task (void *cls) | |||
147 | 143 | ||
148 | 144 | ||
149 | /** | 145 | /** |
150 | * Functions with this signature are called whenever a client | 146 | x * Functions with this signature are called whenever a client |
151 | * is disconnected on the network level. | 147 | * is disconnected on the network level. |
152 | * | 148 | * |
153 | * @param cls closure | 149 | * @param cls closure |
@@ -155,7 +151,8 @@ shutdown_task (void *cls) | |||
155 | * for the last call when the server is destroyed | 151 | * for the last call when the server is destroyed |
156 | */ | 152 | */ |
157 | static void | 153 | static void |
158 | client_disconnected (void *cls, struct GNUNET_SERVER_Client *client) | 154 | client_disconnected (void *cls, |
155 | struct GNUNET_SERVER_Client *client) | ||
159 | { | 156 | { |
160 | if (NULL == client) | 157 | if (NULL == client) |
161 | { | 158 | { |
@@ -163,11 +160,8 @@ client_disconnected (void *cls, struct GNUNET_SERVER_Client *client) | |||
163 | return; | 160 | return; |
164 | } | 161 | } |
165 | nconn--; | 162 | nconn--; |
166 | if (GNUNET_YES != in_shutdown) | 163 | if (GNUNET_YES == in_shutdown) |
167 | return; | 164 | GNUNET_SCHEDULER_shutdown (); |
168 | GNUNET_assert (NULL != shutdown_task_id); | ||
169 | GNUNET_SCHEDULER_cancel (shutdown_task_id); | ||
170 | shutdown_task_id = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | ||
171 | } | 165 | } |
172 | 166 | ||
173 | 167 | ||
@@ -179,7 +173,8 @@ client_disconnected (void *cls, struct GNUNET_SERVER_Client *client) | |||
179 | * @param client identification of the client | 173 | * @param client identification of the client |
180 | */ | 174 | */ |
181 | static void | 175 | static void |
182 | client_connected (void *cls, struct GNUNET_SERVER_Client *client) | 176 | client_connected (void *cls, |
177 | struct GNUNET_SERVER_Client *client) | ||
183 | { | 178 | { |
184 | if (NULL == client) | 179 | if (NULL == client) |
185 | { | 180 | { |
@@ -199,8 +194,9 @@ client_connected (void *cls, struct GNUNET_SERVER_Client *client) | |||
199 | * @param cfg configuration to use | 194 | * @param cfg configuration to use |
200 | */ | 195 | */ |
201 | static void | 196 | static void |
202 | logger_run (void *cls, struct GNUNET_SERVER_Handle *server, | 197 | logger_run (void *cls, |
203 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 198 | struct GNUNET_SERVER_Handle *server, |
199 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
204 | { | 200 | { |
205 | static const struct GNUNET_SERVER_MessageHandler message_handlers[] = { | 201 | static const struct GNUNET_SERVER_MessageHandler message_handlers[] = { |
206 | {&handle_log_msg, NULL, GNUNET_MESSAGE_TYPE_TESTBED_LOGGER_MSG, 0}, | 202 | {&handle_log_msg, NULL, GNUNET_MESSAGE_TYPE_TESTBED_LOGGER_MSG, 0}, |
@@ -213,10 +209,14 @@ logger_run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
213 | pid_t pid; | 209 | pid_t pid; |
214 | 210 | ||
215 | if (GNUNET_OK != | 211 | if (GNUNET_OK != |
216 | GNUNET_CONFIGURATION_get_value_filename (cfg, "TESTBED-LOGGER", "DIR", | 212 | GNUNET_CONFIGURATION_get_value_filename (cfg, |
213 | "TESTBED-LOGGER", | ||
214 | "DIR", | ||
217 | &dir)) | 215 | &dir)) |
218 | { | 216 | { |
219 | LOG (GNUNET_ERROR_TYPE_ERROR, "Not logging directory definied. Exiting\n"); | 217 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, |
218 | "TESTBED-LOGGER", | ||
219 | "DIR"); | ||
220 | GNUNET_SCHEDULER_shutdown (); | 220 | GNUNET_SCHEDULER_shutdown (); |
221 | return; | 221 | return; |
222 | } | 222 | } |
@@ -225,14 +225,19 @@ logger_run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
225 | hname = GNUNET_malloc (hname_len); | 225 | hname = GNUNET_malloc (hname_len); |
226 | if (0 != gethostname (hname, hname_len)) | 226 | if (0 != gethostname (hname, hname_len)) |
227 | { | 227 | { |
228 | LOG (GNUNET_ERROR_TYPE_ERROR, "Cannot get hostname. Exiting\n"); | 228 | LOG (GNUNET_ERROR_TYPE_ERROR, |
229 | "Cannot get hostname. Exiting\n"); | ||
229 | GNUNET_free (hname); | 230 | GNUNET_free (hname); |
230 | GNUNET_free (dir); | 231 | GNUNET_free (dir); |
231 | GNUNET_SCHEDULER_shutdown (); | 232 | GNUNET_SCHEDULER_shutdown (); |
232 | return; | 233 | return; |
233 | } | 234 | } |
234 | (void) GNUNET_asprintf (&fn, "%s/%.*s_%jd.dat", dir, hname_len, hname, | 235 | GNUNET_asprintf (&fn, |
235 | (intmax_t) pid); | 236 | "%s/%.*s_%jd.dat", |
237 | dir, | ||
238 | hname_len, | ||
239 | hname, | ||
240 | (intmax_t) pid); | ||
236 | GNUNET_free (hname); | 241 | GNUNET_free (hname); |
237 | GNUNET_free (dir); | 242 | GNUNET_free (dir); |
238 | if (NULL == (bio = GNUNET_BIO_write_open (fn))) | 243 | if (NULL == (bio = GNUNET_BIO_write_open (fn))) |
@@ -245,9 +250,7 @@ logger_run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
245 | GNUNET_SERVER_add_handlers (server, message_handlers); | 250 | GNUNET_SERVER_add_handlers (server, message_handlers); |
246 | GNUNET_SERVER_connect_notify (server, &client_connected, NULL); | 251 | GNUNET_SERVER_connect_notify (server, &client_connected, NULL); |
247 | GNUNET_SERVER_disconnect_notify (server, &client_disconnected, NULL); | 252 | GNUNET_SERVER_disconnect_notify (server, &client_disconnected, NULL); |
248 | shutdown_task_id = | 253 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
249 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | ||
250 | &shutdown_task, NULL); | ||
251 | LOG_DEBUG ("TESTBED-LOGGER startup complete\n"); | 254 | LOG_DEBUG ("TESTBED-LOGGER startup complete\n"); |
252 | } | 255 | } |
253 | 256 | ||
@@ -258,11 +261,10 @@ logger_run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
258 | int | 261 | int |
259 | main (int argc, char *const *argv) | 262 | main (int argc, char *const *argv) |
260 | { | 263 | { |
261 | //sleep (15); /* Debugging */ | ||
262 | return (GNUNET_OK == | 264 | return (GNUNET_OK == |
263 | GNUNET_SERVICE_run (argc, argv, "testbed-logger", | 265 | GNUNET_SERVICE_run (argc, argv, "testbed-logger", |
264 | GNUNET_SERVICE_OPTION_NONE, | 266 | GNUNET_SERVICE_OPTION_NONE, |
265 | &logger_run, NULL)) ? 0 : 1; | 267 | &logger_run, NULL)) ? 0 : 1; |
266 | } | 268 | } |
267 | 269 | ||
268 | /* end of gnunet-service-testbed.c */ | 270 | /* end of gnunet-service-testbed-logger.c */ |
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c index e4fe87fcd..8a286742c 100644 --- a/src/testbed/gnunet-service-testbed.c +++ b/src/testbed/gnunet-service-testbed.c | |||
@@ -130,12 +130,6 @@ static struct MessageQueue *mq_tail; | |||
130 | 130 | ||
131 | 131 | ||
132 | /** | 132 | /** |
133 | * The shutdown task handle | ||
134 | */ | ||
135 | static struct GNUNET_SCHEDULER_Task * shutdown_task_id; | ||
136 | |||
137 | |||
138 | /** | ||
139 | * Function called to notify a client about the connection begin ready to queue | 133 | * Function called to notify a client about the connection begin ready to queue |
140 | * more data. "buf" will be NULL and "size" zero if the connection was closed | 134 | * more data. "buf" will be NULL and "size" zero if the connection was closed |
141 | * for writing in the meantime. | 135 | * for writing in the meantime. |
@@ -480,7 +474,8 @@ parse_shared_services (char *ss_str, struct GNUNET_CONFIGURATION_Handle *cfg) | |||
480 | * @param message the actual message | 474 | * @param message the actual message |
481 | */ | 475 | */ |
482 | static void | 476 | static void |
483 | handle_init (void *cls, struct GNUNET_SERVER_Client *client, | 477 | handle_init (void *cls, |
478 | struct GNUNET_SERVER_Client *client, | ||
484 | const struct GNUNET_MessageHeader *message) | 479 | const struct GNUNET_MessageHeader *message) |
485 | { | 480 | { |
486 | const struct GNUNET_TESTBED_InitMessage *msg; | 481 | const struct GNUNET_TESTBED_InitMessage *msg; |
@@ -553,14 +548,15 @@ handle_init (void *cls, struct GNUNET_SERVER_Client *client, | |||
553 | 548 | ||
554 | 549 | ||
555 | /** | 550 | /** |
556 | * Message handler for GNUNET_MESSAGE_TYPE_TESTBED_ADDHOST messages | 551 | * Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_ADDHOST messages |
557 | * | 552 | * |
558 | * @param cls NULL | 553 | * @param cls NULL |
559 | * @param client identification of the client | 554 | * @param client identification of the client |
560 | * @param message the actual message | 555 | * @param message the actual message |
561 | */ | 556 | */ |
562 | static void | 557 | static void |
563 | handle_add_host (void *cls, struct GNUNET_SERVER_Client *client, | 558 | handle_add_host (void *cls, |
559 | struct GNUNET_SERVER_Client *client, | ||
564 | const struct GNUNET_MessageHeader *message) | 560 | const struct GNUNET_MessageHeader *message) |
565 | { | 561 | { |
566 | struct GNUNET_TESTBED_Host *host; | 562 | struct GNUNET_TESTBED_Host *host; |
@@ -669,14 +665,15 @@ handle_add_host (void *cls, struct GNUNET_SERVER_Client *client, | |||
669 | 665 | ||
670 | 666 | ||
671 | /** | 667 | /** |
672 | * Handler for GNUNET_MESSAGE_TYPE_TESTBED_GETSLAVECONFIG messages | 668 | * Handler for #GNUNET_MESSAGE_TYPE_TESTBED_GETSLAVECONFIG messages |
673 | * | 669 | * |
674 | * @param cls NULL | 670 | * @param cls NULL |
675 | * @param client identification of the client | 671 | * @param client identification of the client |
676 | * @param message the actual message | 672 | * @param message the actual message |
677 | */ | 673 | */ |
678 | static void | 674 | static void |
679 | handle_slave_get_config (void *cls, struct GNUNET_SERVER_Client *client, | 675 | handle_slave_get_config (void *cls, |
676 | struct GNUNET_SERVER_Client *client, | ||
680 | const struct GNUNET_MessageHeader *message) | 677 | const struct GNUNET_MessageHeader *message) |
681 | { | 678 | { |
682 | struct GNUNET_TESTBED_SlaveGetConfigurationMessage *msg; | 679 | struct GNUNET_TESTBED_SlaveGetConfigurationMessage *msg; |
@@ -781,7 +778,6 @@ shutdown_task (void *cls) | |||
781 | struct MessageQueue *mq_entry; | 778 | struct MessageQueue *mq_entry; |
782 | uint32_t id; | 779 | uint32_t id; |
783 | 780 | ||
784 | shutdown_task_id = NULL; | ||
785 | LOG_DEBUG ("Shutting down testbed service\n"); | 781 | LOG_DEBUG ("Shutting down testbed service\n"); |
786 | /* cleanup any remaining forwarded operations */ | 782 | /* cleanup any remaining forwarded operations */ |
787 | GST_clear_fopcq (); | 783 | GST_clear_fopcq (); |
@@ -939,10 +935,7 @@ testbed_run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
939 | GST_config = GNUNET_CONFIGURATION_dup (cfg); | 935 | GST_config = GNUNET_CONFIGURATION_dup (cfg); |
940 | GNUNET_SERVER_add_handlers (server, message_handlers); | 936 | GNUNET_SERVER_add_handlers (server, message_handlers); |
941 | GNUNET_SERVER_disconnect_notify (server, &client_disconnect_cb, NULL); | 937 | GNUNET_SERVER_disconnect_notify (server, &client_disconnect_cb, NULL); |
942 | shutdown_task_id = | 938 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
943 | GNUNET_SCHEDULER_add_delayed_with_priority (GNUNET_TIME_UNIT_FOREVER_REL, | ||
944 | GNUNET_SCHEDULER_PRIORITY_IDLE, | ||
945 | &shutdown_task, NULL); | ||
946 | LOG_DEBUG ("Testbed startup complete\n"); | 939 | LOG_DEBUG ("Testbed startup complete\n"); |
947 | GST_stats_init (GST_config); | 940 | GST_stats_init (GST_config); |
948 | GST_barriers_init (GST_config); | 941 | GST_barriers_init (GST_config); |
@@ -955,9 +948,10 @@ testbed_run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
955 | int | 948 | int |
956 | main (int argc, char *const *argv) | 949 | main (int argc, char *const *argv) |
957 | { | 950 | { |
958 | //sleep (15); /* Debugging */ | ||
959 | return (GNUNET_OK == | 951 | return (GNUNET_OK == |
960 | GNUNET_SERVICE_run (argc, argv, "testbed", GNUNET_SERVICE_OPTION_NONE, | 952 | GNUNET_SERVICE_run (argc, argv, |
953 | "testbed", | ||
954 | GNUNET_SERVICE_OPTION_NONE, | ||
961 | &testbed_run, NULL)) ? 0 : 1; | 955 | &testbed_run, NULL)) ? 0 : 1; |
962 | } | 956 | } |
963 | 957 | ||
diff --git a/src/testbed/gnunet-service-testbed_cpustatus.c b/src/testbed/gnunet-service-testbed_cpustatus.c index cda669caa..ae49e31f9 100644 --- a/src/testbed/gnunet-service-testbed_cpustatus.c +++ b/src/testbed/gnunet-service-testbed_cpustatus.c | |||
@@ -655,12 +655,8 @@ sample_load_task (void *cls) | |||
655 | int ld_disk; | 655 | int ld_disk; |
656 | unsigned int mem_usage; | 656 | unsigned int mem_usage; |
657 | unsigned int nproc; | 657 | unsigned int nproc; |
658 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
659 | 658 | ||
660 | sample_load_task_id = NULL; | 659 | sample_load_task_id = NULL; |
661 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
662 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | ||
663 | return; | ||
664 | ld_cpu = cpu_get_load (); | 660 | ld_cpu = cpu_get_load (); |
665 | ld_disk = disk_get_load (); | 661 | ld_disk = disk_get_load (); |
666 | if ( (-1 == ld_cpu) || (-1 == ld_disk) ) | 662 | if ( (-1 == ld_cpu) || (-1 == ld_disk) ) |
diff --git a/src/testbed/gnunet-service-testbed_oc.c b/src/testbed/gnunet-service-testbed_oc.c index 34bf8e047..55dd5cad9 100644 --- a/src/testbed/gnunet-service-testbed_oc.c +++ b/src/testbed/gnunet-service-testbed_oc.c | |||
@@ -879,13 +879,9 @@ send_hello (void *cls) | |||
879 | struct OverlayConnectContext *occ = cls; | 879 | struct OverlayConnectContext *occ = cls; |
880 | struct LocalPeer2Context *lp2c; | 880 | struct LocalPeer2Context *lp2c; |
881 | char *other_peer_str; | 881 | char *other_peer_str; |
882 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
883 | 882 | ||
884 | occ->send_hello_task = NULL; | 883 | occ->send_hello_task = NULL; |
885 | GNUNET_assert (NULL != occ->timeout_task); | 884 | GNUNET_assert (NULL != occ->timeout_task); |
886 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
887 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
888 | return; | ||
889 | GNUNET_assert (NULL != occ->hello); | 885 | GNUNET_assert (NULL != occ->hello); |
890 | if (OCC_TYPE_LOCAL != occ->type) | 886 | if (OCC_TYPE_LOCAL != occ->type) |
891 | { | 887 | { |
diff --git a/src/testbed/gnunet-testbed-profiler.c b/src/testbed/gnunet-testbed-profiler.c index 308ec0386..9468b3c91 100644 --- a/src/testbed/gnunet-testbed-profiler.c +++ b/src/testbed/gnunet-testbed-profiler.c | |||
@@ -55,12 +55,7 @@ static char *hosts_file; | |||
55 | /** | 55 | /** |
56 | * Abort task identifier | 56 | * Abort task identifier |
57 | */ | 57 | */ |
58 | static struct GNUNET_SCHEDULER_Task * abort_task; | 58 | static struct GNUNET_SCHEDULER_Task *abort_task; |
59 | |||
60 | /** | ||
61 | * Shutdown task identifier | ||
62 | */ | ||
63 | static struct GNUNET_SCHEDULER_Task * shutdown_task; | ||
64 | 59 | ||
65 | /** | 60 | /** |
66 | * Global event mask for all testbed events | 61 | * Global event mask for all testbed events |
@@ -111,7 +106,6 @@ static int noninteractive; | |||
111 | static void | 106 | static void |
112 | do_shutdown (void *cls) | 107 | do_shutdown (void *cls) |
113 | { | 108 | { |
114 | shutdown_task = NULL; | ||
115 | if (NULL != abort_task) | 109 | if (NULL != abort_task) |
116 | { | 110 | { |
117 | GNUNET_SCHEDULER_cancel (abort_task); | 111 | GNUNET_SCHEDULER_cancel (abort_task); |
@@ -122,7 +116,6 @@ do_shutdown (void *cls) | |||
122 | GNUNET_CONFIGURATION_destroy (cfg); | 116 | GNUNET_CONFIGURATION_destroy (cfg); |
123 | cfg = NULL; | 117 | cfg = NULL; |
124 | } | 118 | } |
125 | GNUNET_SCHEDULER_shutdown (); /* Stop scheduler to shutdown testbed run */ | ||
126 | } | 119 | } |
127 | 120 | ||
128 | 121 | ||
@@ -134,12 +127,11 @@ do_shutdown (void *cls) | |||
134 | static void | 127 | static void |
135 | do_abort (void *cls) | 128 | do_abort (void *cls) |
136 | { | 129 | { |
137 | LOG (GNUNET_ERROR_TYPE_WARNING, "Aborting\n"); | ||
138 | abort_task = NULL; | 130 | abort_task = NULL; |
131 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
132 | "Aborting\n"); | ||
139 | result = GNUNET_SYSERR; | 133 | result = GNUNET_SYSERR; |
140 | if (NULL != shutdown_task) | 134 | GNUNET_SCHEDULER_shutdown (); |
141 | GNUNET_SCHEDULER_cancel (shutdown_task); | ||
142 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
143 | } | 135 | } |
144 | 136 | ||
145 | 137 | ||
@@ -228,12 +220,11 @@ test_run (void *cls, | |||
228 | result = GNUNET_OK; | 220 | result = GNUNET_OK; |
229 | fprintf (stdout, "\n"); | 221 | fprintf (stdout, "\n"); |
230 | print_overlay_links_summary (); | 222 | print_overlay_links_summary (); |
223 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); | ||
231 | if (noninteractive) | 224 | if (noninteractive) |
232 | { | 225 | { |
233 | GNUNET_SCHEDULER_cancel (abort_task); | 226 | GNUNET_SCHEDULER_cancel (abort_task); |
234 | abort_task = NULL; | 227 | abort_task = NULL; |
235 | shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | ||
236 | &do_shutdown, NULL); | ||
237 | return; | 228 | return; |
238 | } | 229 | } |
239 | #if (!ENABLE_SUPERMUC) | 230 | #if (!ENABLE_SUPERMUC) |
@@ -243,8 +234,7 @@ test_run (void *cls, | |||
243 | #endif | 234 | #endif |
244 | fprintf (stdout, "Shutting down. Please wait\n"); | 235 | fprintf (stdout, "Shutting down. Please wait\n"); |
245 | fflush (stdout); | 236 | fflush (stdout); |
246 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 237 | GNUNET_SCHEDULER_shutdown (); |
247 | return; | ||
248 | } | 238 | } |
249 | 239 | ||
250 | 240 | ||
diff --git a/src/testbed/gnunet_testbed_mpi_spawn.c b/src/testbed/gnunet_testbed_mpi_spawn.c index 191f658b7..d69812cd2 100644 --- a/src/testbed/gnunet_testbed_mpi_spawn.c +++ b/src/testbed/gnunet_testbed_mpi_spawn.c | |||
@@ -56,11 +56,6 @@ static unsigned long child_exit_code; | |||
56 | static enum GNUNET_OS_ProcessStatusType child_status; | 56 | static enum GNUNET_OS_ProcessStatusType child_status; |
57 | 57 | ||
58 | /** | 58 | /** |
59 | * The shutdown task | ||
60 | */ | ||
61 | static struct GNUNET_SCHEDULER_Task * shutdown_task_id; | ||
62 | |||
63 | /** | ||
64 | * Task to kill the child | 59 | * Task to kill the child |
65 | */ | 60 | */ |
66 | static struct GNUNET_SCHEDULER_Task * terminate_task_id; | 61 | static struct GNUNET_SCHEDULER_Task * terminate_task_id; |
@@ -76,7 +71,6 @@ static struct GNUNET_SCHEDULER_Task * child_death_task_id; | |||
76 | static void | 71 | static void |
77 | shutdown_task (void *cls) | 72 | shutdown_task (void *cls) |
78 | { | 73 | { |
79 | shutdown_task_id = NULL; | ||
80 | if (0 != child_exit_code) | 74 | if (0 != child_exit_code) |
81 | { | 75 | { |
82 | LOG (GNUNET_ERROR_TYPE_WARNING, "Child exited with error code: %lu\n", | 76 | LOG (GNUNET_ERROR_TYPE_WARNING, "Child exited with error code: %lu\n", |
@@ -102,8 +96,7 @@ terminate_task (void *cls) | |||
102 | 96 | ||
103 | GNUNET_assert (NULL != child); | 97 | GNUNET_assert (NULL != child); |
104 | terminate_task_id = | 98 | terminate_task_id = |
105 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 99 | GNUNET_SCHEDULER_add_shutdown (&terminate_task, NULL); |
106 | &terminate_task, NULL); | ||
107 | if (0 != hard_kill) | 100 | if (0 != hard_kill) |
108 | { | 101 | { |
109 | switch (hard_kill) | 102 | switch (hard_kill) |
@@ -159,7 +152,7 @@ child_death_task (void *cls) | |||
159 | &child_exit_code)); | 152 | &child_exit_code)); |
160 | GNUNET_OS_process_destroy (child); | 153 | GNUNET_OS_process_destroy (child); |
161 | child = NULL; | 154 | child = NULL; |
162 | shutdown_task_id = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | 155 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); |
163 | } | 156 | } |
164 | 157 | ||
165 | 158 | ||
@@ -253,13 +246,12 @@ run (void *cls) | |||
253 | { | 246 | { |
254 | GNUNET_break (0); | 247 | GNUNET_break (0); |
255 | ret = GNUNET_SYSERR; | 248 | ret = GNUNET_SYSERR; |
256 | shutdown_task_id = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | 249 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); |
257 | return; | 250 | return; |
258 | } | 251 | } |
259 | ret = GNUNET_OK; | 252 | ret = GNUNET_OK; |
260 | terminate_task_id = | 253 | terminate_task_id = |
261 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 254 | GNUNET_SCHEDULER_add_shutdown (&terminate_task, NULL); |
262 | &terminate_task, NULL); | ||
263 | child_death_task_id = | 255 | child_death_task_id = |
264 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | 256 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
265 | GNUNET_DISK_pipe_handle (sigpipe, | 257 | GNUNET_DISK_pipe_handle (sigpipe, |
diff --git a/src/testbed/test_testbed_api_3peers_3controllers.c b/src/testbed/test_testbed_api_3peers_3controllers.c index a728048f3..0ee1fc566 100644 --- a/src/testbed/test_testbed_api_3peers_3controllers.c +++ b/src/testbed/test_testbed_api_3peers_3controllers.c | |||
@@ -301,6 +301,7 @@ do_abort (void *cls) | |||
301 | do_shutdown (cls); | 301 | do_shutdown (cls); |
302 | } | 302 | } |
303 | 303 | ||
304 | |||
304 | static void | 305 | static void |
305 | abort_test () | 306 | abort_test () |
306 | { | 307 | { |
@@ -842,10 +843,11 @@ status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config, | |||
842 | * @param cls NULL | 843 | * @param cls NULL |
843 | * @param host the host whose status is being reported; will be NULL if the host | 844 | * @param host the host whose status is being reported; will be NULL if the host |
844 | * given to GNUNET_TESTBED_is_host_habitable() is NULL | 845 | * given to GNUNET_TESTBED_is_host_habitable() is NULL |
845 | * @param status GNUNET_YES if it is habitable; GNUNET_NO if not | 846 | * @param status #GNUNET_YES if it is habitable; #GNUNET_NO if not |
846 | */ | 847 | */ |
847 | static void | 848 | static void |
848 | host_habitable_cb (void *cls, const struct GNUNET_TESTBED_Host *_host, | 849 | host_habitable_cb (void *cls, |
850 | const struct GNUNET_TESTBED_Host *_host, | ||
849 | int status) | 851 | int status) |
850 | { | 852 | { |
851 | hc_handle = NULL; | 853 | hc_handle = NULL; |
@@ -857,7 +859,7 @@ host_habitable_cb (void *cls, const struct GNUNET_TESTBED_Host *_host, | |||
857 | "Skipping test\n"); | 859 | "Skipping test\n"); |
858 | GNUNET_SCHEDULER_cancel (abort_task); | 860 | GNUNET_SCHEDULER_cancel (abort_task); |
859 | abort_task = NULL; | 861 | abort_task = NULL; |
860 | (void) GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 862 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
861 | result = SKIP; | 863 | result = SKIP; |
862 | return; | 864 | return; |
863 | } | 865 | } |
diff --git a/src/testbed/test_testbed_api_hosts.c b/src/testbed/test_testbed_api_hosts.c index 2141dc46f..0999020a8 100644 --- a/src/testbed/test_testbed_api_hosts.c +++ b/src/testbed/test_testbed_api_hosts.c | |||
@@ -58,10 +58,6 @@ static unsigned int num_hosts; | |||
58 | */ | 58 | */ |
59 | static int status; | 59 | static int status; |
60 | 60 | ||
61 | /** | ||
62 | * Shutdown task identifier | ||
63 | */ | ||
64 | struct GNUNET_SCHEDULER_Task * shutdown_id; | ||
65 | 61 | ||
66 | /** | 62 | /** |
67 | * The shutdown task | 63 | * The shutdown task |
@@ -159,8 +155,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
159 | } | 155 | } |
160 | } | 156 | } |
161 | status = GNUNET_YES; | 157 | status = GNUNET_YES; |
162 | shutdown_id = | 158 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
163 | GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS (0), &do_shutdown, NULL); | ||
164 | } | 159 | } |
165 | 160 | ||
166 | 161 | ||
diff --git a/src/testbed/test_testbed_api_testbed_run.c b/src/testbed/test_testbed_api_testbed_run.c index 10beebc1f..45c9f5adf 100644 --- a/src/testbed/test_testbed_api_testbed_run.c +++ b/src/testbed/test_testbed_api_testbed_run.c | |||
@@ -86,9 +86,10 @@ do_shutdown (void *cls) | |||
86 | static void | 86 | static void |
87 | do_abort (void *cls) | 87 | do_abort (void *cls) |
88 | { | 88 | { |
89 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test timedout -- Aborting\n"); | ||
90 | abort_task = NULL; | 89 | abort_task = NULL; |
91 | (void) GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 90 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
91 | "Test timed out -- Aborting\n"); | ||
92 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
92 | } | 93 | } |
93 | 94 | ||
94 | 95 | ||
@@ -119,8 +120,7 @@ test_master (void *cls, | |||
119 | return; /* abort already scheduled */ | 120 | return; /* abort already scheduled */ |
120 | GNUNET_SCHEDULER_cancel (abort_task); | 121 | GNUNET_SCHEDULER_cancel (abort_task); |
121 | abort_task = NULL; | 122 | abort_task = NULL; |
122 | (void) GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 123 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
123 | &do_shutdown, NULL); | ||
124 | return; | 124 | return; |
125 | } | 125 | } |
126 | GNUNET_assert (NULL != peers[0]); | 126 | GNUNET_assert (NULL != peers[0]); |
@@ -168,7 +168,9 @@ controller_event_cb (void *cls, | |||
168 | * @param cfg the configuration file handle | 168 | * @param cfg the configuration file handle |
169 | */ | 169 | */ |
170 | static void | 170 | static void |
171 | run (void *cls, char *const *args, const char *cfgfile, | 171 | run (void *cls, |
172 | char *const *args, | ||
173 | const char *cfgfile, | ||
172 | const struct GNUNET_CONFIGURATION_Handle *config) | 174 | const struct GNUNET_CONFIGURATION_Handle *config) |
173 | { | 175 | { |
174 | uint64_t event_mask; | 176 | uint64_t event_mask; |
@@ -176,11 +178,13 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
176 | event_mask = 0; | 178 | event_mask = 0; |
177 | event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START); | 179 | event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START); |
178 | event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP); | 180 | event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP); |
179 | GNUNET_TESTBED_run (NULL, config, NUM_PEERS, event_mask, &controller_event_cb, | 181 | GNUNET_TESTBED_run (NULL, config, NUM_PEERS, event_mask, |
180 | NULL, &test_master, NULL); | 182 | &controller_event_cb, NULL, |
183 | &test_master, NULL); | ||
181 | abort_task = | 184 | abort_task = |
182 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 185 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
183 | (GNUNET_TIME_UNIT_SECONDS, 300), &do_abort, | 186 | (GNUNET_TIME_UNIT_SECONDS, 300), |
187 | &do_abort, | ||
184 | NULL); | 188 | NULL); |
185 | } | 189 | } |
186 | 190 | ||
diff --git a/src/testbed/test_testbed_logger_api.c b/src/testbed/test_testbed_logger_api.c index 30740c94d..f140dfbad 100644 --- a/src/testbed/test_testbed_logger_api.c +++ b/src/testbed/test_testbed_logger_api.c | |||
@@ -113,39 +113,39 @@ do_abort (void *cls) | |||
113 | * | 113 | * |
114 | * @param cls closure | 114 | * @param cls closure |
115 | * @param filename complete filename (absolute path) | 115 | * @param filename complete filename (absolute path) |
116 | * @return #GNUNET_OK to continue to iterate, | ||
117 | * #GNUNET_NO to stop iteration with no error, | ||
118 | * #GNUNET_SYSERR to abort iteration with error! | ||
116 | */ | 119 | */ |
117 | static void | 120 | static int |
118 | iterator_cb (void *cls, | 121 | iterator_cb (void *cls, |
119 | const char *filename) | 122 | const char *filename) |
120 | { | 123 | { |
121 | const char *fn; | 124 | const char *fn; |
122 | size_t len; | 125 | size_t len; |
123 | uint64_t fs; | 126 | uint64_t fs; |
124 | int cancel; | ||
125 | 127 | ||
126 | cancel = GNUNET_NO; | ||
127 | if (NULL == filename) | ||
128 | return; | ||
129 | len = strlen (filename); | 128 | len = strlen (filename); |
130 | if (len < 5) /* log file: `pid'.dat */ | 129 | if (len < 5) /* log file: `pid'.dat */ |
131 | return; | 130 | return GNUNET_OK; |
131 | |||
132 | fn = filename + len; | 132 | fn = filename + len; |
133 | if (0 != strcasecmp (".dat", fn - 4)) | 133 | if (0 != strcasecmp (".dat", fn - 4)) |
134 | return; | 134 | return GNUNET_OK; |
135 | if (GNUNET_OK != GNUNET_DISK_file_size (filename, &fs, | 135 | if (GNUNET_OK != |
136 | GNUNET_NO, GNUNET_YES)) | 136 | GNUNET_DISK_file_size (filename, &fs, |
137 | return; | 137 | GNUNET_NO, GNUNET_YES)) |
138 | return GNUNET_SYSERR; | ||
138 | if ((BSIZE * 2) != fs) /* The file size should be equal to what we | 139 | if ((BSIZE * 2) != fs) /* The file size should be equal to what we |
139 | have written */ | 140 | have written */ |
140 | return; | 141 | return GNUNET_SYSERR; |
141 | cancel = GNUNET_YES; | 142 | return GNUNET_OK; |
142 | result = GNUNET_OK; | ||
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
146 | /** | 146 | /** |
147 | * Functions of this type are called to notify a successful transmission of the | 147 | * Functions of this type are called to notify a successful |
148 | * message to the logger service | 148 | * transmission of the message to the logger service |
149 | * | 149 | * |
150 | * @param cls the closure given to GNUNET_TESTBED_LOGGER_send() | 150 | * @param cls the closure given to GNUNET_TESTBED_LOGGER_send() |
151 | * @param size the amount of data sent | 151 | * @param size the amount of data sent |
diff --git a/src/testbed/testbed_api_testbed.c b/src/testbed/testbed_api_testbed.c index de99fb5a3..b3b2c3987 100644 --- a/src/testbed/testbed_api_testbed.c +++ b/src/testbed/testbed_api_testbed.c | |||
@@ -263,7 +263,7 @@ struct GNUNET_TESTBED_RunHandle | |||
263 | /** | 263 | /** |
264 | * Task run upon shutdown interrupts | 264 | * Task run upon shutdown interrupts |
265 | */ | 265 | */ |
266 | struct GNUNET_SCHEDULER_Task * interrupt_task; | 266 | struct GNUNET_SCHEDULER_Task *interrupt_task; |
267 | 267 | ||
268 | /** | 268 | /** |
269 | * The event mask for the controller | 269 | * The event mask for the controller |
@@ -620,8 +620,7 @@ interrupt (void *cls) | |||
620 | unsigned int size; | 620 | unsigned int size; |
621 | 621 | ||
622 | /* reschedule */ | 622 | /* reschedule */ |
623 | rc->interrupt_task = GNUNET_SCHEDULER_add_delayed | 623 | rc->interrupt_task = GNUNET_SCHEDULER_add_shutdown (&interrupt, rc); |
624 | (GNUNET_TIME_UNIT_FOREVER_REL, &interrupt, rc); | ||
625 | rc_cleanup_operations (rc); | 624 | rc_cleanup_operations (rc); |
626 | if ( (GNUNET_NO == rc->shutdown) && | 625 | if ( (GNUNET_NO == rc->shutdown) && |
627 | (NULL != c) && | 626 | (NULL != c) && |
@@ -988,7 +987,8 @@ host_registration_completion (void *cls, const char *emsg) | |||
988 | GNUNET_SCHEDULER_shutdown (); | 987 | GNUNET_SCHEDULER_shutdown (); |
989 | return; | 988 | return; |
990 | } | 989 | } |
991 | rc->register_hosts_task = GNUNET_SCHEDULER_add_now (®ister_hosts, rc); | 990 | rc->register_hosts_task = GNUNET_SCHEDULER_add_now (®ister_hosts, |
991 | rc); | ||
992 | } | 992 | } |
993 | 993 | ||
994 | 994 | ||
@@ -1415,10 +1415,11 @@ GNUNET_TESTBED_run (const char *host_filename, | |||
1415 | } | 1415 | } |
1416 | rc->rcop_map = GNUNET_CONTAINER_multihashmap32_create (256); | 1416 | rc->rcop_map = GNUNET_CONTAINER_multihashmap32_create (256); |
1417 | rc->timeout_task = | 1417 | rc->timeout_task = |
1418 | GNUNET_SCHEDULER_add_delayed (timeout, &timeout_task, rc); | 1418 | GNUNET_SCHEDULER_add_delayed (timeout, &timeout_task, rc); |
1419 | GNUNET_assert (NULL == rc->interrupt_task); | ||
1419 | rc->interrupt_task = | 1420 | rc->interrupt_task = |
1420 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &interrupt, | 1421 | GNUNET_SCHEDULER_add_shutdown (&interrupt, |
1421 | rc); | 1422 | rc); |
1422 | return; | 1423 | return; |
1423 | 1424 | ||
1424 | error_cleanup: | 1425 | error_cleanup: |
diff --git a/src/testing/gnunet-testing.c b/src/testing/gnunet-testing.c index 92dd17d98..07f1560cb 100644 --- a/src/testing/gnunet-testing.c +++ b/src/testing/gnunet-testing.c | |||
@@ -76,7 +76,7 @@ static char *tmpfilename; | |||
76 | /** | 76 | /** |
77 | * Task identifier of the task that waits for stdin. | 77 | * Task identifier of the task that waits for stdin. |
78 | */ | 78 | */ |
79 | static struct GNUNET_SCHEDULER_Task * tid; | 79 | static struct GNUNET_SCHEDULER_Task *tid; |
80 | 80 | ||
81 | /** | 81 | /** |
82 | * Peer started for '-r'. | 82 | * Peer started for '-r'. |
@@ -228,13 +228,8 @@ static void | |||
228 | stdin_cb (void *cls) | 228 | stdin_cb (void *cls) |
229 | { | 229 | { |
230 | int c; | 230 | int c; |
231 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
232 | 231 | ||
233 | tid = NULL; | 232 | tid = NULL; |
234 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
235 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | ||
236 | return; | ||
237 | GNUNET_assert (0 != (GNUNET_SCHEDULER_REASON_READ_READY & tc->reason)); | ||
238 | c = getchar (); | 233 | c = getchar (); |
239 | switch (c) | 234 | switch (c) |
240 | { | 235 | { |
@@ -258,7 +253,8 @@ stdin_cb (void *cls) | |||
258 | fprintf (stderr, _("Unknown command, use 'q' to quit or 'r' to restart peer\n")); | 253 | fprintf (stderr, _("Unknown command, use 'q' to quit or 'r' to restart peer\n")); |
259 | break; | 254 | break; |
260 | } | 255 | } |
261 | tid = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, fh, | 256 | tid = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
257 | fh, | ||
262 | &stdin_cb, NULL); | 258 | &stdin_cb, NULL); |
263 | } | 259 | } |
264 | 260 | ||
@@ -291,9 +287,10 @@ testing_main (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
291 | } | 287 | } |
292 | printf("ok\n%s\n", tmpfilename); | 288 | printf("ok\n%s\n", tmpfilename); |
293 | fflush(stdout); | 289 | fflush(stdout); |
294 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, NULL); | 290 | GNUNET_SCHEDULER_add_shutdown (&cleanup, NULL); |
295 | fh = GNUNET_DISK_get_handle_from_native (stdin); | 291 | fh = GNUNET_DISK_get_handle_from_native (stdin); |
296 | tid = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, fh, | 292 | tid = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
293 | fh, | ||
297 | &stdin_cb, NULL); | 294 | &stdin_cb, NULL); |
298 | } | 295 | } |
299 | 296 | ||
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index 1a6c163ee..eddac8c8a 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c | |||
@@ -514,13 +514,9 @@ schedule_next_hello (void *cls) | |||
514 | struct FindAdvHelloContext fah; | 514 | struct FindAdvHelloContext fah; |
515 | size_t next_want; | 515 | size_t next_want; |
516 | struct GNUNET_TIME_Relative delay; | 516 | struct GNUNET_TIME_Relative delay; |
517 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
518 | 517 | ||
519 | pl->hello_delay_task = NULL; | 518 | pl->hello_delay_task = NULL; |
520 | GNUNET_assert (GNUNET_YES == pl->is_connected); | 519 | GNUNET_assert (GNUNET_YES == pl->is_connected); |
521 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
522 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
523 | return; /* we're out of here */ | ||
524 | if (pl->hello_req != NULL) | 520 | if (pl->hello_req != NULL) |
525 | return; /* did not finish sending the previous one */ | 521 | return; /* did not finish sending the previous one */ |
526 | /* find applicable HELLOs */ | 522 | /* find applicable HELLOs */ |
@@ -535,7 +531,7 @@ schedule_next_hello (void *cls) | |||
535 | GNUNET_SCHEDULER_add_delayed (fah.next_adv, | 531 | GNUNET_SCHEDULER_add_delayed (fah.next_adv, |
536 | &schedule_next_hello, | 532 | &schedule_next_hello, |
537 | pl); | 533 | pl); |
538 | if (fah.result == NULL) | 534 | if (NULL == fah.result) |
539 | return; | 535 | return; |
540 | next_want = GNUNET_HELLO_size (fah.result->hello); | 536 | next_want = GNUNET_HELLO_size (fah.result->hello); |
541 | delay = GNUNET_TIME_absolute_get_remaining (pl->next_hello_allowed); | 537 | delay = GNUNET_TIME_absolute_get_remaining (pl->next_hello_allowed); |
@@ -1241,9 +1237,8 @@ run (void *cls, | |||
1241 | NULL, GNUNET_NO, | 1237 | NULL, GNUNET_NO, |
1242 | NULL, GNUNET_NO, | 1238 | NULL, GNUNET_NO, |
1243 | handlers); | 1239 | handlers); |
1244 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1240 | GNUNET_SCHEDULER_add_shutdown (&cleaning_task, |
1245 | &cleaning_task, | 1241 | NULL); |
1246 | NULL); | ||
1247 | if (NULL == transport) | 1242 | if (NULL == transport) |
1248 | { | 1243 | { |
1249 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1244 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 9fde3d83e..119e5e564 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -848,9 +848,8 @@ run (void *cls, | |||
848 | "My identity is `%4s'\n", | 848 | "My identity is `%4s'\n", |
849 | GNUNET_i2s_full (&GST_my_identity)); | 849 | GNUNET_i2s_full (&GST_my_identity)); |
850 | 850 | ||
851 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 851 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
852 | &shutdown_task, | 852 | NULL); |
853 | NULL); | ||
854 | if (NULL == GST_peerinfo) | 853 | if (NULL == GST_peerinfo) |
855 | { | 854 | { |
856 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 855 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index 836aa418c..6ea5394bf 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c | |||
@@ -873,7 +873,6 @@ add_valid_address (void *cls, | |||
873 | validation_entry_changed (ve, | 873 | validation_entry_changed (ve, |
874 | GNUNET_TRANSPORT_VS_UPDATE); | 874 | GNUNET_TRANSPORT_VS_UPDATE); |
875 | memset (&prop, 0, sizeof (prop)); | 875 | memset (&prop, 0, sizeof (prop)); |
876 | GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != ve->network); | ||
877 | prop.scope = ve->network; | 876 | prop.scope = ve->network; |
878 | prop.delay = GNUNET_TIME_relative_divide (ve->latency, 2); | 877 | prop.delay = GNUNET_TIME_relative_divide (ve->latency, 2); |
879 | if (GNUNET_YES != ve->known_to_ats) | 878 | if (GNUNET_YES != ve->known_to_ats) |
diff --git a/src/transport/gnunet-transport-profiler.c b/src/transport/gnunet-transport-profiler.c index 624d1a16c..af47c5c56 100644 --- a/src/transport/gnunet-transport-profiler.c +++ b/src/transport/gnunet-transport-profiler.c | |||
@@ -146,11 +146,6 @@ static struct GNUNET_TRANSPORT_Blacklist *bl_handle; | |||
146 | static struct GNUNET_PeerIdentity pid; | 146 | static struct GNUNET_PeerIdentity pid; |
147 | 147 | ||
148 | /** | 148 | /** |
149 | * Task scheduled for cleanup / termination of the process. | ||
150 | */ | ||
151 | static struct GNUNET_SCHEDULER_Task * end; | ||
152 | |||
153 | /** | ||
154 | * Selected level of verbosity. | 149 | * Selected level of verbosity. |
155 | */ | 150 | */ |
156 | static int verbosity; | 151 | static int verbosity; |
@@ -380,9 +375,7 @@ iteration_done () | |||
380 | if (it_count == benchmark_iterations) | 375 | if (it_count == benchmark_iterations) |
381 | { | 376 | { |
382 | benchmark_running = GNUNET_NO; | 377 | benchmark_running = GNUNET_NO; |
383 | if (NULL != end) | 378 | GNUNET_SCHEDULER_shutdown (); |
384 | GNUNET_SCHEDULER_cancel (end); | ||
385 | end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | ||
386 | return; | 379 | return; |
387 | } | 380 | } |
388 | else | 381 | else |
@@ -570,9 +563,8 @@ testservice_task (void *cls, int result) | |||
570 | ats_sh = GNUNET_ATS_connectivity_suggest (ats, | 563 | ats_sh = GNUNET_ATS_connectivity_suggest (ats, |
571 | &pid, | 564 | &pid, |
572 | 1); | 565 | 1); |
573 | end = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 566 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
574 | &shutdown_task, | 567 | NULL); |
575 | NULL); | ||
576 | } | 568 | } |
577 | 569 | ||
578 | 570 | ||
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c index bed9bdc85..cbddee905 100644 --- a/src/transport/gnunet-transport.c +++ b/src/transport/gnunet-transport.c | |||
@@ -607,9 +607,7 @@ operation_timeout (void *cls) | |||
607 | FPRINTF (stdout, | 607 | FPRINTF (stdout, |
608 | _("Failed to connect to `%s'\n"), | 608 | _("Failed to connect to `%s'\n"), |
609 | GNUNET_i2s_full (&pid)); | 609 | GNUNET_i2s_full (&pid)); |
610 | if (NULL != end) | 610 | GNUNET_SCHEDULER_shutdown (); |
611 | GNUNET_SCHEDULER_cancel (end); | ||
612 | end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | ||
613 | ret = 1; | 611 | ret = 1; |
614 | return; | 612 | return; |
615 | } | 613 | } |
@@ -633,9 +631,7 @@ operation_timeout (void *cls) | |||
633 | FPRINTF (stdout, | 631 | FPRINTF (stdout, |
634 | "%s", | 632 | "%s", |
635 | _("Failed to list connections, timeout occured\n")); | 633 | _("Failed to list connections, timeout occured\n")); |
636 | if (NULL != end) | 634 | GNUNET_SCHEDULER_shutdown (); |
637 | GNUNET_SCHEDULER_cancel (end); | ||
638 | end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | ||
639 | ret = 1; | 635 | ret = 1; |
640 | return; | 636 | return; |
641 | } | 637 | } |
@@ -851,18 +847,13 @@ process_validation_string (void *cls, | |||
851 | GNUNET_free (vc); | 847 | GNUNET_free (vc); |
852 | if ((0 == address_resolutions) && (iterate_validation)) | 848 | if ((0 == address_resolutions) && (iterate_validation)) |
853 | { | 849 | { |
854 | if (NULL != end) | ||
855 | { | ||
856 | GNUNET_SCHEDULER_cancel (end); | ||
857 | end = NULL; | ||
858 | } | ||
859 | if (NULL != op_timeout) | 850 | if (NULL != op_timeout) |
860 | { | 851 | { |
861 | GNUNET_SCHEDULER_cancel (op_timeout); | 852 | GNUNET_SCHEDULER_cancel (op_timeout); |
862 | op_timeout = NULL; | 853 | op_timeout = NULL; |
863 | } | 854 | } |
864 | ret = 0; | 855 | ret = 0; |
865 | end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | 856 | GNUNET_SCHEDULER_shutdown (); |
866 | } | 857 | } |
867 | } | 858 | } |
868 | 859 | ||
@@ -937,9 +928,7 @@ process_validation_cb (void *cls, | |||
937 | return; | 928 | return; |
938 | } | 929 | } |
939 | vic = NULL; | 930 | vic = NULL; |
940 | if (NULL != end) | 931 | GNUNET_SCHEDULER_shutdown (); |
941 | GNUNET_SCHEDULER_cancel (end); | ||
942 | end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | ||
943 | return; | 932 | return; |
944 | } | 933 | } |
945 | resolve_validation_address (address, | 934 | resolve_validation_address (address, |
@@ -1364,19 +1353,13 @@ process_peer_string (void *cls, | |||
1364 | GNUNET_free (rc); | 1353 | GNUNET_free (rc); |
1365 | if ((0 == address_resolutions) && (iterate_connections)) | 1354 | if ((0 == address_resolutions) && (iterate_connections)) |
1366 | { | 1355 | { |
1367 | if (NULL != end) | ||
1368 | { | ||
1369 | GNUNET_SCHEDULER_cancel (end); | ||
1370 | end = NULL; | ||
1371 | } | ||
1372 | if (NULL != op_timeout) | 1356 | if (NULL != op_timeout) |
1373 | { | 1357 | { |
1374 | GNUNET_SCHEDULER_cancel (op_timeout); | 1358 | GNUNET_SCHEDULER_cancel (op_timeout); |
1375 | op_timeout = NULL; | 1359 | op_timeout = NULL; |
1376 | } | 1360 | } |
1377 | ret = 0; | 1361 | ret = 0; |
1378 | end = GNUNET_SCHEDULER_add_now (&shutdown_task, | 1362 | GNUNET_SCHEDULER_shutdown (); |
1379 | NULL); | ||
1380 | } | 1363 | } |
1381 | } | 1364 | } |
1382 | 1365 | ||
@@ -1950,10 +1933,9 @@ testservice_task (void *cls, | |||
1950 | GNUNET_break(0); | 1933 | GNUNET_break(0); |
1951 | return; | 1934 | return; |
1952 | } | 1935 | } |
1953 | 1936 | ||
1954 | end = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1937 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
1955 | &shutdown_task, | 1938 | NULL); |
1956 | NULL); | ||
1957 | } | 1939 | } |
1958 | 1940 | ||
1959 | 1941 | ||
diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c index 2b0b8939e..132406799 100644 --- a/src/transport/plugin_transport_http_client.c +++ b/src/transport/plugin_transport_http_client.c | |||
@@ -226,17 +226,17 @@ struct GNUNET_ATS_Session | |||
226 | /** | 226 | /** |
227 | * Session timeout task | 227 | * Session timeout task |
228 | */ | 228 | */ |
229 | struct GNUNET_SCHEDULER_Task * put_disconnect_task; | 229 | struct GNUNET_SCHEDULER_Task *put_disconnect_task; |
230 | 230 | ||
231 | /** | 231 | /** |
232 | * Session timeout task | 232 | * Session timeout task |
233 | */ | 233 | */ |
234 | struct GNUNET_SCHEDULER_Task * timeout_task; | 234 | struct GNUNET_SCHEDULER_Task *timeout_task; |
235 | 235 | ||
236 | /** | 236 | /** |
237 | * Task to wake up client receive handle when receiving is allowed again | 237 | * Task to wake up client receive handle when receiving is allowed again |
238 | */ | 238 | */ |
239 | struct GNUNET_SCHEDULER_Task * recv_wakeup_task; | 239 | struct GNUNET_SCHEDULER_Task *recv_wakeup_task; |
240 | 240 | ||
241 | /** | 241 | /** |
242 | * Absolute time when to receive data again. | 242 | * Absolute time when to receive data again. |
@@ -1130,12 +1130,8 @@ static void | |||
1130 | client_wake_up (void *cls) | 1130 | client_wake_up (void *cls) |
1131 | { | 1131 | { |
1132 | struct GNUNET_ATS_Session *s = cls; | 1132 | struct GNUNET_ATS_Session *s = cls; |
1133 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
1134 | 1133 | ||
1135 | s->recv_wakeup_task = NULL; | 1134 | s->recv_wakeup_task = NULL; |
1136 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
1137 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
1138 | return; | ||
1139 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1135 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1140 | "Session %p/request %p: Waking up GET handle\n", | 1136 | "Session %p/request %p: Waking up GET handle\n", |
1141 | s, s->get.easyhandle); | 1137 | s, s->get.easyhandle); |
@@ -1301,13 +1297,8 @@ client_run (void *cls) | |||
1301 | CURLMsg *msg; | 1297 | CURLMsg *msg; |
1302 | int put_request; /* GNUNET_YES if easy handle is put, GNUNET_NO for get */ | 1298 | int put_request; /* GNUNET_YES if easy handle is put, GNUNET_NO for get */ |
1303 | int msgs_left; | 1299 | int msgs_left; |
1304 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
1305 | 1300 | ||
1306 | plugin->client_perform_task = NULL; | 1301 | plugin->client_perform_task = NULL; |
1307 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
1308 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
1309 | return; | ||
1310 | |||
1311 | /* While data are available or timeouts occured */ | 1302 | /* While data are available or timeouts occured */ |
1312 | do | 1303 | do |
1313 | { | 1304 | { |
@@ -2379,8 +2370,10 @@ http_client_plugin_update_inbound_delay (void *cls, | |||
2379 | if (s->recv_wakeup_task != NULL) | 2370 | if (s->recv_wakeup_task != NULL) |
2380 | { | 2371 | { |
2381 | GNUNET_SCHEDULER_cancel (s->recv_wakeup_task); | 2372 | GNUNET_SCHEDULER_cancel (s->recv_wakeup_task); |
2382 | s->recv_wakeup_task = GNUNET_SCHEDULER_add_delayed (delay, | 2373 | s->recv_wakeup_task |
2383 | &client_wake_up, s); | 2374 | = GNUNET_SCHEDULER_add_delayed (delay, |
2375 | &client_wake_up, | ||
2376 | s); | ||
2384 | } | 2377 | } |
2385 | } | 2378 | } |
2386 | 2379 | ||
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index dfd0294e5..c43124c2e 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c | |||
@@ -374,17 +374,17 @@ struct HTTP_Server_Plugin | |||
374 | /** | 374 | /** |
375 | * MHD IPv4 task | 375 | * MHD IPv4 task |
376 | */ | 376 | */ |
377 | struct GNUNET_SCHEDULER_Task * server_v4_task; | 377 | struct GNUNET_SCHEDULER_Task *server_v4_task; |
378 | 378 | ||
379 | /** | 379 | /** |
380 | * MHD IPv6 task | 380 | * MHD IPv6 task |
381 | */ | 381 | */ |
382 | struct GNUNET_SCHEDULER_Task * server_v6_task; | 382 | struct GNUNET_SCHEDULER_Task *server_v6_task; |
383 | 383 | ||
384 | /** | 384 | /** |
385 | * Task calling transport service about external address | 385 | * Task calling transport service about external address |
386 | */ | 386 | */ |
387 | struct GNUNET_SCHEDULER_Task * notify_ext_task; | 387 | struct GNUNET_SCHEDULER_Task *notify_ext_task; |
388 | 388 | ||
389 | /** | 389 | /** |
390 | * Notify transport only about external address | 390 | * Notify transport only about external address |
@@ -496,12 +496,8 @@ static void | |||
496 | server_wake_up (void *cls) | 496 | server_wake_up (void *cls) |
497 | { | 497 | { |
498 | struct GNUNET_ATS_Session *s = cls; | 498 | struct GNUNET_ATS_Session *s = cls; |
499 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
500 | 499 | ||
501 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
502 | s->recv_wakeup_task = NULL; | 500 | s->recv_wakeup_task = NULL; |
503 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
504 | return; | ||
505 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 501 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
506 | "Session %p: Waking up PUT handle\n", | 502 | "Session %p: Waking up PUT handle\n", |
507 | s); | 503 | s); |
@@ -913,12 +909,8 @@ static void | |||
913 | server_v4_run (void *cls) | 909 | server_v4_run (void *cls) |
914 | { | 910 | { |
915 | struct HTTP_Server_Plugin *plugin = cls; | 911 | struct HTTP_Server_Plugin *plugin = cls; |
916 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
917 | 912 | ||
918 | plugin->server_v4_task = NULL; | 913 | plugin->server_v4_task = NULL; |
919 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
920 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
921 | return; | ||
922 | plugin->server_v4_immediately = GNUNET_NO; | 914 | plugin->server_v4_immediately = GNUNET_NO; |
923 | GNUNET_assert (MHD_YES == MHD_run (plugin->server_v4)); | 915 | GNUNET_assert (MHD_YES == MHD_run (plugin->server_v4)); |
924 | server_reschedule (plugin, plugin->server_v4, GNUNET_NO); | 916 | server_reschedule (plugin, plugin->server_v4, GNUNET_NO); |
@@ -935,12 +927,8 @@ static void | |||
935 | server_v6_run (void *cls) | 927 | server_v6_run (void *cls) |
936 | { | 928 | { |
937 | struct HTTP_Server_Plugin *plugin = cls; | 929 | struct HTTP_Server_Plugin *plugin = cls; |
938 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
939 | 930 | ||
940 | plugin->server_v6_task = NULL; | 931 | plugin->server_v6_task = NULL; |
941 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
942 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
943 | return; | ||
944 | plugin->server_v6_immediately = GNUNET_NO; | 932 | plugin->server_v6_immediately = GNUNET_NO; |
945 | GNUNET_assert (MHD_YES == MHD_run (plugin->server_v6)); | 933 | GNUNET_assert (MHD_YES == MHD_run (plugin->server_v6)); |
946 | server_reschedule (plugin, plugin->server_v6, GNUNET_NO); | 934 | server_reschedule (plugin, plugin->server_v6, GNUNET_NO); |
@@ -1869,8 +1857,10 @@ server_access_cb (void *cls, | |||
1869 | GNUNET_assert(s->server_recv->mhd_conn == mhd_connection); | 1857 | GNUNET_assert(s->server_recv->mhd_conn == mhd_connection); |
1870 | MHD_suspend_connection (s->server_recv->mhd_conn); | 1858 | MHD_suspend_connection (s->server_recv->mhd_conn); |
1871 | if (NULL == s->recv_wakeup_task) | 1859 | if (NULL == s->recv_wakeup_task) |
1872 | s->recv_wakeup_task = GNUNET_SCHEDULER_add_delayed (delay, | 1860 | s->recv_wakeup_task |
1873 | &server_wake_up, s); | 1861 | = GNUNET_SCHEDULER_add_delayed (delay, |
1862 | &server_wake_up, | ||
1863 | s); | ||
1874 | } | 1864 | } |
1875 | return MHD_YES; | 1865 | return MHD_YES; |
1876 | } | 1866 | } |
@@ -2851,18 +2841,12 @@ server_notify_external_hostname (void *cls) | |||
2851 | size_t ext_addr_len; | 2841 | size_t ext_addr_len; |
2852 | unsigned int urlen; | 2842 | unsigned int urlen; |
2853 | char *url; | 2843 | char *url; |
2854 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
2855 | 2844 | ||
2856 | plugin->notify_ext_task = NULL; | 2845 | plugin->notify_ext_task = NULL; |
2857 | tc = GNUNET_SCHEDULER_get_task_context (); | 2846 | GNUNET_asprintf (&url, |
2858 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 2847 | "%s://%s", |
2859 | return; | 2848 | plugin->protocol, |
2860 | 2849 | plugin->external_hostname); | |
2861 | GNUNET_asprintf(&url, | ||
2862 | "%s://%s", | ||
2863 | plugin->protocol, | ||
2864 | plugin->external_hostname); | ||
2865 | |||
2866 | urlen = strlen (url) + 1; | 2850 | urlen = strlen (url) + 1; |
2867 | ext_addr = GNUNET_malloc (sizeof (struct HttpAddress) + urlen); | 2851 | ext_addr = GNUNET_malloc (sizeof (struct HttpAddress) + urlen); |
2868 | ext_addr->options = htonl (plugin->options); | 2852 | ext_addr->options = htonl (plugin->options); |
@@ -2881,13 +2865,23 @@ server_notify_external_hostname (void *cls) | |||
2881 | "Enabling SSL verification for external hostname address `%s'\n", | 2865 | "Enabling SSL verification for external hostname address `%s'\n", |
2882 | plugin->external_hostname); | 2866 | plugin->external_hostname); |
2883 | plugin->ext_addr = GNUNET_HELLO_address_allocate (plugin->env->my_identity, | 2867 | plugin->ext_addr = GNUNET_HELLO_address_allocate (plugin->env->my_identity, |
2884 | "https_client", ext_addr, ext_addr_len, GNUNET_HELLO_ADDRESS_INFO_NONE ); | 2868 | "https_client", |
2885 | plugin->env->notify_address (plugin->env->cls, GNUNET_YES, plugin->ext_addr); | 2869 | ext_addr, |
2870 | ext_addr_len, | ||
2871 | GNUNET_HELLO_ADDRESS_INFO_NONE); | ||
2872 | plugin->env->notify_address (plugin->env->cls, | ||
2873 | GNUNET_YES, | ||
2874 | plugin->ext_addr); | ||
2886 | GNUNET_free (ext_addr); | 2875 | GNUNET_free (ext_addr); |
2887 | #else | 2876 | #else |
2888 | plugin->ext_addr = GNUNET_HELLO_address_allocate (plugin->env->my_identity, | 2877 | plugin->ext_addr = GNUNET_HELLO_address_allocate (plugin->env->my_identity, |
2889 | "http_client", ext_addr, ext_addr_len, GNUNET_HELLO_ADDRESS_INFO_NONE ); | 2878 | "http_client", |
2890 | plugin->env->notify_address (plugin->env->cls, GNUNET_YES, plugin->ext_addr); | 2879 | ext_addr, |
2880 | ext_addr_len, | ||
2881 | GNUNET_HELLO_ADDRESS_INFO_NONE); | ||
2882 | plugin->env->notify_address (plugin->env->cls, | ||
2883 | GNUNET_YES, | ||
2884 | plugin->ext_addr); | ||
2891 | GNUNET_free (ext_addr); | 2885 | GNUNET_free (ext_addr); |
2892 | #endif | 2886 | #endif |
2893 | } | 2887 | } |
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 89feb8f5c..b5706f024 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -3516,13 +3516,11 @@ udp_plugin_select_v4 (void *cls) | |||
3516 | { | 3516 | { |
3517 | struct Plugin *plugin = cls; | 3517 | struct Plugin *plugin = cls; |
3518 | const struct GNUNET_SCHEDULER_TaskContext *tc; | 3518 | const struct GNUNET_SCHEDULER_TaskContext *tc; |
3519 | 3519 | ||
3520 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
3521 | plugin->select_task_v4 = NULL; | 3520 | plugin->select_task_v4 = NULL; |
3522 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
3523 | return; | ||
3524 | if (NULL == plugin->sockv4) | 3521 | if (NULL == plugin->sockv4) |
3525 | return; | 3522 | return; |
3523 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
3526 | if ((0 != (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) && | 3524 | if ((0 != (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) && |
3527 | (GNUNET_NETWORK_fdset_isset (tc->read_ready, | 3525 | (GNUNET_NETWORK_fdset_isset (tc->read_ready, |
3528 | plugin->sockv4))) | 3526 | plugin->sockv4))) |
@@ -3547,12 +3545,10 @@ udp_plugin_select_v6 (void *cls) | |||
3547 | struct Plugin *plugin = cls; | 3545 | struct Plugin *plugin = cls; |
3548 | const struct GNUNET_SCHEDULER_TaskContext *tc; | 3546 | const struct GNUNET_SCHEDULER_TaskContext *tc; |
3549 | 3547 | ||
3550 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
3551 | plugin->select_task_v6 = NULL; | 3548 | plugin->select_task_v6 = NULL; |
3552 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
3553 | return; | ||
3554 | if (NULL == plugin->sockv6) | 3549 | if (NULL == plugin->sockv6) |
3555 | return; | 3550 | return; |
3551 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
3556 | if ( (0 != (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) && | 3552 | if ( (0 != (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) && |
3557 | (GNUNET_NETWORK_fdset_isset (tc->read_ready, | 3553 | (GNUNET_NETWORK_fdset_isset (tc->read_ready, |
3558 | plugin->sockv6)) ) | 3554 | plugin->sockv6)) ) |
diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c index e320785d4..d0566c2d3 100644 --- a/src/transport/plugin_transport_unix.c +++ b/src/transport/plugin_transport_unix.c | |||
@@ -1229,11 +1229,9 @@ unix_plugin_select_read (void *cls) | |||
1229 | { | 1229 | { |
1230 | struct Plugin *plugin = cls; | 1230 | struct Plugin *plugin = cls; |
1231 | const struct GNUNET_SCHEDULER_TaskContext *tc; | 1231 | const struct GNUNET_SCHEDULER_TaskContext *tc; |
1232 | 1232 | ||
1233 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
1234 | plugin->read_task = NULL; | 1233 | plugin->read_task = NULL; |
1235 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 1234 | tc = GNUNET_SCHEDULER_get_task_context (); |
1236 | return; | ||
1237 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) | 1235 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) |
1238 | unix_plugin_do_read (plugin); | 1236 | unix_plugin_do_read (plugin); |
1239 | plugin->read_task = | 1237 | plugin->read_task = |
@@ -1254,11 +1252,9 @@ unix_plugin_select_write (void *cls) | |||
1254 | { | 1252 | { |
1255 | struct Plugin *plugin = cls; | 1253 | struct Plugin *plugin = cls; |
1256 | const struct GNUNET_SCHEDULER_TaskContext *tc; | 1254 | const struct GNUNET_SCHEDULER_TaskContext *tc; |
1257 | 1255 | ||
1258 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
1259 | plugin->write_task = NULL; | 1256 | plugin->write_task = NULL; |
1260 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 1257 | tc = GNUNET_SCHEDULER_get_task_context (); |
1261 | return; | ||
1262 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)) | 1258 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)) |
1263 | unix_plugin_do_write (plugin); | 1259 | unix_plugin_do_write (plugin); |
1264 | if (NULL == plugin->msg_head) | 1260 | if (NULL == plugin->msg_head) |
diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c index 13333b371..528b8f2bf 100644 --- a/src/transport/test_transport_api.c +++ b/src/transport/test_transport_api.c | |||
@@ -228,12 +228,7 @@ notify_ready (void *cls, size_t size, void *buf) | |||
228 | static void | 228 | static void |
229 | sendtask (void *cls) | 229 | sendtask (void *cls) |
230 | { | 230 | { |
231 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
232 | |||
233 | send_task = NULL; | 231 | send_task = NULL; |
234 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
235 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
236 | return; | ||
237 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id)); | 232 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id)); |
238 | 233 | ||
239 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 234 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
diff --git a/src/transport/test_transport_api_bidirectional_connect.c b/src/transport/test_transport_api_bidirectional_connect.c index 1e00e982d..a5d6b6b71 100644 --- a/src/transport/test_transport_api_bidirectional_connect.c +++ b/src/transport/test_transport_api_bidirectional_connect.c | |||
@@ -210,14 +210,10 @@ notify_ready (void *cls, size_t size, void *buf) | |||
210 | static void | 210 | static void |
211 | sendtask (void *cls) | 211 | sendtask (void *cls) |
212 | { | 212 | { |
213 | const struct GNUNET_SCHEDULER_TaskContext *tc; | 213 | char *receiver_s; |
214 | 214 | ||
215 | send_task = NULL; | 215 | send_task = NULL; |
216 | tc = GNUNET_SCHEDULER_get_task_context (); | 216 | receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id)); |
217 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
218 | return; | ||
219 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id)); | ||
220 | |||
221 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 217 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
222 | "Sending message from peer %u (`%4s') -> peer %u (`%s') !\n", | 218 | "Sending message from peer %u (`%4s') -> peer %u (`%s') !\n", |
223 | p2->no, GNUNET_i2s (&p2->id), p1->no, receiver_s); | 219 | p2->no, GNUNET_i2s (&p2->id), p1->no, receiver_s); |
diff --git a/src/transport/test_transport_api_blacklisting.c b/src/transport/test_transport_api_blacklisting.c index f65fb74f9..963d3b045 100644 --- a/src/transport/test_transport_api_blacklisting.c +++ b/src/transport/test_transport_api_blacklisting.c | |||
@@ -262,12 +262,7 @@ notify_ready (void *cls, size_t size, void *buf) | |||
262 | static void | 262 | static void |
263 | sendtask (void *cls) | 263 | sendtask (void *cls) |
264 | { | 264 | { |
265 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
266 | |||
267 | send_task = NULL; | 265 | send_task = NULL; |
268 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
269 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
270 | return; | ||
271 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id)); | 266 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id)); |
272 | 267 | ||
273 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 268 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
diff --git a/src/transport/test_transport_api_disconnect.c b/src/transport/test_transport_api_disconnect.c index 36497ece5..f52634bde 100644 --- a/src/transport/test_transport_api_disconnect.c +++ b/src/transport/test_transport_api_disconnect.c | |||
@@ -165,12 +165,6 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
165 | static void | 165 | static void |
166 | stop_peer (void *cls) | 166 | stop_peer (void *cls) |
167 | { | 167 | { |
168 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
169 | |||
170 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
171 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
172 | return; | ||
173 | |||
174 | struct PeerContext *p = cls; | 168 | struct PeerContext *p = cls; |
175 | 169 | ||
176 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down peer %u (`%s')\n", p->no, | 170 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down peer %u (`%s')\n", p->no, |
@@ -254,12 +248,7 @@ notify_ready (void *cls, size_t size, void *buf) | |||
254 | static void | 248 | static void |
255 | sendtask (void *cls) | 249 | sendtask (void *cls) |
256 | { | 250 | { |
257 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
258 | |||
259 | send_task = NULL; | 251 | send_task = NULL; |
260 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
261 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
262 | return; | ||
263 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id)); | 252 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id)); |
264 | 253 | ||
265 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 254 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
diff --git a/src/transport/test_transport_api_http_reverse_peer2.conf b/src/transport/test_transport_api_http_reverse_peer2.conf index 7117895ef..136c09008 100644 --- a/src/transport/test_transport_api_http_reverse_peer2.conf +++ b/src/transport/test_transport_api_http_reverse_peer2.conf | |||
@@ -10,4 +10,3 @@ EXTERNAL_HOSTNAME_ONLY = YES | |||
10 | [transport] | 10 | [transport] |
11 | PLUGINS = http_server | 11 | PLUGINS = http_server |
12 | 12 | ||
13 | |||
diff --git a/src/transport/test_transport_api_https_peer1.conf b/src/transport/test_transport_api_https_peer1.conf index 8fc2edf2e..c6a083f37 100644 --- a/src/transport/test_transport_api_https_peer1.conf +++ b/src/transport/test_transport_api_https_peer1.conf | |||
@@ -21,5 +21,6 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-peerinfo.sock | |||
21 | PORT = 12101 | 21 | PORT = 12101 |
22 | PLUGINS = https_client | 22 | PLUGINS = https_client |
23 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-transport.sock | 23 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-transport.sock |
24 | #PREFIX = valgrind | ||
24 | 25 | ||
25 | 26 | ||
diff --git a/src/transport/test_transport_api_https_peer2.conf b/src/transport/test_transport_api_https_peer2.conf index d2bf20011..49210651c 100644 --- a/src/transport/test_transport_api_https_peer2.conf +++ b/src/transport/test_transport_api_https_peer2.conf | |||
@@ -27,5 +27,6 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-peerinfo.sock | |||
27 | PORT = 12111 | 27 | PORT = 12111 |
28 | PLUGINS = https_server | 28 | PLUGINS = https_server |
29 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-transport.sock | 29 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-transport.sock |
30 | #PREFIX = valgrind | ||
30 | 31 | ||
31 | 32 | ||
diff --git a/src/transport/test_transport_api_limited_sockets.c b/src/transport/test_transport_api_limited_sockets.c index 8d875ed52..0ae807077 100644 --- a/src/transport/test_transport_api_limited_sockets.c +++ b/src/transport/test_transport_api_limited_sockets.c | |||
@@ -198,13 +198,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
198 | static void | 198 | static void |
199 | sendtask (void *cls) | 199 | sendtask (void *cls) |
200 | { | 200 | { |
201 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
202 | |||
203 | send_task = NULL; | 201 | send_task = NULL; |
204 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
205 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
206 | return; | ||
207 | |||
208 | th = GNUNET_TRANSPORT_notify_transmit_ready (p1->th, &p2->id, 256, TIMEOUT, | 202 | th = GNUNET_TRANSPORT_notify_transmit_ready (p1->th, &p2->id, 256, TIMEOUT, |
209 | ¬ify_ready, &p1); | 203 | ¬ify_ready, &p1); |
210 | } | 204 | } |
diff --git a/src/transport/test_transport_api_manipulation_cfg.c b/src/transport/test_transport_api_manipulation_cfg.c index 915b79719..fe3d31f7b 100644 --- a/src/transport/test_transport_api_manipulation_cfg.c +++ b/src/transport/test_transport_api_manipulation_cfg.c | |||
@@ -206,12 +206,7 @@ notify_request_ready (void *cls, size_t size, void *buf) | |||
206 | static void | 206 | static void |
207 | sendtask_request_task (void *cls) | 207 | sendtask_request_task (void *cls) |
208 | { | 208 | { |
209 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
210 | |||
211 | send_task = NULL; | 209 | send_task = NULL; |
212 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
213 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
214 | return; | ||
215 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p2->id)); | 210 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p2->id)); |
216 | 211 | ||
217 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 212 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -272,12 +267,7 @@ notify_response_ready (void *cls, size_t size, void *buf) | |||
272 | static void | 267 | static void |
273 | sendtask_response_task (void *cls) | 268 | sendtask_response_task (void *cls) |
274 | { | 269 | { |
275 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
276 | |||
277 | send_task = NULL; | 270 | send_task = NULL; |
278 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
279 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
280 | return; | ||
281 | { | 271 | { |
282 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id)); | 272 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id)); |
283 | 273 | ||
diff --git a/src/transport/test_transport_api_manipulation_recv_tcp.c b/src/transport/test_transport_api_manipulation_recv_tcp.c index 7b82236f9..02c9408a6 100644 --- a/src/transport/test_transport_api_manipulation_recv_tcp.c +++ b/src/transport/test_transport_api_manipulation_recv_tcp.c | |||
@@ -292,12 +292,7 @@ notify_ready (void *cls, size_t size, void *buf) | |||
292 | static void | 292 | static void |
293 | sendtask (void *cls) | 293 | sendtask (void *cls) |
294 | { | 294 | { |
295 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
296 | |||
297 | send_task = NULL; | 295 | send_task = NULL; |
298 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
299 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
300 | return; | ||
301 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id)); | 296 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id)); |
302 | 297 | ||
303 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 298 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
diff --git a/src/transport/test_transport_api_manipulation_send_tcp.c b/src/transport/test_transport_api_manipulation_send_tcp.c index 22b420c27..e031b7111 100644 --- a/src/transport/test_transport_api_manipulation_send_tcp.c +++ b/src/transport/test_transport_api_manipulation_send_tcp.c | |||
@@ -288,12 +288,8 @@ sendtask (void *cls) | |||
288 | { | 288 | { |
289 | struct GNUNET_TIME_Relative delay; | 289 | struct GNUNET_TIME_Relative delay; |
290 | struct GNUNET_ATS_Properties prop; | 290 | struct GNUNET_ATS_Properties prop; |
291 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
292 | 291 | ||
293 | send_task = NULL; | 292 | send_task = NULL; |
294 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
295 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
296 | return; | ||
297 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id)); | 293 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id)); |
298 | 294 | ||
299 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 295 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
diff --git a/src/transport/test_transport_api_monitor_peers.c b/src/transport/test_transport_api_monitor_peers.c index 79b39325c..549394944 100644 --- a/src/transport/test_transport_api_monitor_peers.c +++ b/src/transport/test_transport_api_monitor_peers.c | |||
@@ -262,12 +262,7 @@ notify_ready (void *cls, size_t size, void *buf) | |||
262 | static void | 262 | static void |
263 | sendtask (void *cls) | 263 | sendtask (void *cls) |
264 | { | 264 | { |
265 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
266 | |||
267 | send_task = NULL; | 265 | send_task = NULL; |
268 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
269 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
270 | return; | ||
271 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id)); | 266 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id)); |
272 | 267 | ||
273 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 268 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
diff --git a/src/transport/test_transport_api_monitor_validation.c b/src/transport/test_transport_api_monitor_validation.c index 37b8494f1..49550e011 100644 --- a/src/transport/test_transport_api_monitor_validation.c +++ b/src/transport/test_transport_api_monitor_validation.c | |||
@@ -275,12 +275,7 @@ notify_ready (void *cls, | |||
275 | static void | 275 | static void |
276 | sendtask (void *cls) | 276 | sendtask (void *cls) |
277 | { | 277 | { |
278 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
279 | |||
280 | send_task = NULL; | 278 | send_task = NULL; |
281 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
282 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
283 | return; | ||
284 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id)); | 279 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id)); |
285 | 280 | ||
286 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 281 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
diff --git a/src/transport/test_transport_api_restart_1peer.c b/src/transport/test_transport_api_restart_1peer.c index adec15f4f..50f9ebb9c 100644 --- a/src/transport/test_transport_api_restart_1peer.c +++ b/src/transport/test_transport_api_restart_1peer.c | |||
@@ -260,12 +260,7 @@ notify_ready (void *cls, size_t size, void *buf) | |||
260 | static void | 260 | static void |
261 | sendtask (void *cls) | 261 | sendtask (void *cls) |
262 | { | 262 | { |
263 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
264 | |||
265 | send_task = NULL; | 263 | send_task = NULL; |
266 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
267 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
268 | return; | ||
269 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id)); | 264 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id)); |
270 | 265 | ||
271 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 266 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
diff --git a/src/transport/test_transport_api_restart_2peers.c b/src/transport/test_transport_api_restart_2peers.c index 2a669c9a0..18cc87c78 100644 --- a/src/transport/test_transport_api_restart_2peers.c +++ b/src/transport/test_transport_api_restart_2peers.c | |||
@@ -266,13 +266,7 @@ notify_ready (void *cls, | |||
266 | static void | 266 | static void |
267 | sendtask (void *cls) | 267 | sendtask (void *cls) |
268 | { | 268 | { |
269 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
270 | |||
271 | send_task = NULL; | 269 | send_task = NULL; |
272 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
273 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
274 | return; | ||
275 | |||
276 | { | 270 | { |
277 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id)); | 271 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id)); |
278 | 272 | ||
diff --git a/src/transport/test_transport_api_timeout.c b/src/transport/test_transport_api_timeout.c index aa9884a2e..89fabdefd 100644 --- a/src/transport/test_transport_api_timeout.c +++ b/src/transport/test_transport_api_timeout.c | |||
@@ -185,13 +185,8 @@ static void | |||
185 | timer (void *cls) | 185 | timer (void *cls) |
186 | { | 186 | { |
187 | static int percentage; | 187 | static int percentage; |
188 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
189 | 188 | ||
190 | timer_task = NULL; | 189 | timer_task = NULL; |
191 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
192 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
193 | return; | ||
194 | |||
195 | percentage += 10; | 190 | percentage += 10; |
196 | time_running = | 191 | time_running = |
197 | GNUNET_TIME_relative_add (time_running, | 192 | GNUNET_TIME_relative_add (time_running, |
@@ -213,6 +208,7 @@ timer (void *cls) | |||
213 | } | 208 | } |
214 | } | 209 | } |
215 | 210 | ||
211 | |||
216 | static void | 212 | static void |
217 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | 213 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) |
218 | { | 214 | { |
diff --git a/src/transport/test_transport_startonly.c b/src/transport/test_transport_startonly.c index d49e3a8c0..7dd4984e2 100644 --- a/src/transport/test_transport_startonly.c +++ b/src/transport/test_transport_startonly.c | |||
@@ -67,15 +67,9 @@ end () | |||
67 | static void | 67 | static void |
68 | end_badly (void *cls) | 68 | end_badly (void *cls) |
69 | { | 69 | { |
70 | const struct GNUNET_SCHEDULER_TaskContext *tc; | 70 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
71 | 71 | "Fail! Stopping peers\n"); | |
72 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
73 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Fail! Stopping peers\n"); | ||
74 | |||
75 | timeout_task = NULL; | 72 | timeout_task = NULL; |
76 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
77 | return; | ||
78 | |||
79 | if (p1 != NULL) | 73 | if (p1 != NULL) |
80 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); | 74 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); |
81 | if (NULL != tth) | 75 | if (NULL != tth) |
@@ -83,6 +77,7 @@ end_badly (void *cls) | |||
83 | ret = GNUNET_SYSERR; | 77 | ret = GNUNET_SYSERR; |
84 | } | 78 | } |
85 | 79 | ||
80 | |||
86 | static void | 81 | static void |
87 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | 82 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) |
88 | { | 83 | { |
@@ -91,6 +86,7 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
91 | connected++; | 86 | connected++; |
92 | } | 87 | } |
93 | 88 | ||
89 | |||
94 | static void | 90 | static void |
95 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | 91 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) |
96 | { | 92 | { |
@@ -98,6 +94,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
98 | GNUNET_i2s (peer)); | 94 | GNUNET_i2s (peer)); |
99 | } | 95 | } |
100 | 96 | ||
97 | |||
101 | static void | 98 | static void |
102 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 99 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
103 | const struct GNUNET_MessageHeader *message) | 100 | const struct GNUNET_MessageHeader *message) |
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c index 652a4e08f..4a514ea72 100644 --- a/src/transport/transport-testing.c +++ b/src/transport/transport-testing.c | |||
@@ -220,7 +220,7 @@ hello_offered (void *cls) | |||
220 | /** | 220 | /** |
221 | * Offer the current HELLO of P2 to P1. | 221 | * Offer the current HELLO of P2 to P1. |
222 | * | 222 | * |
223 | * @param cls our `struct GNUNET_TRANSPORT_TESTING_ConnectRequest ` | 223 | * @param cls our `struct GNUNET_TRANSPORT_TESTING_ConnectRequest` |
224 | */ | 224 | */ |
225 | static void | 225 | static void |
226 | offer_hello (void *cls) | 226 | offer_hello (void *cls) |
@@ -228,12 +228,8 @@ offer_hello (void *cls) | |||
228 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls; | 228 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls; |
229 | struct PeerContext *p1 = cc->p1; | 229 | struct PeerContext *p1 = cc->p1; |
230 | struct PeerContext *p2 = cc->p2; | 230 | struct PeerContext *p2 = cc->p2; |
231 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
232 | 231 | ||
233 | cc->tct = NULL; | 232 | cc->tct = NULL; |
234 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
235 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
236 | return; | ||
237 | { | 233 | { |
238 | char *p2_s = GNUNET_strdup (GNUNET_i2s (&p2->id)); | 234 | char *p2_s = GNUNET_strdup (GNUNET_i2s (&p2->id)); |
239 | 235 | ||
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index 6fc538f25..59f249686 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c | |||
@@ -1196,15 +1196,8 @@ static void | |||
1196 | reconnect (void *cls) | 1196 | reconnect (void *cls) |
1197 | { | 1197 | { |
1198 | struct GNUNET_TRANSPORT_Handle *h = cls; | 1198 | struct GNUNET_TRANSPORT_Handle *h = cls; |
1199 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
1200 | 1199 | ||
1201 | h->reconnect_task = NULL; | 1200 | h->reconnect_task = NULL; |
1202 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
1203 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
1204 | { | ||
1205 | /* shutdown, just give up */ | ||
1206 | return; | ||
1207 | } | ||
1208 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1201 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1209 | "Connecting to transport service.\n"); | 1202 | "Connecting to transport service.\n"); |
1210 | GNUNET_assert (NULL == h->client); | 1203 | GNUNET_assert (NULL == h->client); |
diff --git a/src/util/bandwidth.c b/src/util/bandwidth.c index 2df2a9449..364c46977 100644 --- a/src/util/bandwidth.c +++ b/src/util/bandwidth.c | |||
@@ -149,7 +149,6 @@ excess_trigger (void *cls) | |||
149 | struct GNUNET_BANDWIDTH_Tracker *av = cls; | 149 | struct GNUNET_BANDWIDTH_Tracker *av = cls; |
150 | 150 | ||
151 | av->excess_task = NULL; | 151 | av->excess_task = NULL; |
152 | |||
153 | if (NULL != av->excess_cb) | 152 | if (NULL != av->excess_cb) |
154 | av->excess_cb (av->excess_cb_cls); | 153 | av->excess_cb (av->excess_cb_cls); |
155 | } | 154 | } |
diff --git a/src/util/client.c b/src/util/client.c index f93fd1d10..d00e8bbd0 100644 --- a/src/util/client.c +++ b/src/util/client.c | |||
@@ -578,7 +578,7 @@ receive_helper (void *cls, | |||
578 | /** | 578 | /** |
579 | * Continuation to call the receive callback. | 579 | * Continuation to call the receive callback. |
580 | * | 580 | * |
581 | * @param cls our handle to the client connection | 581 | * @param cls our handle to the client connection |
582 | */ | 582 | */ |
583 | static void | 583 | static void |
584 | receive_task (void *cls) | 584 | receive_task (void *cls) |
@@ -611,7 +611,8 @@ receive_task (void *cls) | |||
611 | GNUNET_assert (GNUNET_YES == client->msg_complete); | 611 | GNUNET_assert (GNUNET_YES == client->msg_complete); |
612 | GNUNET_assert (client->received_pos >= msize); | 612 | GNUNET_assert (client->received_pos >= msize); |
613 | memcpy (msg, cmsg, msize); | 613 | memcpy (msg, cmsg, msize); |
614 | memmove (client->received_buf, &client->received_buf[msize], | 614 | memmove (client->received_buf, |
615 | &client->received_buf[msize], | ||
615 | client->received_pos - msize); | 616 | client->received_pos - msize); |
616 | client->received_pos -= msize; | 617 | client->received_pos -= msize; |
617 | client->msg_complete = GNUNET_NO; | 618 | client->msg_complete = GNUNET_NO; |
@@ -655,7 +656,8 @@ GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *client, | |||
655 | (GNUNET_SYSERR == client->in_receive) ) | 656 | (GNUNET_SYSERR == client->in_receive) ) |
656 | { | 657 | { |
657 | GNUNET_assert (NULL == client->receive_task); | 658 | GNUNET_assert (NULL == client->receive_task); |
658 | client->receive_task = GNUNET_SCHEDULER_add_now (&receive_task, client); | 659 | client->receive_task = GNUNET_SCHEDULER_add_now (&receive_task, |
660 | client); | ||
659 | return; | 661 | return; |
660 | } | 662 | } |
661 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 663 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -703,7 +705,7 @@ struct GNUNET_CLIENT_TestHandle | |||
703 | /** | 705 | /** |
704 | * ID of task used for asynchronous operations. | 706 | * ID of task used for asynchronous operations. |
705 | */ | 707 | */ |
706 | struct GNUNET_SCHEDULER_Task * task; | 708 | struct GNUNET_SCHEDULER_Task *task; |
707 | 709 | ||
708 | /** | 710 | /** |
709 | * Final result to report back (once known). | 711 | * Final result to report back (once known). |
@@ -1081,19 +1083,9 @@ static void | |||
1081 | client_delayed_retry (void *cls) | 1083 | client_delayed_retry (void *cls) |
1082 | { | 1084 | { |
1083 | struct GNUNET_CLIENT_TransmitHandle *th = cls; | 1085 | struct GNUNET_CLIENT_TransmitHandle *th = cls; |
1084 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
1085 | struct GNUNET_TIME_Relative delay; | 1086 | struct GNUNET_TIME_Relative delay; |
1086 | 1087 | ||
1087 | th->reconnect_task = NULL; | 1088 | th->reconnect_task = NULL; |
1088 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
1089 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
1090 | { | ||
1091 | /* give up, was shutdown */ | ||
1092 | th->client->th = NULL; | ||
1093 | th->notify (th->notify_cls, 0, NULL); | ||
1094 | GNUNET_free (th); | ||
1095 | return; | ||
1096 | } | ||
1097 | th->client->connection = | 1089 | th->client->connection = |
1098 | do_connect (th->client->service_name, | 1090 | do_connect (th->client->service_name, |
1099 | th->client->cfg, | 1091 | th->client->cfg, |
@@ -1112,13 +1104,16 @@ client_delayed_retry (void *cls) | |||
1112 | GNUNET_assert (NULL == th->th); | 1104 | GNUNET_assert (NULL == th->th); |
1113 | GNUNET_assert (NULL == th->reconnect_task); | 1105 | GNUNET_assert (NULL == th->reconnect_task); |
1114 | th->reconnect_task = | 1106 | th->reconnect_task = |
1115 | GNUNET_SCHEDULER_add_delayed (delay, &client_delayed_retry, th); | 1107 | GNUNET_SCHEDULER_add_delayed (delay, |
1108 | &client_delayed_retry, | ||
1109 | th); | ||
1116 | return; | 1110 | return; |
1117 | } | 1111 | } |
1118 | th->th = | 1112 | th->th = |
1119 | GNUNET_CONNECTION_notify_transmit_ready (th->client->connection, th->size, | 1113 | GNUNET_CONNECTION_notify_transmit_ready (th->client->connection, th->size, |
1120 | GNUNET_TIME_absolute_get_remaining | 1114 | GNUNET_TIME_absolute_get_remaining |
1121 | (th->timeout), &client_notify, | 1115 | (th->timeout), |
1116 | &client_notify, | ||
1122 | th); | 1117 | th); |
1123 | if (NULL == th->th) | 1118 | if (NULL == th->th) |
1124 | { | 1119 | { |
@@ -1149,22 +1144,18 @@ client_notify (void *cls, | |||
1149 | struct GNUNET_CLIENT_Connection *client = th->client; | 1144 | struct GNUNET_CLIENT_Connection *client = th->client; |
1150 | size_t ret; | 1145 | size_t ret; |
1151 | struct GNUNET_TIME_Relative delay; | 1146 | struct GNUNET_TIME_Relative delay; |
1152 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
1153 | |||
1154 | 1147 | ||
1155 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1148 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1156 | "client_notify is running\n"); | 1149 | "client_notify is running\n"); |
1157 | th->th = NULL; | 1150 | th->th = NULL; |
1158 | client->th = NULL; | 1151 | client->th = NULL; |
1159 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
1160 | if (NULL == buf) | 1152 | if (NULL == buf) |
1161 | { | 1153 | { |
1162 | delay = GNUNET_TIME_absolute_get_remaining (th->timeout); | 1154 | delay = GNUNET_TIME_absolute_get_remaining (th->timeout); |
1163 | delay.rel_value_us /= 2; | 1155 | delay.rel_value_us /= 2; |
1164 | if ( (GNUNET_YES != th->auto_retry) || | 1156 | if ( (GNUNET_YES != th->auto_retry) || |
1165 | (0 == --th->attempts_left) || | 1157 | (0 == --th->attempts_left) || |
1166 | (delay.rel_value_us < 1)|| | 1158 | (delay.rel_value_us < 1) ) |
1167 | (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))) | ||
1168 | { | 1159 | { |
1169 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1160 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1170 | "Transmission failed %u times, giving up.\n", | 1161 | "Transmission failed %u times, giving up.\n", |
@@ -1198,7 +1189,9 @@ client_notify (void *cls, | |||
1198 | GNUNET_assert (NULL == th->reconnect_task); | 1189 | GNUNET_assert (NULL == th->reconnect_task); |
1199 | GNUNET_assert (NULL == th->th); | 1190 | GNUNET_assert (NULL == th->th); |
1200 | th->reconnect_task = | 1191 | th->reconnect_task = |
1201 | GNUNET_SCHEDULER_add_delayed (delay, &client_delayed_retry, th); | 1192 | GNUNET_SCHEDULER_add_delayed (delay, |
1193 | &client_delayed_retry, | ||
1194 | th); | ||
1202 | return 0; | 1195 | return 0; |
1203 | } | 1196 | } |
1204 | GNUNET_assert (size >= th->size); | 1197 | GNUNET_assert (size >= th->size); |
diff --git a/src/util/client_manager.c b/src/util/client_manager.c index f334bb5b6..026837841 100644 --- a/src/util/client_manager.c +++ b/src/util/client_manager.c | |||
@@ -243,8 +243,10 @@ static void | |||
243 | schedule_disconnect (void *cls) | 243 | schedule_disconnect (void *cls) |
244 | { | 244 | { |
245 | struct GNUNET_CLIENT_MANAGER_Connection *mgr = cls; | 245 | struct GNUNET_CLIENT_MANAGER_Connection *mgr = cls; |
246 | |||
246 | GNUNET_CLIENT_MANAGER_disconnect (mgr, GNUNET_NO, | 247 | GNUNET_CLIENT_MANAGER_disconnect (mgr, GNUNET_NO, |
247 | mgr->disconnect_cb, mgr->disconnect_cls); | 248 | mgr->disconnect_cb, |
249 | mgr->disconnect_cls); | ||
248 | } | 250 | } |
249 | 251 | ||
250 | 252 | ||
@@ -263,9 +265,10 @@ schedule_disconnect (void *cls) | |||
263 | static size_t | 265 | static size_t |
264 | send_next_message (void *cls, size_t buf_size, void *buf) | 266 | send_next_message (void *cls, size_t buf_size, void *buf) |
265 | { | 267 | { |
266 | LOG (GNUNET_ERROR_TYPE_DEBUG, "send_next_message()\n"); | ||
267 | struct GNUNET_CLIENT_MANAGER_Connection *mgr = cls; | 268 | struct GNUNET_CLIENT_MANAGER_Connection *mgr = cls; |
268 | 269 | ||
270 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
271 | "send_next_message()\n"); | ||
269 | if (NULL == buf) | 272 | if (NULL == buf) |
270 | { | 273 | { |
271 | /* disconnected */ | 274 | /* disconnected */ |
@@ -282,7 +285,9 @@ send_next_message (void *cls, size_t buf_size, void *buf) | |||
282 | GNUNET_assert (size <= buf_size); | 285 | GNUNET_assert (size <= buf_size); |
283 | memcpy (buf, mqi->msg, size); | 286 | memcpy (buf, mqi->msg, size); |
284 | 287 | ||
285 | GNUNET_CONTAINER_DLL_remove (mgr->tmit_head, mgr->tmit_tail, mqi); | 288 | GNUNET_CONTAINER_DLL_remove (mgr->tmit_head, |
289 | mgr->tmit_tail, | ||
290 | mqi); | ||
286 | GNUNET_free (mqi->msg); | 291 | GNUNET_free (mqi->msg); |
287 | GNUNET_free (mqi); | 292 | GNUNET_free (mqi); |
288 | 293 | ||
@@ -292,7 +297,7 @@ send_next_message (void *cls, size_t buf_size, void *buf) | |||
292 | } | 297 | } |
293 | else if (GNUNET_YES == mgr->is_disconnecting) | 298 | else if (GNUNET_YES == mgr->is_disconnecting) |
294 | { | 299 | { |
295 | GNUNET_SCHEDULER_add_now (&schedule_disconnect, mgr); | 300 | (void) GNUNET_SCHEDULER_add_now (&schedule_disconnect, mgr); |
296 | return size; | 301 | return size; |
297 | } | 302 | } |
298 | 303 | ||
@@ -322,7 +327,8 @@ transmit_next (struct GNUNET_CLIENT_MANAGER_Connection *mgr) | |||
322 | { | 327 | { |
323 | if (GNUNET_YES == mgr->is_disconnecting) | 328 | if (GNUNET_YES == mgr->is_disconnecting) |
324 | GNUNET_CLIENT_MANAGER_disconnect (mgr, GNUNET_NO, | 329 | GNUNET_CLIENT_MANAGER_disconnect (mgr, GNUNET_NO, |
325 | mgr->disconnect_cb, mgr->disconnect_cls); | 330 | mgr->disconnect_cb, |
331 | mgr->disconnect_cls); | ||
326 | return; | 332 | return; |
327 | } | 333 | } |
328 | 334 | ||
@@ -346,14 +352,15 @@ static void | |||
346 | schedule_reconnect (void *cls) | 352 | schedule_reconnect (void *cls) |
347 | { | 353 | { |
348 | struct GNUNET_CLIENT_MANAGER_Connection *mgr = cls; | 354 | struct GNUNET_CLIENT_MANAGER_Connection *mgr = cls; |
349 | mgr->reconnect_task = NULL; | ||
350 | 355 | ||
356 | mgr->reconnect_task = NULL; | ||
351 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 357 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
352 | "Connecting to %s service.\n", mgr->service_name); | 358 | "Connecting to %s service.\n", |
359 | mgr->service_name); | ||
353 | GNUNET_assert (NULL == mgr->client); | 360 | GNUNET_assert (NULL == mgr->client); |
354 | mgr->client = GNUNET_CLIENT_connect (mgr->service_name, mgr->cfg); | 361 | mgr->client = GNUNET_CLIENT_connect (mgr->service_name, |
362 | mgr->cfg); | ||
355 | GNUNET_assert (NULL != mgr->client); | 363 | GNUNET_assert (NULL != mgr->client); |
356 | |||
357 | transmit_next (mgr); | 364 | transmit_next (mgr); |
358 | } | 365 | } |
359 | 366 | ||
@@ -373,16 +380,17 @@ schedule_reconnect (void *cls) | |||
373 | struct GNUNET_CLIENT_MANAGER_Connection * | 380 | struct GNUNET_CLIENT_MANAGER_Connection * |
374 | GNUNET_CLIENT_MANAGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | 381 | GNUNET_CLIENT_MANAGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, |
375 | const char *service_name, | 382 | const char *service_name, |
376 | const struct | 383 | const struct GNUNET_CLIENT_MANAGER_MessageHandler *handlers) |
377 | GNUNET_CLIENT_MANAGER_MessageHandler *handlers) | ||
378 | { | 384 | { |
379 | struct GNUNET_CLIENT_MANAGER_Connection * | 385 | struct GNUNET_CLIENT_MANAGER_Connection *mgr; |
380 | mgr = GNUNET_malloc (sizeof (*mgr)); | 386 | |
387 | mgr = GNUNET_new (struct GNUNET_CLIENT_MANAGER_Connection); | ||
381 | mgr->cfg = cfg; | 388 | mgr->cfg = cfg; |
382 | mgr->service_name = service_name; | 389 | mgr->service_name = service_name; |
383 | mgr->handlers = handlers; | 390 | mgr->handlers = handlers; |
384 | mgr->reconnect_delay = GNUNET_TIME_UNIT_ZERO; | 391 | mgr->reconnect_delay = GNUNET_TIME_UNIT_ZERO; |
385 | mgr->reconnect_task = GNUNET_SCHEDULER_add_now (&schedule_reconnect, mgr); | 392 | mgr->reconnect_task = GNUNET_SCHEDULER_add_now (&schedule_reconnect, |
393 | mgr); | ||
386 | return mgr; | 394 | return mgr; |
387 | } | 395 | } |
388 | 396 | ||
@@ -405,7 +413,9 @@ GNUNET_CLIENT_MANAGER_disconnect (struct GNUNET_CLIENT_MANAGER_Connection *mgr, | |||
405 | GNUNET_ContinuationCallback disconnect_cb, | 413 | GNUNET_ContinuationCallback disconnect_cb, |
406 | void *cls) | 414 | void *cls) |
407 | { | 415 | { |
408 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting (%d)\n", transmit_queue); | 416 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
417 | "Disconnecting (%d)\n", | ||
418 | transmit_queue); | ||
409 | mgr->disconnect_cb = disconnect_cb; | 419 | mgr->disconnect_cb = disconnect_cb; |
410 | mgr->disconnect_cls = cls; | 420 | mgr->disconnect_cls = cls; |
411 | if (NULL != mgr->tmit_head) | 421 | if (NULL != mgr->tmit_head) |
@@ -424,7 +434,7 @@ GNUNET_CLIENT_MANAGER_disconnect (struct GNUNET_CLIENT_MANAGER_Connection *mgr, | |||
424 | GNUNET_CLIENT_MANAGER_drop_queue (mgr); | 434 | GNUNET_CLIENT_MANAGER_drop_queue (mgr); |
425 | } | 435 | } |
426 | } | 436 | } |
427 | if (mgr->reconnect_task != NULL) | 437 | if (NULL != mgr->reconnect_task) |
428 | { | 438 | { |
429 | GNUNET_SCHEDULER_cancel (mgr->reconnect_task); | 439 | GNUNET_SCHEDULER_cancel (mgr->reconnect_task); |
430 | mgr->reconnect_task = NULL; | 440 | mgr->reconnect_task = NULL; |
@@ -473,7 +483,9 @@ GNUNET_CLIENT_MANAGER_reconnect (struct GNUNET_CLIENT_MANAGER_Connection *mgr) | |||
473 | "Scheduling task to reconnect to service in %s.\n", | 483 | "Scheduling task to reconnect to service in %s.\n", |
474 | GNUNET_STRINGS_relative_time_to_string (mgr->reconnect_delay, GNUNET_YES)); | 484 | GNUNET_STRINGS_relative_time_to_string (mgr->reconnect_delay, GNUNET_YES)); |
475 | mgr->reconnect_task = | 485 | mgr->reconnect_task = |
476 | GNUNET_SCHEDULER_add_delayed (mgr->reconnect_delay, &schedule_reconnect, mgr); | 486 | GNUNET_SCHEDULER_add_delayed (mgr->reconnect_delay, |
487 | &schedule_reconnect, | ||
488 | mgr); | ||
477 | mgr->reconnect_delay = GNUNET_TIME_STD_BACKOFF (mgr->reconnect_delay); | 489 | mgr->reconnect_delay = GNUNET_TIME_STD_BACKOFF (mgr->reconnect_delay); |
478 | } | 490 | } |
479 | 491 | ||
@@ -491,9 +503,13 @@ void | |||
491 | GNUNET_CLIENT_MANAGER_transmit (struct GNUNET_CLIENT_MANAGER_Connection *mgr, | 503 | GNUNET_CLIENT_MANAGER_transmit (struct GNUNET_CLIENT_MANAGER_Connection *mgr, |
492 | struct GNUNET_MessageHeader *msg) | 504 | struct GNUNET_MessageHeader *msg) |
493 | { | 505 | { |
494 | struct MessageQueueItem *mqi = GNUNET_malloc (sizeof (*mqi)); | 506 | struct MessageQueueItem *mqi; |
507 | |||
508 | mqi = GNUNET_new (struct MessageQueueItem); | ||
495 | mqi->msg = GNUNET_copy_message (msg); | 509 | mqi->msg = GNUNET_copy_message (msg); |
496 | GNUNET_CONTAINER_DLL_insert_tail (mgr->tmit_head, mgr->tmit_tail, mqi); | 510 | GNUNET_CONTAINER_DLL_insert_tail (mgr->tmit_head, |
511 | mgr->tmit_tail, | ||
512 | mqi); | ||
497 | transmit_next (mgr); | 513 | transmit_next (mgr); |
498 | } | 514 | } |
499 | 515 | ||
@@ -511,9 +527,13 @@ void | |||
511 | GNUNET_CLIENT_MANAGER_transmit_now (struct GNUNET_CLIENT_MANAGER_Connection *mgr, | 527 | GNUNET_CLIENT_MANAGER_transmit_now (struct GNUNET_CLIENT_MANAGER_Connection *mgr, |
512 | struct GNUNET_MessageHeader *msg) | 528 | struct GNUNET_MessageHeader *msg) |
513 | { | 529 | { |
514 | struct MessageQueueItem *mqi = GNUNET_malloc (sizeof (*mqi)); | 530 | struct MessageQueueItem *mqi; |
531 | |||
532 | mqi = GNUNET_new (struct MessageQueueItem); | ||
515 | mqi->msg = GNUNET_copy_message (msg); | 533 | mqi->msg = GNUNET_copy_message (msg); |
516 | GNUNET_CONTAINER_DLL_insert (mgr->tmit_head, mgr->tmit_tail, mqi); | 534 | GNUNET_CONTAINER_DLL_insert (mgr->tmit_head, |
535 | mgr->tmit_tail, | ||
536 | mqi); | ||
517 | transmit_next (mgr); | 537 | transmit_next (mgr); |
518 | } | 538 | } |
519 | 539 | ||
@@ -527,7 +547,10 @@ GNUNET_CLIENT_MANAGER_transmit_now (struct GNUNET_CLIENT_MANAGER_Connection *mgr | |||
527 | void | 547 | void |
528 | GNUNET_CLIENT_MANAGER_drop_queue (struct GNUNET_CLIENT_MANAGER_Connection *mgr) | 548 | GNUNET_CLIENT_MANAGER_drop_queue (struct GNUNET_CLIENT_MANAGER_Connection *mgr) |
529 | { | 549 | { |
530 | struct MessageQueueItem *cur, *next = mgr->tmit_head; | 550 | struct MessageQueueItem *cur; |
551 | struct MessageQueueItem *next; | ||
552 | |||
553 | next = mgr->tmit_head; | ||
531 | while (NULL != next) | 554 | while (NULL != next) |
532 | { | 555 | { |
533 | cur = next; | 556 | cur = next; |
@@ -629,15 +652,14 @@ GNUNET_CLIENT_MANAGER_op_get_next_id (struct GNUNET_CLIENT_MANAGER_Connection *m | |||
629 | * @return Operation, or NULL if not found. | 652 | * @return Operation, or NULL if not found. |
630 | */ | 653 | */ |
631 | static struct OperationListItem * | 654 | static struct OperationListItem * |
632 | op_find (struct GNUNET_CLIENT_MANAGER_Connection *mgr, uint64_t op_id) | 655 | op_find (struct GNUNET_CLIENT_MANAGER_Connection *mgr, |
656 | uint64_t op_id) | ||
633 | { | 657 | { |
634 | struct OperationListItem *op = mgr->op_head; | 658 | struct OperationListItem *op; |
635 | while (NULL != op) | 659 | |
636 | { | 660 | for (op = mgr->op_head; NULL != op; op = op->next) |
637 | if (op->op_id == op_id) | 661 | if (op->op_id == op_id) |
638 | return op; | 662 | return op; |
639 | op = op->next; | ||
640 | } | ||
641 | return NULL; | 663 | return NULL; |
642 | } | 664 | } |
643 | 665 | ||
@@ -691,17 +713,21 @@ GNUNET_CLIENT_MANAGER_op_add (struct GNUNET_CLIENT_MANAGER_Connection *mgr, | |||
691 | GNUNET_ResultCallback result_cb, | 713 | GNUNET_ResultCallback result_cb, |
692 | void *cls) | 714 | void *cls) |
693 | { | 715 | { |
716 | struct OperationListItem *op; | ||
717 | |||
694 | if (NULL == result_cb) | 718 | if (NULL == result_cb) |
695 | return 0; | 719 | return 0; |
696 | 720 | op = GNUNET_new (struct OperationListItem); | |
697 | struct OperationListItem *op = GNUNET_malloc (sizeof (*op)); | ||
698 | op->op_id = GNUNET_CLIENT_MANAGER_op_get_next_id (mgr); | 721 | op->op_id = GNUNET_CLIENT_MANAGER_op_get_next_id (mgr); |
699 | op->result_cb = result_cb; | 722 | op->result_cb = result_cb; |
700 | op->cls = cls; | 723 | op->cls = cls; |
701 | GNUNET_CONTAINER_DLL_insert_tail (mgr->op_head, mgr->op_tail, op); | 724 | GNUNET_CONTAINER_DLL_insert_tail (mgr->op_head, |
702 | 725 | mgr->op_tail, | |
726 | op); | ||
703 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 727 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
704 | "%p Added operation #%" PRIu64 "\n", mgr, op->op_id); | 728 | "%p Added operation #%" PRIu64 "\n", |
729 | mgr, | ||
730 | op->op_id); | ||
705 | return op->op_id; | 731 | return op->op_id; |
706 | } | 732 | } |
707 | 733 | ||
@@ -730,8 +756,11 @@ GNUNET_CLIENT_MANAGER_op_add (struct GNUNET_CLIENT_MANAGER_Connection *mgr, | |||
730 | */ | 756 | */ |
731 | static int | 757 | static int |
732 | op_result (struct GNUNET_CLIENT_MANAGER_Connection *mgr, | 758 | op_result (struct GNUNET_CLIENT_MANAGER_Connection *mgr, |
733 | uint64_t op_id, int64_t result_code, | 759 | uint64_t op_id, |
734 | const void *data, uint16_t data_size, uint8_t cancel) | 760 | int64_t result_code, |
761 | const void *data, | ||
762 | uint16_t data_size, | ||
763 | uint8_t cancel) | ||
735 | { | 764 | { |
736 | if (0 == op_id) | 765 | if (0 == op_id) |
737 | return GNUNET_NO; | 766 | return GNUNET_NO; |
@@ -744,11 +773,15 @@ op_result (struct GNUNET_CLIENT_MANAGER_Connection *mgr, | |||
744 | return GNUNET_NO; | 773 | return GNUNET_NO; |
745 | } | 774 | } |
746 | 775 | ||
747 | GNUNET_CONTAINER_DLL_remove (mgr->op_head, mgr->op_tail, op); | 776 | GNUNET_CONTAINER_DLL_remove (mgr->op_head, |
748 | 777 | mgr->op_tail, | |
749 | if (GNUNET_YES != cancel && NULL != op->result_cb) | 778 | op); |
750 | op->result_cb (op->cls, result_code, data, data_size); | ||
751 | 779 | ||
780 | if ( (GNUNET_YES != cancel) && | ||
781 | (NULL != op->result_cb) ) | ||
782 | op->result_cb (op->cls, | ||
783 | result_code, data, | ||
784 | data_size); | ||
752 | GNUNET_free (op); | 785 | GNUNET_free (op); |
753 | return GNUNET_YES; | 786 | return GNUNET_YES; |
754 | } | 787 | } |
@@ -773,8 +806,10 @@ op_result (struct GNUNET_CLIENT_MANAGER_Connection *mgr, | |||
773 | */ | 806 | */ |
774 | int | 807 | int |
775 | GNUNET_CLIENT_MANAGER_op_result (struct GNUNET_CLIENT_MANAGER_Connection *mgr, | 808 | GNUNET_CLIENT_MANAGER_op_result (struct GNUNET_CLIENT_MANAGER_Connection *mgr, |
776 | uint64_t op_id, int64_t result_code, | 809 | uint64_t op_id, |
777 | const void *data, uint16_t data_size) | 810 | int64_t result_code, |
811 | const void *data, | ||
812 | uint16_t data_size) | ||
778 | { | 813 | { |
779 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 814 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
780 | "%p Received result for operation #%" PRIu64 ": %" PRId64 " (size: %u)\n", | 815 | "%p Received result for operation #%" PRIu64 ": %" PRId64 " (size: %u)\n", |
@@ -799,6 +834,8 @@ GNUNET_CLIENT_MANAGER_op_cancel (struct GNUNET_CLIENT_MANAGER_Connection *mgr, | |||
799 | uint64_t op_id) | 834 | uint64_t op_id) |
800 | { | 835 | { |
801 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 836 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
802 | "%p Cancelling operation #%" PRIu64 "\n", mgr, op_id); | 837 | "%p Cancelling operation #%" PRIu64 "\n", |
838 | mgr, | ||
839 | op_id); | ||
803 | return op_result (mgr, op_id, 0, NULL, 0, GNUNET_YES); | 840 | return op_result (mgr, op_id, 0, NULL, 0, GNUNET_YES); |
804 | } | 841 | } |
diff --git a/src/util/connection.c b/src/util/connection.c index b3ea3b5af..95fbb13f8 100644 --- a/src/util/connection.c +++ b/src/util/connection.c | |||
@@ -217,7 +217,7 @@ struct GNUNET_CONNECTION_Handle | |||
217 | struct GNUNET_RESOLVER_RequestHandle *dns_active; | 217 | struct GNUNET_RESOLVER_RequestHandle *dns_active; |
218 | 218 | ||
219 | /** | 219 | /** |
220 | * The handle we return for GNUNET_CONNECTION_notify_transmit_ready. | 220 | * The handle we return for #GNUNET_CONNECTION_notify_transmit_ready(). |
221 | */ | 221 | */ |
222 | struct GNUNET_CONNECTION_TransmitHandle nth; | 222 | struct GNUNET_CONNECTION_TransmitHandle nth; |
223 | 223 | ||
@@ -344,7 +344,9 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access_cb, | |||
344 | 344 | ||
345 | addrlen = sizeof (addr); | 345 | addrlen = sizeof (addr); |
346 | sock = | 346 | sock = |
347 | GNUNET_NETWORK_socket_accept (lsock, (struct sockaddr *) &addr, &addrlen); | 347 | GNUNET_NETWORK_socket_accept (lsock, |
348 | (struct sockaddr *) &addr, | ||
349 | &addrlen); | ||
348 | if (NULL == sock) | 350 | if (NULL == sock) |
349 | { | 351 | { |
350 | if (EAGAIN != errno) | 352 | if (EAGAIN != errno) |
@@ -360,7 +362,8 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access_cb, | |||
360 | 362 | ||
361 | sa = (struct sockaddr *) addr; | 363 | sa = (struct sockaddr *) addr; |
362 | v6 = (struct sockaddr_in6 *) addr; | 364 | v6 = (struct sockaddr_in6 *) addr; |
363 | if ((AF_INET6 == sa->sa_family) && (IN6_IS_ADDR_V4MAPPED (&v6->sin6_addr))) | 365 | if ( (AF_INET6 == sa->sa_family) && |
366 | (IN6_IS_ADDR_V4MAPPED (&v6->sin6_addr)) ) | ||
364 | { | 367 | { |
365 | /* convert to V4 address */ | 368 | /* convert to V4 address */ |
366 | v4 = GNUNET_new (struct sockaddr_in); | 369 | v4 = GNUNET_new (struct sockaddr_in); |
@@ -389,15 +392,21 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access_cb, | |||
389 | { | 392 | { |
390 | #if HAVE_GETPEEREID | 393 | #if HAVE_GETPEEREID |
391 | /* most BSDs */ | 394 | /* most BSDs */ |
392 | if (0 == getpeereid (GNUNET_NETWORK_get_fd (sock), &gc.uid, &gc.gid)) | 395 | if (0 == getpeereid (GNUNET_NETWORK_get_fd (sock), |
396 | &gc.uid, | ||
397 | &gc.gid)) | ||
393 | gcp = &gc; | 398 | gcp = &gc; |
394 | #else | 399 | #else |
395 | #ifdef SO_PEERCRED | 400 | #ifdef SO_PEERCRED |
396 | /* largely traditional GNU/Linux */ | 401 | /* largely traditional GNU/Linux */ |
397 | olen = sizeof (uc); | 402 | olen = sizeof (uc); |
398 | if ((0 == | 403 | if ( (0 == |
399 | getsockopt (GNUNET_NETWORK_get_fd (sock), SOL_SOCKET, SO_PEERCRED, &uc, | 404 | getsockopt (GNUNET_NETWORK_get_fd (sock), |
400 | &olen)) && (olen == sizeof (uc))) | 405 | SOL_SOCKET, |
406 | SO_PEERCRED, | ||
407 | &uc, | ||
408 | &olen)) && | ||
409 | (olen == sizeof (uc)) ) | ||
401 | { | 410 | { |
402 | gc.uid = uc.uid; | 411 | gc.uid = uc.uid; |
403 | gc.gid = uc.gid; | 412 | gc.gid = uc.gid; |
@@ -421,8 +430,11 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access_cb, | |||
421 | #endif | 430 | #endif |
422 | } | 431 | } |
423 | 432 | ||
424 | if ((NULL != access_cb) && | 433 | if ( (NULL != access_cb) && |
425 | (GNUNET_YES != (aret = access_cb (access_cb_cls, gcp, uaddr, addrlen)))) | 434 | (GNUNET_YES != (aret = access_cb (access_cb_cls, |
435 | gcp, | ||
436 | uaddr, | ||
437 | addrlen))) ) | ||
426 | { | 438 | { |
427 | if (GNUNET_NO == aret) | 439 | if (GNUNET_NO == aret) |
428 | LOG (GNUNET_ERROR_TYPE_INFO, | 440 | LOG (GNUNET_ERROR_TYPE_INFO, |
@@ -444,7 +456,9 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access_cb, | |||
444 | connection->sock = sock; | 456 | connection->sock = sock; |
445 | LOG (GNUNET_ERROR_TYPE_INFO, | 457 | LOG (GNUNET_ERROR_TYPE_INFO, |
446 | _("Accepting connection from `%s': %p\n"), | 458 | _("Accepting connection from `%s': %p\n"), |
447 | GNUNET_a2s (uaddr, addrlen), connection); | 459 | GNUNET_a2s (uaddr, |
460 | addrlen), | ||
461 | connection); | ||
448 | return connection; | 462 | return connection; |
449 | } | 463 | } |
450 | 464 | ||
@@ -554,7 +568,9 @@ signal_transmit_error (struct GNUNET_CONNECTION_Handle *connection, | |||
554 | return; /* nobody to tell about it */ | 568 | return; /* nobody to tell about it */ |
555 | notify = connection->nth.notify_ready; | 569 | notify = connection->nth.notify_ready; |
556 | connection->nth.notify_ready = NULL; | 570 | connection->nth.notify_ready = NULL; |
557 | notify (connection->nth.notify_ready_cls, 0, NULL); | 571 | notify (connection->nth.notify_ready_cls, |
572 | 0, | ||
573 | NULL); | ||
558 | } | 574 | } |
559 | 575 | ||
560 | 576 | ||
@@ -631,7 +647,8 @@ connect_success_continuation (struct GNUNET_CONNECTION_Handle *connection) | |||
631 | { | 647 | { |
632 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 648 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
633 | "Connection to `%s' succeeded! (%p)\n", | 649 | "Connection to `%s' succeeded! (%p)\n", |
634 | GNUNET_a2s (connection->addr, connection->addrlen), | 650 | GNUNET_a2s (connection->addr, |
651 | connection->addrlen), | ||
635 | connection); | 652 | connection); |
636 | /* trigger jobs that waited for the connection */ | 653 | /* trigger jobs that waited for the connection */ |
637 | if (NULL != connection->receiver) | 654 | if (NULL != connection->receiver) |
@@ -642,7 +659,8 @@ connect_success_continuation (struct GNUNET_CONNECTION_Handle *connection) | |||
642 | GNUNET_assert (NULL == connection->read_task); | 659 | GNUNET_assert (NULL == connection->read_task); |
643 | connection->read_task = | 660 | connection->read_task = |
644 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining | 661 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining |
645 | (connection->receive_timeout), connection->sock, | 662 | (connection->receive_timeout), |
663 | connection->sock, | ||
646 | &receive_ready, connection); | 664 | &receive_ready, connection); |
647 | } | 665 | } |
648 | if (NULL != connection->nth.notify_ready) | 666 | if (NULL != connection->nth.notify_ready) |
@@ -679,21 +697,28 @@ connect_probe_continuation (void *cls) | |||
679 | socklen_t len; | 697 | socklen_t len; |
680 | 698 | ||
681 | GNUNET_assert (NULL != ap->sock); | 699 | GNUNET_assert (NULL != ap->sock); |
682 | GNUNET_CONTAINER_DLL_remove (connection->ap_head, connection->ap_tail, ap); | 700 | GNUNET_CONTAINER_DLL_remove (connection->ap_head, |
701 | connection->ap_tail, | ||
702 | ap); | ||
683 | len = sizeof (error); | 703 | len = sizeof (error); |
684 | errno = 0; | 704 | errno = 0; |
685 | error = 0; | 705 | error = 0; |
686 | tc = GNUNET_SCHEDULER_get_task_context (); | 706 | tc = GNUNET_SCHEDULER_get_task_context (); |
687 | if ((0 == (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)) || | 707 | if ( (0 == (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)) || |
688 | (GNUNET_OK != | 708 | (GNUNET_OK != |
689 | GNUNET_NETWORK_socket_getsockopt (ap->sock, SOL_SOCKET, SO_ERROR, &error, | 709 | GNUNET_NETWORK_socket_getsockopt (ap->sock, |
690 | &len)) || (0 != error)) | 710 | SOL_SOCKET, |
711 | SO_ERROR, | ||
712 | &error, | ||
713 | &len)) || | ||
714 | (0 != error) ) | ||
691 | { | 715 | { |
692 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (ap->sock)); | 716 | GNUNET_break (GNUNET_OK == |
717 | GNUNET_NETWORK_socket_close (ap->sock)); | ||
693 | GNUNET_free (ap); | 718 | GNUNET_free (ap); |
694 | if ((NULL == connection->ap_head) && | 719 | if ( (NULL == connection->ap_head) && |
695 | (GNUNET_NO == connection->dns_active) && | 720 | (GNUNET_NO == connection->dns_active) && |
696 | (NULL == connection->proxy_handshake)) | 721 | (NULL == connection->proxy_handshake) ) |
697 | connect_fail_continuation (connection); | 722 | connect_fail_continuation (connection); |
698 | return; | 723 | return; |
699 | } | 724 | } |
@@ -709,7 +734,9 @@ connect_probe_continuation (void *cls) | |||
709 | { | 734 | { |
710 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pos->sock)); | 735 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pos->sock)); |
711 | GNUNET_SCHEDULER_cancel (pos->task); | 736 | GNUNET_SCHEDULER_cancel (pos->task); |
712 | GNUNET_CONTAINER_DLL_remove (connection->ap_head, connection->ap_tail, pos); | 737 | GNUNET_CONTAINER_DLL_remove (connection->ap_head, |
738 | connection->ap_tail, | ||
739 | pos); | ||
713 | GNUNET_free (pos); | 740 | GNUNET_free (pos); |
714 | } | 741 | } |
715 | connect_success_continuation (connection); | 742 | connect_success_continuation (connection); |
@@ -771,7 +798,8 @@ try_connect_using_address (void *cls, | |||
771 | GNUNET_free (ap); | 798 | GNUNET_free (ap); |
772 | return; /* not supported by us */ | 799 | return; /* not supported by us */ |
773 | } | 800 | } |
774 | ap->sock = GNUNET_NETWORK_socket_create (ap->addr->sa_family, SOCK_STREAM, 0); | 801 | ap->sock = GNUNET_NETWORK_socket_create (ap->addr->sa_family, |
802 | SOCK_STREAM, 0); | ||
775 | if (NULL == ap->sock) | 803 | if (NULL == ap->sock) |
776 | { | 804 | { |
777 | GNUNET_free (ap); | 805 | GNUNET_free (ap); |
@@ -782,7 +810,9 @@ try_connect_using_address (void *cls, | |||
782 | GNUNET_a2s (ap->addr, ap->addrlen), | 810 | GNUNET_a2s (ap->addr, ap->addrlen), |
783 | connection); | 811 | connection); |
784 | if ((GNUNET_OK != | 812 | if ((GNUNET_OK != |
785 | GNUNET_NETWORK_socket_connect (ap->sock, ap->addr, ap->addrlen)) && | 813 | GNUNET_NETWORK_socket_connect (ap->sock, |
814 | ap->addr, | ||
815 | ap->addrlen)) && | ||
786 | (EINPROGRESS != errno)) | 816 | (EINPROGRESS != errno)) |
787 | { | 817 | { |
788 | /* maybe refused / unsupported address, try next */ | 818 | /* maybe refused / unsupported address, try next */ |
@@ -794,17 +824,15 @@ try_connect_using_address (void *cls, | |||
794 | GNUNET_CONTAINER_DLL_insert (connection->ap_head, connection->ap_tail, ap); | 824 | GNUNET_CONTAINER_DLL_insert (connection->ap_head, connection->ap_tail, ap); |
795 | delay = GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT; | 825 | delay = GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT; |
796 | if (NULL != connection->nth.notify_ready) | 826 | if (NULL != connection->nth.notify_ready) |
797 | delay = | 827 | delay = GNUNET_TIME_relative_min (delay, |
798 | GNUNET_TIME_relative_min (delay, | 828 | GNUNET_TIME_absolute_get_remaining (connection->nth.transmit_timeout)); |
799 | GNUNET_TIME_absolute_get_remaining (connection->nth.transmit_timeout)); | ||
800 | if (NULL != connection->receiver) | 829 | if (NULL != connection->receiver) |
801 | delay = | 830 | delay = GNUNET_TIME_relative_min (delay, |
802 | GNUNET_TIME_relative_min (delay, | 831 | GNUNET_TIME_absolute_get_remaining (connection->receive_timeout)); |
803 | GNUNET_TIME_absolute_get_remaining | 832 | ap->task = GNUNET_SCHEDULER_add_write_net (delay, |
804 | (connection->receive_timeout)); | 833 | ap->sock, |
805 | ap->task = | 834 | &connect_probe_continuation, |
806 | GNUNET_SCHEDULER_add_write_net (delay, ap->sock, | 835 | ap); |
807 | &connect_probe_continuation, ap); | ||
808 | } | 836 | } |
809 | 837 | ||
810 | 838 | ||
@@ -833,9 +861,11 @@ GNUNET_CONNECTION_create_from_connect (const struct GNUNET_CONFIGURATION_Handle | |||
833 | connection->port = port; | 861 | connection->port = port; |
834 | connection->hostname = GNUNET_strdup (hostname); | 862 | connection->hostname = GNUNET_strdup (hostname); |
835 | connection->dns_active = | 863 | connection->dns_active = |
836 | GNUNET_RESOLVER_ip_get (connection->hostname, AF_UNSPEC, | 864 | GNUNET_RESOLVER_ip_get (connection->hostname, |
865 | AF_UNSPEC, | ||
837 | GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT, | 866 | GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT, |
838 | &try_connect_using_address, connection); | 867 | &try_connect_using_address, |
868 | connection); | ||
839 | return connection; | 869 | return connection; |
840 | } | 870 | } |
841 | 871 | ||
@@ -865,7 +895,8 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct GNUNET_CONFIGURA | |||
865 | { | 895 | { |
866 | int abstract; | 896 | int abstract; |
867 | 897 | ||
868 | abstract = GNUNET_CONFIGURATION_get_value_yesno (cfg, "TESTING", | 898 | abstract = GNUNET_CONFIGURATION_get_value_yesno (cfg, |
899 | "TESTING", | ||
869 | "USE_ABSTRACT_SOCKETS"); | 900 | "USE_ABSTRACT_SOCKETS"); |
870 | if (GNUNET_YES == abstract) | 901 | if (GNUNET_YES == abstract) |
871 | un->sun_path[0] = '\0'; | 902 | un->sun_path[0] = '\0'; |
@@ -882,7 +913,9 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct GNUNET_CONFIGURA | |||
882 | connection->hostname = NULL; | 913 | connection->hostname = NULL; |
883 | connection->addr = (struct sockaddr *) un; | 914 | connection->addr = (struct sockaddr *) un; |
884 | connection->addrlen = sizeof (struct sockaddr_un); | 915 | connection->addrlen = sizeof (struct sockaddr_un); |
885 | connection->sock = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_STREAM, 0); | 916 | connection->sock = GNUNET_NETWORK_socket_create (AF_UNIX, |
917 | SOCK_STREAM, | ||
918 | 0); | ||
886 | if (NULL == connection->sock) | 919 | if (NULL == connection->sock) |
887 | { | 920 | { |
888 | GNUNET_free (connection->addr); | 921 | GNUNET_free (connection->addr); |
@@ -891,11 +924,14 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct GNUNET_CONFIGURA | |||
891 | return NULL; | 924 | return NULL; |
892 | } | 925 | } |
893 | if ( (GNUNET_OK != | 926 | if ( (GNUNET_OK != |
894 | GNUNET_NETWORK_socket_connect (connection->sock, connection->addr, connection->addrlen)) && | 927 | GNUNET_NETWORK_socket_connect (connection->sock, |
928 | connection->addr, | ||
929 | connection->addrlen)) && | ||
895 | (EINPROGRESS != errno) ) | 930 | (EINPROGRESS != errno) ) |
896 | { | 931 | { |
897 | /* Just return; we expect everything to work eventually so don't fail HARD */ | 932 | /* Just return; we expect everything to work eventually so don't fail HARD */ |
898 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (connection->sock)); | 933 | GNUNET_break (GNUNET_OK == |
934 | GNUNET_NETWORK_socket_close (connection->sock)); | ||
899 | connection->sock = NULL; | 935 | connection->sock = NULL; |
900 | return connection; | 936 | return connection; |
901 | } | 937 | } |
@@ -971,10 +1007,13 @@ GNUNET_CONNECTION_create_from_sockaddr (int af_family, | |||
971 | s = GNUNET_NETWORK_socket_create (af_family, SOCK_STREAM, 0); | 1007 | s = GNUNET_NETWORK_socket_create (af_family, SOCK_STREAM, 0); |
972 | if (NULL == s) | 1008 | if (NULL == s) |
973 | { | 1009 | { |
974 | LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, "socket"); | 1010 | LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, |
1011 | "socket"); | ||
975 | return NULL; | 1012 | return NULL; |
976 | } | 1013 | } |
977 | return GNUNET_CONNECTION_connect_socket (s, serv_addr, addrlen); | 1014 | return GNUNET_CONNECTION_connect_socket (s, |
1015 | serv_addr, | ||
1016 | addrlen); | ||
978 | } | 1017 | } |
979 | 1018 | ||
980 | 1019 | ||
@@ -1054,7 +1093,9 @@ GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *connection) | |||
1054 | { | 1093 | { |
1055 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pos->sock)); | 1094 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pos->sock)); |
1056 | GNUNET_SCHEDULER_cancel (pos->task); | 1095 | GNUNET_SCHEDULER_cancel (pos->task); |
1057 | GNUNET_CONTAINER_DLL_remove (connection->ap_head, connection->ap_tail, pos); | 1096 | GNUNET_CONTAINER_DLL_remove (connection->ap_head, |
1097 | connection->ap_tail, | ||
1098 | pos); | ||
1058 | GNUNET_free (pos); | 1099 | GNUNET_free (pos); |
1059 | } | 1100 | } |
1060 | if ( (NULL != connection->sock) && | 1101 | if ( (NULL != connection->sock) && |
@@ -1105,21 +1146,14 @@ receive_ready (void *cls) | |||
1105 | 1146 | ||
1106 | connection->read_task = NULL; | 1147 | connection->read_task = NULL; |
1107 | tc = GNUNET_SCHEDULER_get_task_context (); | 1148 | tc = GNUNET_SCHEDULER_get_task_context (); |
1108 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
1109 | { | ||
1110 | /* ignore shutdown request, go again immediately */ | ||
1111 | connection->read_task = | ||
1112 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining | ||
1113 | (connection->receive_timeout), connection->sock, | ||
1114 | &receive_ready, connection); | ||
1115 | return; | ||
1116 | } | ||
1117 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) | 1149 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) |
1118 | { | 1150 | { |
1119 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1151 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1120 | "Receive from `%s' encounters error: timeout (%s, %p)\n", | 1152 | "Receive from `%s' encounters error: timeout (%s, %p)\n", |
1121 | GNUNET_a2s (connection->addr, connection->addrlen), | 1153 | GNUNET_a2s (connection->addr, |
1122 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (connection->receive_timeout), GNUNET_YES), | 1154 | connection->addrlen), |
1155 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (connection->receive_timeout), | ||
1156 | GNUNET_YES), | ||
1123 | connection); | 1157 | connection); |
1124 | signal_receive_timeout (connection); | 1158 | signal_receive_timeout (connection); |
1125 | return; | 1159 | return; |
@@ -1130,7 +1164,8 @@ receive_ready (void *cls) | |||
1130 | signal_receive_error (connection, ECONNREFUSED); | 1164 | signal_receive_error (connection, ECONNREFUSED); |
1131 | return; | 1165 | return; |
1132 | } | 1166 | } |
1133 | GNUNET_assert (GNUNET_NETWORK_fdset_isset (tc->read_ready, connection->sock)); | 1167 | GNUNET_assert (GNUNET_NETWORK_fdset_isset (tc->read_ready, |
1168 | connection->sock)); | ||
1134 | RETRY: | 1169 | RETRY: |
1135 | ret = GNUNET_NETWORK_socket_recv (connection->sock, | 1170 | ret = GNUNET_NETWORK_socket_recv (connection->sock, |
1136 | buffer, | 1171 | buffer, |
@@ -1161,8 +1196,8 @@ RETRY: | |||
1161 | 1196 | ||
1162 | 1197 | ||
1163 | /** | 1198 | /** |
1164 | * Receive data from the given connection. Note that this function will | 1199 | * Receive data from the given connection. Note that this function |
1165 | * call @a receiver asynchronously using the scheduler. It will | 1200 | * will call @a receiver asynchronously using the scheduler. It will |
1166 | * "immediately" return. Note that there MUST only be one active | 1201 | * "immediately" return. Note that there MUST only be one active |
1167 | * receive call per connection at any given point in time (so do not | 1202 | * receive call per connection at any given point in time (so do not |
1168 | * call receive again until the receiver callback has been invoked). | 1203 | * call receive again until the receiver callback has been invoked). |
@@ -1202,7 +1237,10 @@ GNUNET_CONNECTION_receive (struct GNUNET_CONNECTION_Handle *connection, | |||
1202 | (NULL == connection->proxy_handshake)) | 1237 | (NULL == connection->proxy_handshake)) |
1203 | { | 1238 | { |
1204 | connection->receiver = NULL; | 1239 | connection->receiver = NULL; |
1205 | receiver (receiver_cls, NULL, 0, NULL, 0, ETIMEDOUT); | 1240 | receiver (receiver_cls, |
1241 | NULL, 0, | ||
1242 | NULL, 0, | ||
1243 | ETIMEDOUT); | ||
1206 | return; | 1244 | return; |
1207 | } | 1245 | } |
1208 | } | 1246 | } |
@@ -1312,7 +1350,9 @@ transmit_timeout (void *cls) | |||
1312 | notify = connection->nth.notify_ready; | 1350 | notify = connection->nth.notify_ready; |
1313 | GNUNET_assert (NULL != notify); | 1351 | GNUNET_assert (NULL != notify); |
1314 | connection->nth.notify_ready = NULL; | 1352 | connection->nth.notify_ready = NULL; |
1315 | notify (connection->nth.notify_ready_cls, 0, NULL); | 1353 | notify (connection->nth.notify_ready_cls, |
1354 | 0, | ||
1355 | NULL); | ||
1316 | } | 1356 | } |
1317 | 1357 | ||
1318 | 1358 | ||
@@ -1339,7 +1379,9 @@ connect_error (void *cls) | |||
1339 | connection->write_task = NULL; | 1379 | connection->write_task = NULL; |
1340 | notify = connection->nth.notify_ready; | 1380 | notify = connection->nth.notify_ready; |
1341 | connection->nth.notify_ready = NULL; | 1381 | connection->nth.notify_ready = NULL; |
1342 | notify (connection->nth.notify_ready_cls, 0, NULL); | 1382 | notify (connection->nth.notify_ready_cls, |
1383 | 0, | ||
1384 | NULL); | ||
1343 | } | 1385 | } |
1344 | 1386 | ||
1345 | 1387 | ||
@@ -1364,21 +1406,6 @@ transmit_ready (void *cls) | |||
1364 | connection->write_task = NULL; | 1406 | connection->write_task = NULL; |
1365 | GNUNET_assert (NULL == connection->nth.timeout_task); | 1407 | GNUNET_assert (NULL == connection->nth.timeout_task); |
1366 | tc = GNUNET_SCHEDULER_get_task_context (); | 1408 | tc = GNUNET_SCHEDULER_get_task_context (); |
1367 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
1368 | { | ||
1369 | if (NULL != connection->sock) | ||
1370 | goto SCHEDULE_WRITE; /* ignore shutdown, go again immediately */ | ||
1371 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1372 | "Transmit to `%s' fails, shutdown happened (%p).\n", | ||
1373 | GNUNET_a2s (connection->addr, connection->addrlen), connection); | ||
1374 | notify = connection->nth.notify_ready; | ||
1375 | if (NULL != notify) | ||
1376 | { | ||
1377 | connection->nth.notify_ready = NULL; | ||
1378 | notify (connection->nth.notify_ready_cls, 0, NULL); | ||
1379 | } | ||
1380 | return; | ||
1381 | } | ||
1382 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) | 1409 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) |
1383 | { | 1410 | { |
1384 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1411 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1400,7 +1427,8 @@ transmit_ready (void *cls) | |||
1400 | * Hence retry. */ | 1427 | * Hence retry. */ |
1401 | goto SCHEDULE_WRITE; | 1428 | goto SCHEDULE_WRITE; |
1402 | } | 1429 | } |
1403 | if (!GNUNET_NETWORK_fdset_isset (tc->write_ready, connection->sock)) | 1430 | if (! GNUNET_NETWORK_fdset_isset (tc->write_ready, |
1431 | connection->sock)) | ||
1404 | { | 1432 | { |
1405 | GNUNET_assert (NULL == connection->write_task); | 1433 | GNUNET_assert (NULL == connection->write_task); |
1406 | /* special circumstances (in particular, shutdown): not yet ready | 1434 | /* special circumstances (in particular, shutdown): not yet ready |
@@ -1444,7 +1472,11 @@ RETRY: | |||
1444 | } | 1472 | } |
1445 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1473 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1446 | "Connection transmitted %u/%u bytes to `%s' (%p)\n", | 1474 | "Connection transmitted %u/%u bytes to `%s' (%p)\n", |
1447 | (unsigned int) ret, have, GNUNET_a2s (connection->addr, connection->addrlen), connection); | 1475 | (unsigned int) ret, |
1476 | have, | ||
1477 | GNUNET_a2s (connection->addr, | ||
1478 | connection->addrlen), | ||
1479 | connection); | ||
1448 | connection->write_buffer_pos += ret; | 1480 | connection->write_buffer_pos += ret; |
1449 | if (connection->write_buffer_pos == connection->write_buffer_off) | 1481 | if (connection->write_buffer_pos == connection->write_buffer_off) |
1450 | { | 1482 | { |
@@ -1452,21 +1484,25 @@ RETRY: | |||
1452 | connection->write_buffer_pos = 0; | 1484 | connection->write_buffer_pos = 0; |
1453 | connection->write_buffer_off = 0; | 1485 | connection->write_buffer_off = 0; |
1454 | } | 1486 | } |
1455 | if ((0 == connection->write_buffer_off) && (NULL == connection->nth.notify_ready)) | 1487 | if ( (0 == connection->write_buffer_off) && |
1488 | (NULL == connection->nth.notify_ready) ) | ||
1456 | return; /* all data sent! */ | 1489 | return; /* all data sent! */ |
1457 | /* not done writing, schedule more */ | 1490 | /* not done writing, schedule more */ |
1458 | SCHEDULE_WRITE: | 1491 | SCHEDULE_WRITE: |
1459 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1492 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1460 | "Re-scheduling transmit_ready (more to do) (%p).\n", connection); | 1493 | "Re-scheduling transmit_ready (more to do) (%p).\n", |
1494 | connection); | ||
1461 | have = connection->write_buffer_off - connection->write_buffer_pos; | 1495 | have = connection->write_buffer_off - connection->write_buffer_pos; |
1462 | GNUNET_assert ((NULL != connection->nth.notify_ready) || (have > 0)); | 1496 | GNUNET_assert ( (NULL != connection->nth.notify_ready) || |
1497 | (have > 0) ); | ||
1463 | if (NULL == connection->write_task) | 1498 | if (NULL == connection->write_task) |
1464 | connection->write_task = | 1499 | connection->write_task = |
1465 | GNUNET_SCHEDULER_add_write_net ((connection->nth.notify_ready == | 1500 | GNUNET_SCHEDULER_add_write_net ((connection->nth.notify_ready == |
1466 | NULL) ? GNUNET_TIME_UNIT_FOREVER_REL : | 1501 | NULL) ? GNUNET_TIME_UNIT_FOREVER_REL : |
1467 | GNUNET_TIME_absolute_get_remaining | 1502 | GNUNET_TIME_absolute_get_remaining |
1468 | (connection->nth.transmit_timeout), | 1503 | (connection->nth.transmit_timeout), |
1469 | connection->sock, &transmit_ready, connection); | 1504 | connection->sock, |
1505 | &transmit_ready, connection); | ||
1470 | } | 1506 | } |
1471 | 1507 | ||
1472 | 1508 | ||
@@ -1488,8 +1524,8 @@ struct GNUNET_CONNECTION_TransmitHandle * | |||
1488 | GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle *connection, | 1524 | GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle *connection, |
1489 | size_t size, | 1525 | size_t size, |
1490 | struct GNUNET_TIME_Relative timeout, | 1526 | struct GNUNET_TIME_Relative timeout, |
1491 | GNUNET_CONNECTION_TransmitReadyNotify | 1527 | GNUNET_CONNECTION_TransmitReadyNotify notify, |
1492 | notify, void *notify_cls) | 1528 | void *notify_cls) |
1493 | { | 1529 | { |
1494 | if (NULL != connection->nth.notify_ready) | 1530 | if (NULL != connection->nth.notify_ready) |
1495 | { | 1531 | { |
@@ -1529,7 +1565,8 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle *connec | |||
1529 | connection->write_task = | 1565 | connection->write_task = |
1530 | GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_absolute_get_remaining | 1566 | GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_absolute_get_remaining |
1531 | (connection->nth.transmit_timeout), | 1567 | (connection->nth.transmit_timeout), |
1532 | connection->sock, &transmit_ready, connection); | 1568 | connection->sock, |
1569 | &transmit_ready, connection); | ||
1533 | return &connection->nth; | 1570 | return &connection->nth; |
1534 | } | 1571 | } |
1535 | /* not yet connected, wait for connection */ | 1572 | /* not yet connected, wait for connection */ |
@@ -1538,7 +1575,8 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle *connec | |||
1538 | connection); | 1575 | connection); |
1539 | connection->nth.timeout_task = | 1576 | connection->nth.timeout_task = |
1540 | GNUNET_SCHEDULER_add_delayed (timeout, | 1577 | GNUNET_SCHEDULER_add_delayed (timeout, |
1541 | &transmit_timeout, connection); | 1578 | &transmit_timeout, |
1579 | connection); | ||
1542 | return &connection->nth; | 1580 | return &connection->nth; |
1543 | } | 1581 | } |
1544 | 1582 | ||
@@ -1575,7 +1613,8 @@ GNUNET_CONNECTION_notify_transmit_ready_cancel (struct GNUNET_CONNECTION_Transmi | |||
1575 | struct GNUNET_CONNECTION_Handle * | 1613 | struct GNUNET_CONNECTION_Handle * |
1576 | GNUNET_CONNECTION_create_proxied_from_handshake (struct GNUNET_CONNECTION_Handle *cph) | 1614 | GNUNET_CONNECTION_create_proxied_from_handshake (struct GNUNET_CONNECTION_Handle *cph) |
1577 | { | 1615 | { |
1578 | struct GNUNET_CONNECTION_Handle * proxied = GNUNET_CONNECTION_create_from_existing(NULL); | 1616 | struct GNUNET_CONNECTION_Handle *proxied = GNUNET_CONNECTION_create_from_existing (NULL); |
1617 | |||
1579 | proxied->proxy_handshake = cph; | 1618 | proxied->proxy_handshake = cph; |
1580 | return proxied; | 1619 | return proxied; |
1581 | } | 1620 | } |
@@ -1592,11 +1631,12 @@ void | |||
1592 | GNUNET_CONNECTION_acivate_proxied (struct GNUNET_CONNECTION_Handle *proxied) | 1631 | GNUNET_CONNECTION_acivate_proxied (struct GNUNET_CONNECTION_Handle *proxied) |
1593 | { | 1632 | { |
1594 | struct GNUNET_CONNECTION_Handle *cph = proxied->proxy_handshake; | 1633 | struct GNUNET_CONNECTION_Handle *cph = proxied->proxy_handshake; |
1634 | |||
1595 | GNUNET_assert (NULL != cph); | 1635 | GNUNET_assert (NULL != cph); |
1596 | GNUNET_assert (NULL == proxied->sock); | 1636 | GNUNET_assert (NULL == proxied->sock); |
1597 | GNUNET_assert (NULL != cph->sock); | 1637 | GNUNET_assert (NULL != cph->sock); |
1598 | proxied->sock=cph->sock; | 1638 | proxied->sock = cph->sock; |
1599 | cph->sock=NULL; | 1639 | cph->sock = NULL; |
1600 | GNUNET_CONNECTION_destroy (cph); | 1640 | GNUNET_CONNECTION_destroy (cph); |
1601 | connect_success_continuation (proxied); | 1641 | connect_success_continuation (proxied); |
1602 | } | 1642 | } |
diff --git a/src/util/crypto_hash_file.c b/src/util/crypto_hash_file.c index f2d49d164..ace5212c9 100644 --- a/src/util/crypto_hash_file.c +++ b/src/util/crypto_hash_file.c | |||
@@ -130,9 +130,13 @@ file_hash_task (void *cls) | |||
130 | delta = fhc->bsize; | 130 | delta = fhc->bsize; |
131 | if (fhc->fsize - fhc->offset < delta) | 131 | if (fhc->fsize - fhc->offset < delta) |
132 | delta = fhc->fsize - fhc->offset; | 132 | delta = fhc->fsize - fhc->offset; |
133 | if (delta != GNUNET_DISK_file_read (fhc->fh, fhc->buffer, delta)) | 133 | if (delta != GNUNET_DISK_file_read (fhc->fh, |
134 | fhc->buffer, | ||
135 | delta)) | ||
134 | { | 136 | { |
135 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "read", fhc->filename); | 137 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, |
138 | "read", | ||
139 | fhc->filename); | ||
136 | file_hash_finish (fhc, NULL); | 140 | file_hash_finish (fhc, NULL); |
137 | return; | 141 | return; |
138 | } | 142 | } |
@@ -140,12 +144,14 @@ file_hash_task (void *cls) | |||
140 | fhc->offset += delta; | 144 | fhc->offset += delta; |
141 | if (fhc->offset == fhc->fsize) | 145 | if (fhc->offset == fhc->fsize) |
142 | { | 146 | { |
143 | res = (struct GNUNET_HashCode *) gcry_md_read (fhc->md, GCRY_MD_SHA512); | 147 | res = (struct GNUNET_HashCode *) gcry_md_read (fhc->md, |
148 | GCRY_MD_SHA512); | ||
144 | file_hash_finish (fhc, res); | 149 | file_hash_finish (fhc, res); |
145 | return; | 150 | return; |
146 | } | 151 | } |
147 | fhc->task = GNUNET_SCHEDULER_add_with_priority (fhc->priority, | 152 | fhc->task = GNUNET_SCHEDULER_add_with_priority (fhc->priority, |
148 | &file_hash_task, fhc); | 153 | &file_hash_task, |
154 | fhc); | ||
149 | } | 155 | } |
150 | 156 | ||
151 | 157 | ||
@@ -156,12 +162,13 @@ file_hash_task (void *cls) | |||
156 | * @param filename name of file to hash | 162 | * @param filename name of file to hash |
157 | * @param blocksize number of bytes to process in one task | 163 | * @param blocksize number of bytes to process in one task |
158 | * @param callback function to call upon completion | 164 | * @param callback function to call upon completion |
159 | * @param callback_cls closure for callback | 165 | * @param callback_cls closure for @a callback |
160 | * @return NULL on (immediate) errror | 166 | * @return NULL on (immediate) errror |
161 | */ | 167 | */ |
162 | struct GNUNET_CRYPTO_FileHashContext * | 168 | struct GNUNET_CRYPTO_FileHashContext * |
163 | GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority, | 169 | GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority, |
164 | const char *filename, size_t blocksize, | 170 | const char *filename, |
171 | size_t blocksize, | ||
165 | GNUNET_CRYPTO_HashCompletedCallback callback, | 172 | GNUNET_CRYPTO_HashCompletedCallback callback, |
166 | void *callback_cls) | 173 | void *callback_cls) |
167 | { | 174 | { |
@@ -181,24 +188,29 @@ GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority, | |||
181 | return NULL; | 188 | return NULL; |
182 | } | 189 | } |
183 | fhc->bsize = blocksize; | 190 | fhc->bsize = blocksize; |
184 | if (GNUNET_OK != GNUNET_DISK_file_size (filename, &fhc->fsize, GNUNET_NO, GNUNET_YES)) | 191 | if (GNUNET_OK != |
192 | GNUNET_DISK_file_size (filename, | ||
193 | &fhc->fsize, | ||
194 | GNUNET_NO, | ||
195 | GNUNET_YES)) | ||
185 | { | 196 | { |
186 | GNUNET_free (fhc->filename); | 197 | GNUNET_free (fhc->filename); |
187 | GNUNET_free (fhc); | 198 | GNUNET_free (fhc); |
188 | return NULL; | 199 | return NULL; |
189 | } | 200 | } |
190 | fhc->fh = | 201 | fhc->fh = GNUNET_DISK_file_open (filename, |
191 | GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ, | 202 | GNUNET_DISK_OPEN_READ, |
192 | GNUNET_DISK_PERM_NONE); | 203 | GNUNET_DISK_PERM_NONE); |
193 | if (!fhc->fh) | 204 | if (! fhc->fh) |
194 | { | 205 | { |
195 | GNUNET_free (fhc->filename); | 206 | GNUNET_free (fhc->filename); |
196 | GNUNET_free (fhc); | 207 | GNUNET_free (fhc); |
197 | return NULL; | 208 | return NULL; |
198 | } | 209 | } |
199 | fhc->priority = priority; | 210 | fhc->priority = priority; |
200 | fhc->task = | 211 | fhc->task = GNUNET_SCHEDULER_add_with_priority (priority, |
201 | GNUNET_SCHEDULER_add_with_priority (priority, &file_hash_task, fhc); | 212 | &file_hash_task, |
213 | fhc); | ||
202 | return fhc; | 214 | return fhc; |
203 | } | 215 | } |
204 | 216 | ||
@@ -213,7 +225,8 @@ GNUNET_CRYPTO_hash_file_cancel (struct GNUNET_CRYPTO_FileHashContext *fhc) | |||
213 | { | 225 | { |
214 | GNUNET_SCHEDULER_cancel (fhc->task); | 226 | GNUNET_SCHEDULER_cancel (fhc->task); |
215 | GNUNET_free (fhc->filename); | 227 | GNUNET_free (fhc->filename); |
216 | GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fhc->fh)); | 228 | GNUNET_break (GNUNET_OK == |
229 | GNUNET_DISK_file_close (fhc->fh)); | ||
217 | GNUNET_free (fhc); | 230 | GNUNET_free (fhc); |
218 | } | 231 | } |
219 | 232 | ||
diff --git a/src/util/gnunet-scrypt.c b/src/util/gnunet-scrypt.c index 7449d8042..6fd871cbe 100644 --- a/src/util/gnunet-scrypt.c +++ b/src/util/gnunet-scrypt.c | |||
@@ -40,7 +40,7 @@ static struct GNUNET_CRYPTO_EddsaPublicKey pub; | |||
40 | 40 | ||
41 | static uint64_t proof; | 41 | static uint64_t proof; |
42 | 42 | ||
43 | static struct GNUNET_SCHEDULER_Task * proof_task; | 43 | static struct GNUNET_SCHEDULER_Task *proof_task; |
44 | 44 | ||
45 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | 45 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
46 | 46 | ||
@@ -51,15 +51,21 @@ static char *pwfn; | |||
51 | 51 | ||
52 | /** | 52 | /** |
53 | * Write our current proof to disk. | 53 | * Write our current proof to disk. |
54 | * | ||
55 | * @param cls closure | ||
54 | */ | 56 | */ |
55 | static void | 57 | static void |
56 | write_proof () | 58 | shutdown_task (void *cls) |
57 | { | 59 | { |
58 | if (sizeof (proof) != | 60 | if (sizeof (proof) != |
59 | GNUNET_DISK_fn_write (pwfn, &proof, sizeof (proof), | 61 | GNUNET_DISK_fn_write (pwfn, |
62 | &proof, | ||
63 | sizeof (proof), | ||
60 | GNUNET_DISK_PERM_USER_READ | | 64 | GNUNET_DISK_PERM_USER_READ | |
61 | GNUNET_DISK_PERM_USER_WRITE)) | 65 | GNUNET_DISK_PERM_USER_WRITE)) |
62 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", proof); | 66 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, |
67 | "write", | ||
68 | proof); | ||
63 | } | 69 | } |
64 | 70 | ||
65 | 71 | ||
@@ -120,15 +126,10 @@ find_proof (void *cls) | |||
120 | unsigned int i; | 126 | unsigned int i; |
121 | struct GNUNET_TIME_Absolute timestamp; | 127 | struct GNUNET_TIME_Absolute timestamp; |
122 | struct GNUNET_TIME_Relative elapsed; | 128 | struct GNUNET_TIME_Relative elapsed; |
123 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
124 | 129 | ||
125 | tc = GNUNET_SCHEDULER_get_task_context (); | 130 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
126 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | 131 | "Got Proof of Work %llu\n", |
127 | { | 132 | proof); |
128 | write_proof (); | ||
129 | return; | ||
130 | } | ||
131 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got Proof of Work %llu\n", proof); | ||
132 | proof_task = NULL; | 133 | proof_task = NULL; |
133 | memcpy (&buf[sizeof (uint64_t)], &pub, | 134 | memcpy (&buf[sizeof (uint64_t)], &pub, |
134 | sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)); | 135 | sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)); |
@@ -144,7 +145,7 @@ find_proof (void *cls) | |||
144 | proof = counter; | 145 | proof = counter; |
145 | FPRINTF (stdout, "Proof of work found: %llu!\n", | 146 | FPRINTF (stdout, "Proof of work found: %llu!\n", |
146 | (unsigned long long) proof); | 147 | (unsigned long long) proof); |
147 | write_proof (); | 148 | GNUNET_SCHEDULER_shutdown (); |
148 | return; | 149 | return; |
149 | } | 150 | } |
150 | counter++; | 151 | counter++; |
@@ -162,16 +163,16 @@ find_proof (void *cls) | |||
162 | (unsigned long long) counter); | 163 | (unsigned long long) counter); |
163 | /* remember progress every 100 rounds */ | 164 | /* remember progress every 100 rounds */ |
164 | proof = counter; | 165 | proof = counter; |
165 | write_proof (); | 166 | shutdown_task (NULL); |
166 | } | 167 | } |
167 | else | 168 | else |
168 | { | 169 | { |
169 | proof = counter; | 170 | proof = counter; |
170 | } | 171 | } |
171 | proof_task = | 172 | proof_task = |
172 | GNUNET_SCHEDULER_add_delayed_with_priority (proof_find_delay, | 173 | GNUNET_SCHEDULER_add_delayed_with_priority (proof_find_delay, |
173 | GNUNET_SCHEDULER_PRIORITY_IDLE, | 174 | GNUNET_SCHEDULER_PRIORITY_IDLE, |
174 | &find_proof, NULL); | 175 | &find_proof, NULL); |
175 | } | 176 | } |
176 | 177 | ||
177 | 178 | ||
@@ -193,17 +194,18 @@ run (void *cls, | |||
193 | char *pids; | 194 | char *pids; |
194 | 195 | ||
195 | cfg = config; | 196 | cfg = config; |
196 | |||
197 | /* load proof of work */ | 197 | /* load proof of work */ |
198 | if (NULL == pwfn) | 198 | if (NULL == pwfn) |
199 | { | 199 | { |
200 | if (GNUNET_OK != | 200 | if (GNUNET_OK != |
201 | GNUNET_CONFIGURATION_get_value_filename (cfg, "NSE", | 201 | GNUNET_CONFIGURATION_get_value_filename (cfg, |
202 | "NSE", | ||
202 | "PROOFFILE", | 203 | "PROOFFILE", |
203 | &pwfn)) | 204 | &pwfn)) |
204 | { | 205 | { |
205 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, | 206 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, |
206 | "NSE", "PROOFFILE"); | 207 | "NSE", |
208 | "PROOFFILE"); | ||
207 | GNUNET_SCHEDULER_shutdown (); | 209 | GNUNET_SCHEDULER_shutdown (); |
208 | return; | 210 | return; |
209 | } | 211 | } |
@@ -219,19 +221,26 @@ run (void *cls, | |||
219 | /* load private key */ | 221 | /* load private key */ |
220 | if (NULL == pkfn) | 222 | if (NULL == pkfn) |
221 | { | 223 | { |
222 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "PEER", | 224 | if (GNUNET_OK != |
223 | "PRIVATE_KEY", | 225 | GNUNET_CONFIGURATION_get_value_filename (cfg, |
224 | &pkfn)) | 226 | "PEER", |
227 | "PRIVATE_KEY", | ||
228 | &pkfn)) | ||
225 | { | 229 | { |
226 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, | 230 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, |
227 | "PEER", "PRIVATE_KEY"); | 231 | "PEER", |
232 | "PRIVATE_KEY"); | ||
228 | return; | 233 | return; |
229 | } | 234 | } |
230 | } | 235 | } |
231 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Private Key file: %s\n", pkfn); | 236 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
237 | "Private Key file: %s\n", | ||
238 | pkfn); | ||
232 | if (NULL == (pk = GNUNET_CRYPTO_eddsa_key_create_from_file (pkfn))) | 239 | if (NULL == (pk = GNUNET_CRYPTO_eddsa_key_create_from_file (pkfn))) |
233 | { | 240 | { |
234 | FPRINTF (stderr, _("Loading hostkey from `%s' failed.\n"), pkfn); | 241 | FPRINTF (stderr, |
242 | _("Loading hostkey from `%s' failed.\n"), | ||
243 | pkfn); | ||
235 | GNUNET_free (pkfn); | 244 | GNUNET_free (pkfn); |
236 | return; | 245 | return; |
237 | } | 246 | } |
@@ -248,22 +257,28 @@ run (void *cls, | |||
248 | if (0 == nse_work_required) | 257 | if (0 == nse_work_required) |
249 | { | 258 | { |
250 | if (GNUNET_OK != | 259 | if (GNUNET_OK != |
251 | GNUNET_CONFIGURATION_get_value_number (cfg, "NSE", "WORKBITS", | 260 | GNUNET_CONFIGURATION_get_value_number (cfg, |
261 | "NSE", | ||
262 | "WORKBITS", | ||
252 | &nse_work_required)) | 263 | &nse_work_required)) |
253 | { | 264 | { |
254 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "NSE", "WORKBITS"); | 265 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, |
266 | "NSE", | ||
267 | "WORKBITS"); | ||
255 | GNUNET_SCHEDULER_shutdown (); | 268 | GNUNET_SCHEDULER_shutdown (); |
256 | return; | 269 | return; |
257 | } | 270 | } |
258 | if (nse_work_required >= sizeof (struct GNUNET_HashCode) * 8) | 271 | if (nse_work_required >= sizeof (struct GNUNET_HashCode) * 8) |
259 | { | 272 | { |
260 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, "NSE", "WORKBITS", | 273 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, |
274 | "NSE", | ||
275 | "WORKBITS", | ||
261 | _("Value is too large.\n")); | 276 | _("Value is too large.\n")); |
262 | GNUNET_SCHEDULER_shutdown (); | 277 | GNUNET_SCHEDULER_shutdown (); |
263 | return; | 278 | return; |
264 | } else if (0 == nse_work_required) | 279 | } |
280 | else if (0 == nse_work_required) | ||
265 | { | 281 | { |
266 | write_proof (); | ||
267 | GNUNET_SCHEDULER_shutdown (); | 282 | GNUNET_SCHEDULER_shutdown (); |
268 | return; | 283 | return; |
269 | } | 284 | } |
@@ -275,8 +290,12 @@ run (void *cls, | |||
275 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 290 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
276 | "Delay between tries: %s\n", | 291 | "Delay between tries: %s\n", |
277 | GNUNET_STRINGS_relative_time_to_string (proof_find_delay, 1)); | 292 | GNUNET_STRINGS_relative_time_to_string (proof_find_delay, 1)); |
278 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, | 293 | proof_task = |
279 | &find_proof, NULL); | 294 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, |
295 | &find_proof, | ||
296 | NULL); | ||
297 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, | ||
298 | NULL); | ||
280 | } | 299 | } |
281 | 300 | ||
282 | 301 | ||
@@ -307,7 +326,8 @@ main (int argc, char *const *argv) | |||
307 | }; | 326 | }; |
308 | int ret; | 327 | int ret; |
309 | 328 | ||
310 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 329 | if (GNUNET_OK != |
330 | GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | ||
311 | return 2; | 331 | return 2; |
312 | 332 | ||
313 | ret = (GNUNET_OK == | 333 | ret = (GNUNET_OK == |
diff --git a/src/util/gnunet-uri.c b/src/util/gnunet-uri.c index 75e70d2b7..f69508f67 100644 --- a/src/util/gnunet-uri.c +++ b/src/util/gnunet-uri.c | |||
@@ -52,6 +52,7 @@ static void | |||
52 | maint_child_death (void *cls) | 52 | maint_child_death (void *cls) |
53 | { | 53 | { |
54 | enum GNUNET_OS_ProcessStatusType type; | 54 | enum GNUNET_OS_ProcessStatusType type; |
55 | |||
55 | if ( (GNUNET_OK != | 56 | if ( (GNUNET_OK != |
56 | GNUNET_OS_process_status (p, &type, &exit_code)) || | 57 | GNUNET_OS_process_status (p, &type, &exit_code)) || |
57 | (type != GNUNET_OS_PROCESS_EXITED) ) | 58 | (type != GNUNET_OS_PROCESS_EXITED) ) |
@@ -80,12 +81,14 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
80 | 81 | ||
81 | if (NULL == (uri = args[0])) | 82 | if (NULL == (uri = args[0])) |
82 | { | 83 | { |
83 | fprintf (stderr, _("No URI specified on command line\n")); | 84 | fprintf (stderr, |
85 | _("No URI specified on command line\n")); | ||
84 | return; | 86 | return; |
85 | } | 87 | } |
86 | if (0 != strncasecmp ("gnunet://", uri, strlen ("gnunet://"))) | 88 | if (0 != strncasecmp ("gnunet://", uri, strlen ("gnunet://"))) |
87 | { | 89 | { |
88 | fprintf (stderr, _("Invalid URI: does not start with `%s'\n"), | 90 | fprintf (stderr, |
91 | _("Invalid URI: does not start with `%s'\n"), | ||
89 | "gnunet://"); | 92 | "gnunet://"); |
90 | return; | 93 | return; |
91 | } | 94 | } |
diff --git a/src/util/helper.c b/src/util/helper.c index 3ed1c7276..ecfe4ccfa 100644 --- a/src/util/helper.c +++ b/src/util/helper.c | |||
@@ -142,17 +142,17 @@ struct GNUNET_HELPER_Handle | |||
142 | /** | 142 | /** |
143 | * Task to read from the helper. | 143 | * Task to read from the helper. |
144 | */ | 144 | */ |
145 | struct GNUNET_SCHEDULER_Task * read_task; | 145 | struct GNUNET_SCHEDULER_Task *read_task; |
146 | 146 | ||
147 | /** | 147 | /** |
148 | * Task to read from the helper. | 148 | * Task to read from the helper. |
149 | */ | 149 | */ |
150 | struct GNUNET_SCHEDULER_Task * write_task; | 150 | struct GNUNET_SCHEDULER_Task *write_task; |
151 | 151 | ||
152 | /** | 152 | /** |
153 | * Restart task. | 153 | * Restart task. |
154 | */ | 154 | */ |
155 | struct GNUNET_SCHEDULER_Task * restart_task; | 155 | struct GNUNET_SCHEDULER_Task *restart_task; |
156 | 156 | ||
157 | /** | 157 | /** |
158 | * Does the helper support the use of a control pipe for signalling? | 158 | * Does the helper support the use of a control pipe for signalling? |
@@ -319,19 +319,10 @@ static void | |||
319 | helper_read (void *cls) | 319 | helper_read (void *cls) |
320 | { | 320 | { |
321 | struct GNUNET_HELPER_Handle *h = cls; | 321 | struct GNUNET_HELPER_Handle *h = cls; |
322 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
323 | char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE] GNUNET_ALIGN; | 322 | char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE] GNUNET_ALIGN; |
324 | ssize_t t; | 323 | ssize_t t; |
325 | 324 | ||
326 | h->read_task = NULL; | 325 | h->read_task = NULL; |
327 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
328 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
329 | { | ||
330 | /* try again */ | ||
331 | h->read_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | ||
332 | h->fh_from_helper, &helper_read, h); | ||
333 | return; | ||
334 | } | ||
335 | t = GNUNET_DISK_file_read (h->fh_from_helper, &buf, sizeof (buf)); | 326 | t = GNUNET_DISK_file_read (h->fh_from_helper, &buf, sizeof (buf)); |
336 | if (t < 0) | 327 | if (t < 0) |
337 | { | 328 | { |
@@ -348,9 +339,9 @@ helper_read (void *cls) | |||
348 | } | 339 | } |
349 | stop_helper (h, GNUNET_NO); | 340 | stop_helper (h, GNUNET_NO); |
350 | /* Restart the helper */ | 341 | /* Restart the helper */ |
351 | h->restart_task = GNUNET_SCHEDULER_add_delayed( | 342 | h->restart_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
352 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, | 343 | h->retry_back_off), |
353 | h->retry_back_off), &restart_task, h); | 344 | &restart_task, h); |
354 | return; | 345 | return; |
355 | } | 346 | } |
356 | if (0 == t) | 347 | if (0 == t) |
@@ -368,9 +359,10 @@ helper_read (void *cls) | |||
368 | } | 359 | } |
369 | stop_helper (h, GNUNET_NO); | 360 | stop_helper (h, GNUNET_NO); |
370 | /* Restart the helper */ | 361 | /* Restart the helper */ |
371 | h->restart_task = GNUNET_SCHEDULER_add_delayed( | 362 | h->restart_task |
372 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, | 363 | = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
373 | h->retry_back_off), &restart_task, h); | 364 | h->retry_back_off), |
365 | &restart_task, h); | ||
374 | return; | 366 | return; |
375 | } | 367 | } |
376 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 368 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -378,9 +370,13 @@ helper_read (void *cls) | |||
378 | (unsigned int) t, | 370 | (unsigned int) t, |
379 | h->binary_name); | 371 | h->binary_name); |
380 | h->read_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | 372 | h->read_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
381 | h->fh_from_helper, &helper_read, h); | 373 | h->fh_from_helper, |
374 | &helper_read, h); | ||
382 | if (GNUNET_SYSERR == | 375 | if (GNUNET_SYSERR == |
383 | GNUNET_SERVER_mst_receive (h->mst, NULL, buf, t, GNUNET_NO, GNUNET_NO)) | 376 | GNUNET_SERVER_mst_receive (h->mst, |
377 | NULL, | ||
378 | buf, t, | ||
379 | GNUNET_NO, GNUNET_NO)) | ||
384 | { | 380 | { |
385 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 381 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
386 | _("Failed to parse inbound message from helper `%s'\n"), | 382 | _("Failed to parse inbound message from helper `%s'\n"), |
@@ -393,9 +389,9 @@ helper_read (void *cls) | |||
393 | } | 389 | } |
394 | stop_helper (h, GNUNET_NO); | 390 | stop_helper (h, GNUNET_NO); |
395 | /* Restart the helper */ | 391 | /* Restart the helper */ |
396 | h->restart_task = GNUNET_SCHEDULER_add_delayed( | 392 | h->restart_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, |
397 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, | 393 | h->retry_back_off), |
398 | h->retry_back_off), &restart_task, h); | 394 | &restart_task, h); |
399 | return; | 395 | return; |
400 | } | 396 | } |
401 | } | 397 | } |
@@ -416,9 +412,9 @@ start_helper (struct GNUNET_HELPER_Handle *h) | |||
416 | /* out of file descriptors? try again later... */ | 412 | /* out of file descriptors? try again later... */ |
417 | stop_helper (h, GNUNET_NO); | 413 | stop_helper (h, GNUNET_NO); |
418 | h->restart_task = | 414 | h->restart_task = |
419 | GNUNET_SCHEDULER_add_delayed( | 415 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, |
420 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, | 416 | h->retry_back_off), |
421 | h->retry_back_off), &restart_task, h); | 417 | &restart_task, h); |
422 | return; | 418 | return; |
423 | } | 419 | } |
424 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 420 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -437,9 +433,9 @@ start_helper (struct GNUNET_HELPER_Handle *h) | |||
437 | { | 433 | { |
438 | /* failed to start process? try again later... */ | 434 | /* failed to start process? try again later... */ |
439 | stop_helper (h, GNUNET_NO); | 435 | stop_helper (h, GNUNET_NO); |
440 | h->restart_task = GNUNET_SCHEDULER_add_delayed( | 436 | h->restart_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, |
441 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, | 437 | h->retry_back_off), |
442 | h->retry_back_off), &restart_task, h); | 438 | &restart_task, h); |
443 | return; | 439 | return; |
444 | } | 440 | } |
445 | GNUNET_DISK_pipe_close_end (h->helper_out, GNUNET_DISK_PIPE_END_WRITE); | 441 | GNUNET_DISK_pipe_close_end (h->helper_out, GNUNET_DISK_PIPE_END_WRITE); |
@@ -583,22 +579,11 @@ static void | |||
583 | helper_write (void *cls) | 579 | helper_write (void *cls) |
584 | { | 580 | { |
585 | struct GNUNET_HELPER_Handle *h = cls; | 581 | struct GNUNET_HELPER_Handle *h = cls; |
586 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
587 | struct GNUNET_HELPER_SendHandle *sh; | 582 | struct GNUNET_HELPER_SendHandle *sh; |
588 | const char *buf; | 583 | const char *buf; |
589 | ssize_t t; | 584 | ssize_t t; |
590 | 585 | ||
591 | h->write_task = NULL; | 586 | h->write_task = NULL; |
592 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
593 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
594 | { | ||
595 | /* try again */ | ||
596 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
597 | "Helper write triggered during shutdown, retrying\n"); | ||
598 | h->write_task = GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, | ||
599 | h->fh_to_helper, &helper_write, h); | ||
600 | return; | ||
601 | } | ||
602 | if (NULL == (sh = h->sh_head)) | 587 | if (NULL == (sh = h->sh_head)) |
603 | { | 588 | { |
604 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 589 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -626,9 +611,9 @@ helper_write (void *cls) | |||
626 | "Stopping and restarting helper task!\n"); | 611 | "Stopping and restarting helper task!\n"); |
627 | stop_helper (h, GNUNET_NO); | 612 | stop_helper (h, GNUNET_NO); |
628 | /* Restart the helper */ | 613 | /* Restart the helper */ |
629 | h->restart_task = GNUNET_SCHEDULER_add_delayed( | 614 | h->restart_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, |
630 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, | 615 | h->retry_back_off), |
631 | h->retry_back_off), &restart_task, h); | 616 | &restart_task, h); |
632 | return; | 617 | return; |
633 | } | 618 | } |
634 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 619 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
diff --git a/src/util/mq.c b/src/util/mq.c index aff9f465c..6f8c04224 100644 --- a/src/util/mq.c +++ b/src/util/mq.c | |||
@@ -302,13 +302,8 @@ static void | |||
302 | impl_send_continue (void *cls) | 302 | impl_send_continue (void *cls) |
303 | { | 303 | { |
304 | struct GNUNET_MQ_Handle *mq = cls; | 304 | struct GNUNET_MQ_Handle *mq = cls; |
305 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
306 | struct GNUNET_MQ_Envelope *current_envelope; | 305 | struct GNUNET_MQ_Envelope *current_envelope; |
307 | 306 | ||
308 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
309 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
310 | return; | ||
311 | |||
312 | mq->continue_task = NULL; | 307 | mq->continue_task = NULL; |
313 | /* call is only valid if we're actually currently sending | 308 | /* call is only valid if we're actually currently sending |
314 | * a message */ | 309 | * a message */ |
@@ -325,7 +320,9 @@ impl_send_continue (void *cls) | |||
325 | GNUNET_CONTAINER_DLL_remove (mq->envelope_head, | 320 | GNUNET_CONTAINER_DLL_remove (mq->envelope_head, |
326 | mq->envelope_tail, | 321 | mq->envelope_tail, |
327 | mq->current_envelope); | 322 | mq->current_envelope); |
328 | mq->send_impl (mq, mq->current_envelope->mh, mq->impl_state); | 323 | mq->send_impl (mq, |
324 | mq->current_envelope->mh, | ||
325 | mq->impl_state); | ||
329 | } | 326 | } |
330 | if (NULL != current_envelope->sent_cb) | 327 | if (NULL != current_envelope->sent_cb) |
331 | current_envelope->sent_cb (current_envelope->sent_cls); | 328 | current_envelope->sent_cb (current_envelope->sent_cls); |
@@ -334,10 +331,9 @@ impl_send_continue (void *cls) | |||
334 | 331 | ||
335 | 332 | ||
336 | /** | 333 | /** |
337 | * Call the send implementation for the next queued message, | 334 | * Call the send implementation for the next queued message, if any. |
338 | * if any. | 335 | * Only useful for implementing message queues, results in undefined |
339 | * Only useful for implementing message queues, | 336 | * behavior if not used carefully. |
340 | * results in undefined behavior if not used carefully. | ||
341 | * | 337 | * |
342 | * @param mq message queue to send the next message with | 338 | * @param mq message queue to send the next message with |
343 | */ | 339 | */ |
@@ -471,7 +467,9 @@ GNUNET_MQ_msg_nested_mh_ (struct GNUNET_MessageHeader **mhp, | |||
471 | return NULL; | 467 | return NULL; |
472 | 468 | ||
473 | mqm = GNUNET_MQ_msg_ (mhp, size, type); | 469 | mqm = GNUNET_MQ_msg_ (mhp, size, type); |
474 | memcpy ((char *) mqm->mh + base_size, nested_mh, ntohs (nested_mh->size)); | 470 | memcpy ((char *) mqm->mh + base_size, |
471 | nested_mh, | ||
472 | ntohs (nested_mh->size)); | ||
475 | 473 | ||
476 | return mqm; | 474 | return mqm; |
477 | } | 475 | } |
@@ -481,9 +479,9 @@ GNUNET_MQ_msg_nested_mh_ (struct GNUNET_MessageHeader **mhp, | |||
481 | * Transmit a queued message to the session's client. | 479 | * Transmit a queued message to the session's client. |
482 | * | 480 | * |
483 | * @param cls consensus session | 481 | * @param cls consensus session |
484 | * @param size number of bytes available in buf | 482 | * @param size number of bytes available in @a buf |
485 | * @param buf where the callee should write the message | 483 | * @param buf where the callee should write the message |
486 | * @return number of bytes written to buf | 484 | * @return number of bytes written to @a buf |
487 | */ | 485 | */ |
488 | static size_t | 486 | static size_t |
489 | transmit_queued (void *cls, size_t size, | 487 | transmit_queued (void *cls, size_t size, |
@@ -535,10 +533,10 @@ server_client_send_impl (struct GNUNET_MQ_Handle *mq, | |||
535 | 533 | ||
536 | GNUNET_assert (NULL != mq); | 534 | GNUNET_assert (NULL != mq); |
537 | GNUNET_assert (NULL != state); | 535 | GNUNET_assert (NULL != state); |
538 | state->th = | 536 | state->th = GNUNET_SERVER_notify_transmit_ready (state->client, |
539 | GNUNET_SERVER_notify_transmit_ready (state->client, ntohs (msg->size), | 537 | ntohs (msg->size), |
540 | GNUNET_TIME_UNIT_FOREVER_REL, | 538 | GNUNET_TIME_UNIT_FOREVER_REL, |
541 | &transmit_queued, mq); | 539 | &transmit_queued, mq); |
542 | } | 540 | } |
543 | 541 | ||
544 | 542 | ||
@@ -580,10 +578,10 @@ handle_client_message (void *cls, | |||
580 | GNUNET_MQ_inject_error (mq, GNUNET_MQ_ERROR_READ); | 578 | GNUNET_MQ_inject_error (mq, GNUNET_MQ_ERROR_READ); |
581 | return; | 579 | return; |
582 | } | 580 | } |
583 | 581 | GNUNET_CLIENT_receive (state->connection, | |
584 | GNUNET_CLIENT_receive (state->connection, handle_client_message, mq, | 582 | &handle_client_message, |
583 | mq, | ||
585 | GNUNET_TIME_UNIT_FOREVER_REL); | 584 | GNUNET_TIME_UNIT_FOREVER_REL); |
586 | |||
587 | GNUNET_MQ_inject_message (mq, msg); | 585 | GNUNET_MQ_inject_message (mq, msg); |
588 | } | 586 | } |
589 | 587 | ||
@@ -652,7 +650,8 @@ connection_client_send_impl (struct GNUNET_MQ_Handle *mq, | |||
652 | GNUNET_assert (NULL != state); | 650 | GNUNET_assert (NULL != state); |
653 | GNUNET_assert (NULL == state->th); | 651 | GNUNET_assert (NULL == state->th); |
654 | state->th = | 652 | state->th = |
655 | GNUNET_CLIENT_notify_transmit_ready (state->connection, ntohs (msg->size), | 653 | GNUNET_CLIENT_notify_transmit_ready (state->connection, |
654 | ntohs (msg->size), | ||
656 | GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_NO, | 655 | GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_NO, |
657 | &connection_client_transmit_queued, mq); | 656 | &connection_client_transmit_queued, mq); |
658 | GNUNET_assert (NULL != state->th); | 657 | GNUNET_assert (NULL != state->th); |
@@ -752,8 +751,10 @@ GNUNET_MQ_assoc_remove (struct GNUNET_MQ_Handle *mq, | |||
752 | 751 | ||
753 | if (NULL == mq->assoc_map) | 752 | if (NULL == mq->assoc_map) |
754 | return NULL; | 753 | return NULL; |
755 | val = GNUNET_CONTAINER_multihashmap32_get (mq->assoc_map, request_id); | 754 | val = GNUNET_CONTAINER_multihashmap32_get (mq->assoc_map, |
756 | GNUNET_CONTAINER_multihashmap32_remove_all (mq->assoc_map, request_id); | 755 | request_id); |
756 | GNUNET_CONTAINER_multihashmap32_remove_all (mq->assoc_map, | ||
757 | request_id); | ||
757 | return val; | 758 | return val; |
758 | } | 759 | } |
759 | 760 | ||
@@ -785,10 +786,11 @@ GNUNET_MQ_destroy (struct GNUNET_MQ_Handle *mq) | |||
785 | struct GNUNET_MQ_Envelope *ev; | 786 | struct GNUNET_MQ_Envelope *ev; |
786 | ev = mq->envelope_head; | 787 | ev = mq->envelope_head; |
787 | ev->parent_queue = NULL; | 788 | ev->parent_queue = NULL; |
788 | GNUNET_CONTAINER_DLL_remove (mq->envelope_head, mq->envelope_tail, ev); | 789 | GNUNET_CONTAINER_DLL_remove (mq->envelope_head, |
790 | mq->envelope_tail, | ||
791 | ev); | ||
789 | GNUNET_MQ_discard (ev); | 792 | GNUNET_MQ_discard (ev); |
790 | } | 793 | } |
791 | |||
792 | if (NULL != mq->current_envelope) | 794 | if (NULL != mq->current_envelope) |
793 | { | 795 | { |
794 | /* we can only discard envelopes that | 796 | /* we can only discard envelopes that |
@@ -797,7 +799,6 @@ GNUNET_MQ_destroy (struct GNUNET_MQ_Handle *mq) | |||
797 | GNUNET_MQ_discard (mq->current_envelope); | 799 | GNUNET_MQ_discard (mq->current_envelope); |
798 | mq->current_envelope = NULL; | 800 | mq->current_envelope = NULL; |
799 | } | 801 | } |
800 | |||
801 | if (NULL != mq->assoc_map) | 802 | if (NULL != mq->assoc_map) |
802 | { | 803 | { |
803 | GNUNET_CONTAINER_multihashmap32_destroy (mq->assoc_map); | 804 | GNUNET_CONTAINER_multihashmap32_destroy (mq->assoc_map); |
@@ -851,10 +852,12 @@ GNUNET_MQ_send_cancel (struct GNUNET_MQ_Envelope *ev) | |||
851 | GNUNET_assert (NULL != mq); | 852 | GNUNET_assert (NULL != mq); |
852 | GNUNET_assert (NULL != mq->cancel_impl); | 853 | GNUNET_assert (NULL != mq->cancel_impl); |
853 | 854 | ||
854 | if (mq->current_envelope == ev) { | 855 | if (mq->current_envelope == ev) |
856 | { | ||
855 | // complex case, we already started with transmitting | 857 | // complex case, we already started with transmitting |
856 | // the message | 858 | // the message |
857 | mq->cancel_impl (mq, mq->impl_state); | 859 | mq->cancel_impl (mq, |
860 | mq->impl_state); | ||
858 | // continue sending the next message, if any | 861 | // continue sending the next message, if any |
859 | if (NULL == mq->envelope_head) | 862 | if (NULL == mq->envelope_head) |
860 | { | 863 | { |
@@ -866,11 +869,17 @@ GNUNET_MQ_send_cancel (struct GNUNET_MQ_Envelope *ev) | |||
866 | GNUNET_CONTAINER_DLL_remove (mq->envelope_head, | 869 | GNUNET_CONTAINER_DLL_remove (mq->envelope_head, |
867 | mq->envelope_tail, | 870 | mq->envelope_tail, |
868 | mq->current_envelope); | 871 | mq->current_envelope); |
869 | mq->send_impl (mq, mq->current_envelope->mh, mq->impl_state); | 872 | mq->send_impl (mq, |
873 | mq->current_envelope->mh, | ||
874 | mq->impl_state); | ||
870 | } | 875 | } |
871 | } else { | 876 | } |
877 | else | ||
878 | { | ||
872 | // simple case, message is still waiting in the queue | 879 | // simple case, message is still waiting in the queue |
873 | GNUNET_CONTAINER_DLL_remove (mq->envelope_head, mq->envelope_tail, ev); | 880 | GNUNET_CONTAINER_DLL_remove (mq->envelope_head, |
881 | mq->envelope_tail, | ||
882 | ev); | ||
874 | } | 883 | } |
875 | 884 | ||
876 | ev->parent_queue = NULL; | 885 | ev->parent_queue = NULL; |
diff --git a/src/util/os_installation.c b/src/util/os_installation.c index 161b0535f..a0e8647a1 100644 --- a/src/util/os_installation.c +++ b/src/util/os_installation.c | |||
@@ -62,7 +62,7 @@ static const struct GNUNET_OS_ProjectData default_pd = { | |||
62 | .bug_email = "gnunet-developers@gnu.org", | 62 | .bug_email = "gnunet-developers@gnu.org", |
63 | .homepage = "http://www.gnu.org/s/gnunet/", | 63 | .homepage = "http://www.gnu.org/s/gnunet/", |
64 | .config_file = "gnunet.conf", | 64 | .config_file = "gnunet.conf", |
65 | .user_config_file = "~/.config/gnunet.conf" | 65 | .user_config_file = "~/.config/gnunet.conf", |
66 | }; | 66 | }; |
67 | 67 | ||
68 | /** | 68 | /** |
diff --git a/src/util/os_priority.c b/src/util/os_priority.c index 8dfec6c5e..2a6ea8321 100644 --- a/src/util/os_priority.c +++ b/src/util/os_priority.c | |||
@@ -65,49 +65,68 @@ struct GNUNET_OS_Process | |||
65 | */ | 65 | */ |
66 | static struct GNUNET_OS_Process current_process; | 66 | static struct GNUNET_OS_Process current_process; |
67 | 67 | ||
68 | /** | ||
69 | * Handle for the #parent_control_handler() Task. | ||
70 | */ | ||
71 | static struct GNUNET_SCHEDULER_Task *pch; | ||
72 | |||
73 | |||
74 | /** | ||
75 | * This handler is called on shutdown to remove the #pch. | ||
76 | * | ||
77 | * @param cls the `struct GNUNET_DISK_FileHandle` of the control pipe | ||
78 | */ | ||
79 | static void | ||
80 | shutdown_pch (void *cls) | ||
81 | { | ||
82 | struct GNUNET_DISK_FileHandle *control_pipe = cls; | ||
83 | |||
84 | GNUNET_SCHEDULER_cancel (pch); | ||
85 | pch = NULL; | ||
86 | GNUNET_DISK_file_close (control_pipe); | ||
87 | control_pipe = NULL; | ||
88 | } | ||
89 | |||
68 | 90 | ||
69 | /** | 91 | /** |
70 | * This handler is called when there are control data to be read on the pipe | 92 | * This handler is called when there are control data to be read on the pipe |
71 | * | 93 | * |
72 | * @param cls the 'struct GNUNET_DISK_FileHandle' of the control pipe | 94 | * @param cls the `struct GNUNET_DISK_FileHandle` of the control pipe |
73 | */ | 95 | */ |
74 | static void | 96 | static void |
75 | parent_control_handler (void *cls) | 97 | parent_control_handler (void *cls) |
76 | { | 98 | { |
77 | struct GNUNET_DISK_FileHandle *control_pipe = cls; | 99 | struct GNUNET_DISK_FileHandle *control_pipe = cls; |
78 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
79 | char sig; | 100 | char sig; |
80 | char *pipe_fd; | 101 | char *pipe_fd; |
81 | ssize_t ret; | 102 | ssize_t ret; |
82 | 103 | ||
83 | tc = GNUNET_SCHEDULER_get_task_context (); | 104 | pch = NULL; |
84 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 105 | ret = GNUNET_DISK_file_read (control_pipe, |
85 | "`%s' invoked because of %d\n", __FUNCTION__, | 106 | &sig, |
86 | tc->reason); | 107 | sizeof (sig)); |
87 | if (0 != (tc->reason & | ||
88 | (GNUNET_SCHEDULER_REASON_SHUTDOWN | GNUNET_SCHEDULER_REASON_TIMEOUT))) | ||
89 | { | ||
90 | GNUNET_DISK_file_close (control_pipe); | ||
91 | control_pipe = NULL; | ||
92 | return; | ||
93 | } | ||
94 | ret = GNUNET_DISK_file_read (control_pipe, &sig, sizeof (sig)); | ||
95 | if (sizeof (sig) != ret) | 108 | if (sizeof (sig) != ret) |
96 | { | 109 | { |
97 | if (-1 == ret) | 110 | if (-1 == ret) |
98 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DISK_file_read"); | 111 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, |
99 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Closing control pipe\n"); | 112 | "GNUNET_DISK_file_read"); |
113 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
114 | "Closing control pipe\n"); | ||
100 | GNUNET_DISK_file_close (control_pipe); | 115 | GNUNET_DISK_file_close (control_pipe); |
101 | control_pipe = NULL; | 116 | control_pipe = NULL; |
102 | return; | 117 | return; |
103 | } | 118 | } |
104 | pipe_fd = getenv (GNUNET_OS_CONTROL_PIPE); | 119 | pipe_fd = getenv (GNUNET_OS_CONTROL_PIPE); |
105 | GNUNET_assert ( (NULL == pipe_fd) || (strlen (pipe_fd) <= 0) ); | 120 | GNUNET_assert ( (NULL == pipe_fd) || |
121 | (strlen (pipe_fd) <= 0) ); | ||
106 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 122 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
107 | "Got control code %d from parent via pipe %s\n", sig, pipe_fd); | 123 | "Got control code %d from parent via pipe %s\n", |
108 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | 124 | sig, |
109 | control_pipe, &parent_control_handler, | 125 | pipe_fd); |
110 | control_pipe); | 126 | pch = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
127 | control_pipe, | ||
128 | &parent_control_handler, | ||
129 | control_pipe); | ||
111 | GNUNET_SIGNAL_raise ((int) sig); | 130 | GNUNET_SIGNAL_raise ((int) sig); |
112 | } | 131 | } |
113 | 132 | ||
@@ -115,7 +134,7 @@ parent_control_handler (void *cls) | |||
115 | /** | 134 | /** |
116 | * Task that connects this process to its parent via pipe; | 135 | * Task that connects this process to its parent via pipe; |
117 | * essentially, the parent control handler will read signal numbers | 136 | * essentially, the parent control handler will read signal numbers |
118 | * from the 'GNUNET_OS_CONTROL_PIPE' (as given in an environment | 137 | * from the #GNUNET_OS_CONTROL_PIPE (as given in an environment |
119 | * variable) and raise those signals. | 138 | * variable) and raise those signals. |
120 | * | 139 | * |
121 | * @param cls closure (unused) | 140 | * @param cls closure (unused) |
@@ -128,6 +147,12 @@ GNUNET_OS_install_parent_control_handler (void *cls) | |||
128 | struct GNUNET_DISK_FileHandle *control_pipe; | 147 | struct GNUNET_DISK_FileHandle *control_pipe; |
129 | uint64_t pipe_fd; | 148 | uint64_t pipe_fd; |
130 | 149 | ||
150 | if (NULL != pch) | ||
151 | { | ||
152 | /* already done, we've been called twice... */ | ||
153 | GNUNET_break (0); | ||
154 | return; | ||
155 | } | ||
131 | env_buf = getenv (GNUNET_OS_CONTROL_PIPE); | 156 | env_buf = getenv (GNUNET_OS_CONTROL_PIPE); |
132 | if ( (NULL == env_buf) || (strlen (env_buf) <= 0) ) | 157 | if ( (NULL == env_buf) || (strlen (env_buf) <= 0) ) |
133 | { | 158 | { |
@@ -141,7 +166,9 @@ GNUNET_OS_install_parent_control_handler (void *cls) | |||
141 | pipe_fd = strtoull (env_buf, &env_buf_end, 16); | 166 | pipe_fd = strtoull (env_buf, &env_buf_end, 16); |
142 | if ((0 != errno) || (env_buf == env_buf_end)) | 167 | if ((0 != errno) || (env_buf == env_buf_end)) |
143 | { | 168 | { |
144 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "strtoull", env_buf); | 169 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, |
170 | "strtoull", | ||
171 | env_buf); | ||
145 | putenv (GNUNET_OS_CONTROL_PIPE "="); | 172 | putenv (GNUNET_OS_CONTROL_PIPE "="); |
146 | return; | 173 | return; |
147 | } | 174 | } |
@@ -153,7 +180,8 @@ GNUNET_OS_install_parent_control_handler (void *cls) | |||
153 | #endif | 180 | #endif |
154 | { | 181 | { |
155 | LOG (GNUNET_ERROR_TYPE_ERROR, | 182 | LOG (GNUNET_ERROR_TYPE_ERROR, |
156 | "GNUNET_OS_CONTROL_PIPE `%s' contains garbage?\n", env_buf); | 183 | "GNUNET_OS_CONTROL_PIPE `%s' contains garbage?\n", |
184 | env_buf); | ||
157 | putenv (GNUNET_OS_CONTROL_PIPE "="); | 185 | putenv (GNUNET_OS_CONTROL_PIPE "="); |
158 | return; | 186 | return; |
159 | } | 187 | } |
@@ -164,14 +192,21 @@ GNUNET_OS_install_parent_control_handler (void *cls) | |||
164 | #endif | 192 | #endif |
165 | if (NULL == control_pipe) | 193 | if (NULL == control_pipe) |
166 | { | 194 | { |
167 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "open", env_buf); | 195 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, |
196 | "open", | ||
197 | env_buf); | ||
168 | putenv (GNUNET_OS_CONTROL_PIPE "="); | 198 | putenv (GNUNET_OS_CONTROL_PIPE "="); |
169 | return; | 199 | return; |
170 | } | 200 | } |
171 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 201 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
172 | "Adding parent control handler pipe `%s' to the scheduler\n", env_buf); | 202 | "Adding parent control handler pipe `%s' to the scheduler\n", |
173 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, control_pipe, | 203 | env_buf); |
174 | &parent_control_handler, control_pipe); | 204 | pch = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
205 | control_pipe, | ||
206 | &parent_control_handler, | ||
207 | control_pipe); | ||
208 | GNUNET_SCHEDULER_add_shutdown (&shutdown_pch, | ||
209 | control_pipe); | ||
175 | putenv (GNUNET_OS_CONTROL_PIPE "="); | 210 | putenv (GNUNET_OS_CONTROL_PIPE "="); |
176 | } | 211 | } |
177 | 212 | ||
@@ -179,8 +214,8 @@ GNUNET_OS_install_parent_control_handler (void *cls) | |||
179 | /** | 214 | /** |
180 | * Get process structure for current process | 215 | * Get process structure for current process |
181 | * | 216 | * |
182 | * The pointer it returns points to static memory location and must not be | 217 | * The pointer it returns points to static memory location and must |
183 | * deallocated/closed | 218 | * not be deallocated/closed. |
184 | * | 219 | * |
185 | * @return pointer to the process sturcutre for this process | 220 | * @return pointer to the process sturcutre for this process |
186 | */ | 221 | */ |
@@ -205,7 +240,8 @@ GNUNET_OS_process_current () | |||
205 | * @return 0 on success, -1 on error | 240 | * @return 0 on success, -1 on error |
206 | */ | 241 | */ |
207 | int | 242 | int |
208 | GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig) | 243 | GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, |
244 | int sig) | ||
209 | { | 245 | { |
210 | int ret; | 246 | int ret; |
211 | char csig; | 247 | char csig; |
@@ -213,8 +249,13 @@ GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig) | |||
213 | csig = (char) sig; | 249 | csig = (char) sig; |
214 | if (NULL != proc->control_pipe) | 250 | if (NULL != proc->control_pipe) |
215 | { | 251 | { |
216 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending signal %d to pid: %u via pipe\n", sig, proc->pid); | 252 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
217 | ret = GNUNET_DISK_file_write (proc->control_pipe, &csig, sizeof (csig)); | 253 | "Sending signal %d to pid: %u via pipe\n", |
254 | sig, | ||
255 | proc->pid); | ||
256 | ret = GNUNET_DISK_file_write (proc->control_pipe, | ||
257 | &csig, | ||
258 | sizeof (csig)); | ||
218 | if (sizeof (csig) == ret) | 259 | if (sizeof (csig) == ret) |
219 | return 0; | 260 | return 0; |
220 | } | 261 | } |
@@ -237,14 +278,17 @@ GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig) | |||
237 | if (0 != GetExitCodeProcess (proc->handle, &exitcode)) | 278 | if (0 != GetExitCodeProcess (proc->handle, &exitcode)) |
238 | must_kill = (exitcode == STILL_ACTIVE) ? GNUNET_YES : GNUNET_NO; | 279 | must_kill = (exitcode == STILL_ACTIVE) ? GNUNET_YES : GNUNET_NO; |
239 | if (GNUNET_YES == must_kill) | 280 | if (GNUNET_YES == must_kill) |
281 | { | ||
240 | if (0 == SafeTerminateProcess (proc->handle, 0, 0)) | 282 | if (0 == SafeTerminateProcess (proc->handle, 0, 0)) |
241 | { | 283 | { |
242 | DWORD error_code = GetLastError (); | 284 | DWORD error_code = GetLastError (); |
243 | if ((error_code != WAIT_TIMEOUT) && (error_code != ERROR_PROCESS_ABORTED)) | 285 | if ( (error_code != WAIT_TIMEOUT) && |
286 | (error_code != ERROR_PROCESS_ABORTED) ) | ||
244 | { | 287 | { |
245 | LOG ((error_code == ERROR_ACCESS_DENIED) ? | 288 | LOG ((error_code == ERROR_ACCESS_DENIED) ? |
246 | GNUNET_ERROR_TYPE_INFO : GNUNET_ERROR_TYPE_WARNING, | 289 | GNUNET_ERROR_TYPE_INFO : GNUNET_ERROR_TYPE_WARNING, |
247 | "SafeTermiateProcess failed with code %lu\n", error_code); | 290 | "SafeTermiateProcess failed with code %lu\n", |
291 | error_code); | ||
248 | /* The problem here is that a process that is already dying | 292 | /* The problem here is that a process that is already dying |
249 | * might cause SafeTerminateProcess to fail with | 293 | * might cause SafeTerminateProcess to fail with |
250 | * ERROR_ACCESS_DENIED, but the process WILL die eventually. | 294 | * ERROR_ACCESS_DENIED, but the process WILL die eventually. |
@@ -263,6 +307,7 @@ GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig) | |||
263 | } | 307 | } |
264 | } | 308 | } |
265 | } | 309 | } |
310 | } | ||
266 | } | 311 | } |
267 | return 0; | 312 | return 0; |
268 | #else | 313 | #else |
@@ -277,12 +322,16 @@ GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig) | |||
277 | errno = EINVAL; | 322 | errno = EINVAL; |
278 | return -1; | 323 | return -1; |
279 | #else | 324 | #else |
280 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending signal %d to pid: %u via system call\n", sig, proc->pid); | 325 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
326 | "Sending signal %d to pid: %u via system call\n", | ||
327 | sig, | ||
328 | proc->pid); | ||
281 | return PLIBC_KILL (proc->pid, sig); | 329 | return PLIBC_KILL (proc->pid, sig); |
282 | #endif | 330 | #endif |
283 | } | 331 | } |
284 | } | 332 | } |
285 | 333 | ||
334 | |||
286 | /** | 335 | /** |
287 | * Get the pid of the process in question | 336 | * Get the pid of the process in question |
288 | * | 337 | * |
@@ -298,7 +347,8 @@ GNUNET_OS_process_get_pid (struct GNUNET_OS_Process * proc) | |||
298 | 347 | ||
299 | 348 | ||
300 | /** | 349 | /** |
301 | * Cleans up process structure contents (OS-dependent) and deallocates it | 350 | * Cleans up process structure contents (OS-dependent) and deallocates |
351 | * it. | ||
302 | * | 352 | * |
303 | * @param proc pointer to process structure | 353 | * @param proc pointer to process structure |
304 | */ | 354 | */ |
@@ -314,6 +364,7 @@ GNUNET_OS_process_destroy (struct GNUNET_OS_Process *proc) | |||
314 | GNUNET_free (proc); | 364 | GNUNET_free (proc); |
315 | } | 365 | } |
316 | 366 | ||
367 | |||
317 | #if WINDOWS | 368 | #if WINDOWS |
318 | #include "gnunet_signal_lib.h" | 369 | #include "gnunet_signal_lib.h" |
319 | 370 | ||
@@ -324,6 +375,7 @@ extern GNUNET_SIGNAL_Handler w32_sigchld_handler; | |||
324 | */ | 375 | */ |
325 | #define DWORD_WINAPI DWORD WINAPI | 376 | #define DWORD_WINAPI DWORD WINAPI |
326 | 377 | ||
378 | |||
327 | /** | 379 | /** |
328 | * @brief Waits for a process to terminate and invokes the SIGCHLD handler | 380 | * @brief Waits for a process to terminate and invokes the SIGCHLD handler |
329 | * @param proc pointer to process structure | 381 | * @param proc pointer to process structure |
@@ -467,7 +519,9 @@ open_dev_null (int target_fd, | |||
467 | fd = open ("/dev/null", flags); | 519 | fd = open ("/dev/null", flags); |
468 | if (-1 == fd) | 520 | if (-1 == fd) |
469 | { | 521 | { |
470 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", "/dev/null"); | 522 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, |
523 | "open", | ||
524 | "/dev/null"); | ||
471 | return; | 525 | return; |
472 | } | 526 | } |
473 | if (fd == target_fd) | 527 | if (fd == target_fd) |
@@ -531,23 +585,30 @@ start_process (int pipe_control, | |||
531 | int fd_stdin_read; | 585 | int fd_stdin_read; |
532 | int fd_stdin_write; | 586 | int fd_stdin_write; |
533 | 587 | ||
534 | if (GNUNET_SYSERR == GNUNET_OS_check_helper_binary (filename, GNUNET_NO, NULL)) | 588 | if (GNUNET_SYSERR == |
589 | GNUNET_OS_check_helper_binary (filename, GNUNET_NO, NULL)) | ||
535 | return NULL; /* not executable */ | 590 | return NULL; /* not executable */ |
536 | if (GNUNET_YES == pipe_control) | 591 | if (GNUNET_YES == pipe_control) |
537 | { | 592 | { |
538 | struct GNUNET_DISK_PipeHandle *childpipe; | 593 | struct GNUNET_DISK_PipeHandle *childpipe; |
539 | int dup_childpipe_read_fd = -1; | 594 | int dup_childpipe_read_fd = -1; |
540 | 595 | ||
541 | childpipe = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO, GNUNET_YES, GNUNET_NO); | 596 | childpipe = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO, |
597 | GNUNET_YES, GNUNET_NO); | ||
542 | if (NULL == childpipe) | 598 | if (NULL == childpipe) |
543 | return NULL; | 599 | return NULL; |
544 | childpipe_read = GNUNET_DISK_pipe_detach_end (childpipe, GNUNET_DISK_PIPE_END_READ); | 600 | childpipe_read = GNUNET_DISK_pipe_detach_end (childpipe, |
545 | childpipe_write = GNUNET_DISK_pipe_detach_end (childpipe, GNUNET_DISK_PIPE_END_WRITE); | 601 | GNUNET_DISK_PIPE_END_READ); |
602 | childpipe_write = GNUNET_DISK_pipe_detach_end (childpipe, | ||
603 | GNUNET_DISK_PIPE_END_WRITE); | ||
546 | GNUNET_DISK_pipe_close (childpipe); | 604 | GNUNET_DISK_pipe_close (childpipe); |
547 | if ((NULL == childpipe_read) || (NULL == childpipe_write) || | 605 | if ( (NULL == childpipe_read) || |
548 | (GNUNET_OK != GNUNET_DISK_internal_file_handle_ (childpipe_read, | 606 | (NULL == childpipe_write) || |
549 | &childpipe_read_fd, sizeof (int))) || | 607 | (GNUNET_OK != |
550 | (-1 == (dup_childpipe_read_fd = dup (childpipe_read_fd)))) | 608 | GNUNET_DISK_internal_file_handle_ (childpipe_read, |
609 | &childpipe_read_fd, | ||
610 | sizeof (int))) || | ||
611 | (-1 == (dup_childpipe_read_fd = dup (childpipe_read_fd)))) | ||
551 | { | 612 | { |
552 | if (NULL != childpipe_read) | 613 | if (NULL != childpipe_read) |
553 | GNUNET_DISK_file_close (childpipe_read); | 614 | GNUNET_DISK_file_close (childpipe_read); |
@@ -1762,17 +1823,19 @@ cmd_read (void *cls) | |||
1762 | 1823 | ||
1763 | cmd->rtask = NULL; | 1824 | cmd->rtask = NULL; |
1764 | tc = GNUNET_SCHEDULER_get_task_context (); | 1825 | tc = GNUNET_SCHEDULER_get_task_context (); |
1765 | if (GNUNET_YES != GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, cmd->r)) | 1826 | if (GNUNET_YES != |
1827 | GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, | ||
1828 | cmd->r)) | ||
1766 | { | 1829 | { |
1767 | /* timeout, shutdown, etc. */ | 1830 | /* timeout */ |
1768 | proc = cmd->proc; | 1831 | proc = cmd->proc; |
1769 | cmd->proc = NULL; | 1832 | cmd->proc = NULL; |
1770 | proc (cmd->proc_cls, NULL); | 1833 | proc (cmd->proc_cls, NULL); |
1771 | return; | 1834 | return; |
1772 | } | 1835 | } |
1773 | ret = | 1836 | ret = GNUNET_DISK_file_read (cmd->r, |
1774 | GNUNET_DISK_file_read (cmd->r, &cmd->buf[cmd->off], | 1837 | &cmd->buf[cmd->off], |
1775 | sizeof (cmd->buf) - cmd->off); | 1838 | sizeof (cmd->buf) - cmd->off); |
1776 | if (ret <= 0) | 1839 | if (ret <= 0) |
1777 | { | 1840 | { |
1778 | if ((cmd->off > 0) && (cmd->off < sizeof (cmd->buf))) | 1841 | if ((cmd->off > 0) && (cmd->off < sizeof (cmd->buf))) |
@@ -1795,9 +1858,11 @@ cmd_read (void *cls) | |||
1795 | cmd->off -= (end + 1 - cmd->buf); | 1858 | cmd->off -= (end + 1 - cmd->buf); |
1796 | end = memchr (cmd->buf, '\n', cmd->off); | 1859 | end = memchr (cmd->buf, '\n', cmd->off); |
1797 | } | 1860 | } |
1798 | cmd->rtask = | 1861 | cmd->rtask |
1799 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_absolute_get_remaining | 1862 | = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_absolute_get_remaining |
1800 | (cmd->timeout), cmd->r, &cmd_read, cmd); | 1863 | (cmd->timeout), |
1864 | cmd->r, | ||
1865 | &cmd_read, cmd); | ||
1801 | } | 1866 | } |
1802 | 1867 | ||
1803 | 1868 | ||
@@ -1824,12 +1889,15 @@ GNUNET_OS_command_run (GNUNET_OS_LineProcessor proc, | |||
1824 | struct GNUNET_DISK_PipeHandle *opipe; | 1889 | struct GNUNET_DISK_PipeHandle *opipe; |
1825 | va_list ap; | 1890 | va_list ap; |
1826 | 1891 | ||
1827 | opipe = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO, GNUNET_YES); | 1892 | opipe = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, |
1893 | GNUNET_NO, GNUNET_YES); | ||
1828 | if (NULL == opipe) | 1894 | if (NULL == opipe) |
1829 | return NULL; | 1895 | return NULL; |
1830 | va_start (ap, binary); | 1896 | va_start (ap, binary); |
1831 | /* redirect stdout, don't inherit stderr/stdin */ | 1897 | /* redirect stdout, don't inherit stderr/stdin */ |
1832 | eip = GNUNET_OS_start_process_va (GNUNET_NO, 0, NULL, opipe, NULL, binary, ap); | 1898 | eip = GNUNET_OS_start_process_va (GNUNET_NO, 0, NULL, |
1899 | opipe, NULL, binary, | ||
1900 | ap); | ||
1833 | va_end (ap); | 1901 | va_end (ap); |
1834 | if (NULL == eip) | 1902 | if (NULL == eip) |
1835 | { | 1903 | { |
@@ -1843,8 +1911,12 @@ GNUNET_OS_command_run (GNUNET_OS_LineProcessor proc, | |||
1843 | cmd->opipe = opipe; | 1911 | cmd->opipe = opipe; |
1844 | cmd->proc = proc; | 1912 | cmd->proc = proc; |
1845 | cmd->proc_cls = proc_cls; | 1913 | cmd->proc_cls = proc_cls; |
1846 | cmd->r = GNUNET_DISK_pipe_handle (opipe, GNUNET_DISK_PIPE_END_READ); | 1914 | cmd->r = GNUNET_DISK_pipe_handle (opipe, |
1847 | cmd->rtask = GNUNET_SCHEDULER_add_read_file (timeout, cmd->r, &cmd_read, cmd); | 1915 | GNUNET_DISK_PIPE_END_READ); |
1916 | cmd->rtask = GNUNET_SCHEDULER_add_read_file (timeout, | ||
1917 | cmd->r, | ||
1918 | &cmd_read, | ||
1919 | cmd); | ||
1848 | return cmd; | 1920 | return cmd; |
1849 | } | 1921 | } |
1850 | 1922 | ||
diff --git a/src/util/program.c b/src/util/program.c index bf7885fe9..72f6a1e6c 100644 --- a/src/util/program.c +++ b/src/util/program.c | |||
@@ -76,11 +76,7 @@ static void | |||
76 | program_main (void *cls) | 76 | program_main (void *cls) |
77 | { | 77 | { |
78 | struct CommandContext *cc = cls; | 78 | struct CommandContext *cc = cls; |
79 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
80 | 79 | ||
81 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
82 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | ||
83 | return; | ||
84 | GNUNET_SPEEDUP_start_(cc->cfg); | 80 | GNUNET_SPEEDUP_start_(cc->cfg); |
85 | GNUNET_RESOLVER_connect (cc->cfg); | 81 | GNUNET_RESOLVER_connect (cc->cfg); |
86 | cc->task (cc->task_cls, cc->args, cc->cfgfile, cc->cfg); | 82 | cc->task (cc->task_cls, cc->args, cc->cfgfile, cc->cfg); |
diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c index e7a836f03..0488d6a3c 100644 --- a/src/util/resolver_api.c +++ b/src/util/resolver_api.c | |||
@@ -118,7 +118,7 @@ struct GNUNET_RESOLVER_RequestHandle | |||
118 | GNUNET_RESOLVER_HostnameCallback name_callback; | 118 | GNUNET_RESOLVER_HostnameCallback name_callback; |
119 | 119 | ||
120 | /** | 120 | /** |
121 | * Closure for the respective "callback". | 121 | * Closure for the callbacks. |
122 | */ | 122 | */ |
123 | void *cls; | 123 | void *cls; |
124 | 124 | ||
@@ -131,7 +131,7 @@ struct GNUNET_RESOLVER_RequestHandle | |||
131 | * Task handle for making reply callbacks in numeric lookups | 131 | * Task handle for making reply callbacks in numeric lookups |
132 | * asynchronous, and for timeout handling. | 132 | * asynchronous, and for timeout handling. |
133 | */ | 133 | */ |
134 | struct GNUNET_SCHEDULER_Task * task; | 134 | struct GNUNET_SCHEDULER_Task *task; |
135 | 135 | ||
136 | /** | 136 | /** |
137 | * Desired address family. | 137 | * Desired address family. |
@@ -638,6 +638,7 @@ loopback_resolution (void *cls) | |||
638 | rh->addr_callback (rh->cls, | 638 | rh->addr_callback (rh->cls, |
639 | (const struct sockaddr *) &v4, | 639 | (const struct sockaddr *) &v4, |
640 | sizeof (v4)); | 640 | sizeof (v4)); |
641 | |||
641 | break; | 642 | break; |
642 | default: | 643 | default: |
643 | GNUNET_break (0); | 644 | GNUNET_break (0); |
@@ -683,7 +684,7 @@ process_requests () | |||
683 | /* nothing to do, release socket really soon if there is nothing | 684 | /* nothing to do, release socket really soon if there is nothing |
684 | * else happening... */ | 685 | * else happening... */ |
685 | s_task = | 686 | s_task = |
686 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS, | 687 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
687 | &shutdown_task, | 688 | &shutdown_task, |
688 | NULL); | 689 | NULL); |
689 | return; | 690 | return; |
@@ -727,14 +728,9 @@ process_requests () | |||
727 | static void | 728 | static void |
728 | reconnect_task (void *cls) | 729 | reconnect_task (void *cls) |
729 | { | 730 | { |
730 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
731 | |||
732 | r_task = NULL; | 731 | r_task = NULL; |
733 | if (NULL == req_head) | 732 | if (NULL == req_head) |
734 | return; /* no work pending */ | 733 | return; /* no work pending */ |
735 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
736 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
737 | return; | ||
738 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 734 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
739 | "Trying to connect to DNS service\n"); | 735 | "Trying to connect to DNS service\n"); |
740 | client = GNUNET_CLIENT_connect ("resolver", | 736 | client = GNUNET_CLIENT_connect ("resolver", |
@@ -774,7 +770,9 @@ reconnect () | |||
774 | break; | 770 | break; |
775 | case GNUNET_SYSERR: | 771 | case GNUNET_SYSERR: |
776 | /* request was cancelled, remove entirely */ | 772 | /* request was cancelled, remove entirely */ |
777 | GNUNET_CONTAINER_DLL_remove (req_head, req_tail, rh); | 773 | GNUNET_CONTAINER_DLL_remove (req_head, |
774 | req_tail, | ||
775 | rh); | ||
778 | GNUNET_free (rh); | 776 | GNUNET_free (rh); |
779 | break; | 777 | break; |
780 | default: | 778 | default: |
diff --git a/src/util/scheduler.c b/src/util/scheduler.c index dcf5aeeaa..81f968dee 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2009-2013 GNUnet e.V. | 3 | Copyright (C) 2009-2016 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -152,6 +152,11 @@ struct GNUNET_SCHEDULER_Task | |||
152 | int lifeness; | 152 | int lifeness; |
153 | 153 | ||
154 | /** | 154 | /** |
155 | * Is this task run on shutdown? | ||
156 | */ | ||
157 | int on_shutdown; | ||
158 | |||
159 | /** | ||
155 | * Is this task in the ready list? | 160 | * Is this task in the ready list? |
156 | */ | 161 | */ |
157 | int in_ready_list; | 162 | int in_ready_list; |
@@ -184,6 +189,16 @@ static struct GNUNET_SCHEDULER_Task *pending_head; | |||
184 | static struct GNUNET_SCHEDULER_Task *pending_tail; | 189 | static struct GNUNET_SCHEDULER_Task *pending_tail; |
185 | 190 | ||
186 | /** | 191 | /** |
192 | * Head of list of tasks waiting for shutdown. | ||
193 | */ | ||
194 | static struct GNUNET_SCHEDULER_Task *shutdown_head; | ||
195 | |||
196 | /** | ||
197 | * Tail of list of tasks waiting for shutdown. | ||
198 | */ | ||
199 | static struct GNUNET_SCHEDULER_Task *shutdown_tail; | ||
200 | |||
201 | /** | ||
187 | * List of tasks waiting ONLY for a timeout event. | 202 | * List of tasks waiting ONLY for a timeout event. |
188 | * Sorted by timeout (earliest first). Used so that | 203 | * Sorted by timeout (earliest first). Used so that |
189 | * we do not traverse the list of these tasks when | 204 | * we do not traverse the list of these tasks when |
@@ -421,8 +436,6 @@ queue_ready_task (struct GNUNET_SCHEDULER_Task *task) | |||
421 | { | 436 | { |
422 | enum GNUNET_SCHEDULER_Priority p = check_priority (task->priority); | 437 | enum GNUNET_SCHEDULER_Priority p = check_priority (task->priority); |
423 | 438 | ||
424 | if (0 != (task->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
425 | p = task->priority = GNUNET_SCHEDULER_PRIORITY_SHUTDOWN; | ||
426 | GNUNET_CONTAINER_DLL_insert (ready_head[p], | 439 | GNUNET_CONTAINER_DLL_insert (ready_head[p], |
427 | ready_tail[p], | 440 | ready_tail[p], |
428 | task); | 441 | task); |
@@ -477,29 +490,24 @@ check_ready (const struct GNUNET_NETWORK_FDSet *rs, | |||
477 | 490 | ||
478 | 491 | ||
479 | /** | 492 | /** |
480 | * Request the shutdown of a scheduler. Marks all currently | 493 | * Request the shutdown of a scheduler. Marks all tasks |
481 | * pending tasks as ready because of shutdown. This will | 494 | * awaiting shutdown as ready. Note that tasks |
482 | * cause all tasks to run (as soon as possible, respecting | 495 | * scheduled with #GNUNET_SCHEDULER_add_shutdown() AFTER this call |
483 | * priorities and prerequisite tasks). Note that tasks | 496 | * will be delayed until the next shutdown signal. |
484 | * scheduled AFTER this call may still be delayed arbitrarily. | ||
485 | * | ||
486 | * Note that we don't move the tasks into the ready queue yet; | ||
487 | * check_ready() will do that later, possibly adding additional | ||
488 | * readiness-factors | ||
489 | */ | 497 | */ |
490 | void | 498 | void |
491 | GNUNET_SCHEDULER_shutdown () | 499 | GNUNET_SCHEDULER_shutdown () |
492 | { | 500 | { |
493 | struct GNUNET_SCHEDULER_Task *pos; | 501 | struct GNUNET_SCHEDULER_Task *pos; |
494 | int i; | ||
495 | 502 | ||
496 | for (pos = pending_timeout_head; NULL != pos; pos = pos->next) | 503 | while (NULL != (pos = shutdown_head)) |
497 | pos->reason |= GNUNET_SCHEDULER_REASON_SHUTDOWN; | 504 | { |
498 | for (pos = pending_head; NULL != pos; pos = pos->next) | 505 | GNUNET_CONTAINER_DLL_remove (shutdown_head, |
506 | shutdown_tail, | ||
507 | pos); | ||
499 | pos->reason |= GNUNET_SCHEDULER_REASON_SHUTDOWN; | 508 | pos->reason |= GNUNET_SCHEDULER_REASON_SHUTDOWN; |
500 | for (i = 0; i < GNUNET_SCHEDULER_PRIORITY_COUNT; i++) | 509 | queue_ready_task (pos); |
501 | for (pos = ready_head[i]; NULL != pos; pos = pos->next) | 510 | } |
502 | pos->reason |= GNUNET_SCHEDULER_REASON_SHUTDOWN; | ||
503 | } | 511 | } |
504 | 512 | ||
505 | 513 | ||
@@ -523,6 +531,27 @@ destroy_task (struct GNUNET_SCHEDULER_Task *t) | |||
523 | 531 | ||
524 | 532 | ||
525 | /** | 533 | /** |
534 | * Output stack trace of task @a t. | ||
535 | * | ||
536 | * @param t task to dump stack trace of | ||
537 | */ | ||
538 | static void | ||
539 | dump_backtrace (struct GNUNET_SCHEDULER_Task *t) | ||
540 | { | ||
541 | #if EXECINFO | ||
542 | unsigned int i; | ||
543 | |||
544 | for (i = 0; i < t->num_backtrace_strings; i++) | ||
545 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
546 | "Task %p trace %u: %s\n", | ||
547 | t, | ||
548 | i, | ||
549 | t->backtrace_strings[i]); | ||
550 | #endif | ||
551 | } | ||
552 | |||
553 | |||
554 | /** | ||
526 | * Run at least one task in the highest-priority queue that is not | 555 | * Run at least one task in the highest-priority queue that is not |
527 | * empty. Keep running tasks until we are either no longer running | 556 | * empty. Keep running tasks until we are either no longer running |
528 | * "URGENT" tasks or until we have at least one "pending" task (which | 557 | * "URGENT" tasks or until we have at least one "pending" task (which |
@@ -589,16 +618,7 @@ run_ready (struct GNUNET_NETWORK_FDSet *rs, | |||
589 | "Running task: %p\n", | 618 | "Running task: %p\n", |
590 | pos); | 619 | pos); |
591 | pos->callback (pos->callback_cls); | 620 | pos->callback (pos->callback_cls); |
592 | #if EXECINFO | 621 | dump_backtrace (pos); |
593 | unsigned int i; | ||
594 | |||
595 | for (i = 0; i < pos->num_backtrace_strings; i++) | ||
596 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
597 | "Task %p trace %u: %s\n", | ||
598 | pos, | ||
599 | i, | ||
600 | pos->backtrace_strings[i]); | ||
601 | #endif | ||
602 | active_task = NULL; | 622 | active_task = NULL; |
603 | destroy_task (pos); | 623 | destroy_task (pos); |
604 | tasks_run++; | 624 | tasks_run++; |
@@ -684,10 +704,13 @@ check_lifeness () | |||
684 | for (t = pending_head; NULL != t; t = t->next) | 704 | for (t = pending_head; NULL != t; t = t->next) |
685 | if (t->lifeness == GNUNET_YES) | 705 | if (t->lifeness == GNUNET_YES) |
686 | return GNUNET_OK; | 706 | return GNUNET_OK; |
707 | for (t = shutdown_head; NULL != t; t = t->next) | ||
708 | if (t->lifeness == GNUNET_YES) | ||
709 | return GNUNET_OK; | ||
687 | for (t = pending_timeout_head; NULL != t; t = t->next) | 710 | for (t = pending_timeout_head; NULL != t; t = t->next) |
688 | if (t->lifeness == GNUNET_YES) | 711 | if (t->lifeness == GNUNET_YES) |
689 | return GNUNET_OK; | 712 | return GNUNET_OK; |
690 | if ((NULL != pending_head) || (NULL != pending_timeout_head)) | 713 | if (NULL != shutdown_head) |
691 | { | 714 | { |
692 | GNUNET_SCHEDULER_shutdown (); | 715 | GNUNET_SCHEDULER_shutdown (); |
693 | return GNUNET_OK; | 716 | return GNUNET_OK; |
@@ -749,15 +772,21 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task, | |||
749 | my_pid = getpid (); | 772 | my_pid = getpid (); |
750 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 773 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
751 | "Registering signal handlers\n"); | 774 | "Registering signal handlers\n"); |
752 | shc_int = GNUNET_SIGNAL_handler_install (SIGINT, &sighandler_shutdown); | 775 | shc_int = GNUNET_SIGNAL_handler_install (SIGINT, |
753 | shc_term = GNUNET_SIGNAL_handler_install (SIGTERM, &sighandler_shutdown); | 776 | &sighandler_shutdown); |
777 | shc_term = GNUNET_SIGNAL_handler_install (SIGTERM, | ||
778 | &sighandler_shutdown); | ||
754 | #if (SIGTERM != GNUNET_TERM_SIG) | 779 | #if (SIGTERM != GNUNET_TERM_SIG) |
755 | shc_gterm = GNUNET_SIGNAL_handler_install (GNUNET_TERM_SIG, &sighandler_shutdown); | 780 | shc_gterm = GNUNET_SIGNAL_handler_install (GNUNET_TERM_SIG, |
781 | &sighandler_shutdown); | ||
756 | #endif | 782 | #endif |
757 | #ifndef MINGW | 783 | #ifndef MINGW |
758 | shc_pipe = GNUNET_SIGNAL_handler_install (SIGPIPE, &sighandler_pipe); | 784 | shc_pipe = GNUNET_SIGNAL_handler_install (SIGPIPE, |
759 | shc_quit = GNUNET_SIGNAL_handler_install (SIGQUIT, &sighandler_shutdown); | 785 | &sighandler_pipe); |
760 | shc_hup = GNUNET_SIGNAL_handler_install (SIGHUP, &sighandler_shutdown); | 786 | shc_quit = GNUNET_SIGNAL_handler_install (SIGQUIT, |
787 | &sighandler_shutdown); | ||
788 | shc_hup = GNUNET_SIGNAL_handler_install (SIGHUP, | ||
789 | &sighandler_shutdown); | ||
761 | #endif | 790 | #endif |
762 | current_priority = GNUNET_SCHEDULER_PRIORITY_DEFAULT; | 791 | current_priority = GNUNET_SCHEDULER_PRIORITY_DEFAULT; |
763 | current_lifeness = GNUNET_YES; | 792 | current_lifeness = GNUNET_YES; |
@@ -826,14 +855,7 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task, | |||
826 | LOG (GNUNET_ERROR_TYPE_ERROR, | 855 | LOG (GNUNET_ERROR_TYPE_ERROR, |
827 | "Got invalid file descriptor %d!\n", | 856 | "Got invalid file descriptor %d!\n", |
828 | t->read_fd); | 857 | t->read_fd); |
829 | #if EXECINFO | 858 | dump_backtrace (t); |
830 | unsigned int i; | ||
831 | |||
832 | for (i = 0; i < t->num_backtrace_strings; i++) | ||
833 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
834 | "Trace: %s\n", | ||
835 | t->backtrace_strings[i]); | ||
836 | #endif | ||
837 | } | 859 | } |
838 | } | 860 | } |
839 | if (-1 != t->write_fd) | 861 | if (-1 != t->write_fd) |
@@ -844,14 +866,7 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task, | |||
844 | LOG (GNUNET_ERROR_TYPE_ERROR, | 866 | LOG (GNUNET_ERROR_TYPE_ERROR, |
845 | "Got invalid file descriptor %d!\n", | 867 | "Got invalid file descriptor %d!\n", |
846 | t->write_fd); | 868 | t->write_fd); |
847 | #if EXECINFO | 869 | dump_backtrace (t); |
848 | unsigned int i; | ||
849 | |||
850 | for (i = 0; i < t->num_backtrace_strings; i++) | ||
851 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
852 | "Trace: %s\n", | ||
853 | t->backtrace_strings[i]); | ||
854 | #endif | ||
855 | } | 870 | } |
856 | } | 871 | } |
857 | } | 872 | } |
@@ -959,7 +974,8 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Task *task) | |||
959 | enum GNUNET_SCHEDULER_Priority p; | 974 | enum GNUNET_SCHEDULER_Priority p; |
960 | void *ret; | 975 | void *ret; |
961 | 976 | ||
962 | GNUNET_assert (NULL != active_task); | 977 | GNUNET_assert ( (NULL != active_task) || |
978 | (GNUNET_NO == task->lifeness) ); | ||
963 | if (! task->in_ready_list) | 979 | if (! task->in_ready_list) |
964 | { | 980 | { |
965 | if ( (-1 == task->read_fd) && | 981 | if ( (-1 == task->read_fd) && |
@@ -967,9 +983,14 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Task *task) | |||
967 | (NULL == task->read_set) && | 983 | (NULL == task->read_set) && |
968 | (NULL == task->write_set) ) | 984 | (NULL == task->write_set) ) |
969 | { | 985 | { |
970 | GNUNET_CONTAINER_DLL_remove (pending_timeout_head, | 986 | if (GNUNET_YES == task->on_shutdown) |
971 | pending_timeout_tail, | 987 | GNUNET_CONTAINER_DLL_remove (shutdown_head, |
972 | task); | 988 | shutdown_tail, |
989 | task); | ||
990 | else | ||
991 | GNUNET_CONTAINER_DLL_remove (pending_timeout_head, | ||
992 | pending_timeout_tail, | ||
993 | task); | ||
973 | if (task == pending_timeout_last) | 994 | if (task == pending_timeout_last) |
974 | pending_timeout_last = NULL; | 995 | pending_timeout_last = NULL; |
975 | } | 996 | } |
@@ -998,6 +1019,27 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Task *task) | |||
998 | 1019 | ||
999 | 1020 | ||
1000 | /** | 1021 | /** |
1022 | * Initialize backtrace data for task @a t | ||
1023 | * | ||
1024 | * @param t task to initialize | ||
1025 | */ | ||
1026 | static void | ||
1027 | init_backtrace (struct GNUNET_SCHEDULER_Task *t) | ||
1028 | { | ||
1029 | #if EXECINFO | ||
1030 | void *backtrace_array[MAX_TRACE_DEPTH]; | ||
1031 | |||
1032 | t->num_backtrace_strings | ||
1033 | = backtrace (backtrace_array, MAX_TRACE_DEPTH); | ||
1034 | t->backtrace_strings = | ||
1035 | backtrace_symbols (backtrace_array, | ||
1036 | t->num_backtrace_strings); | ||
1037 | dump_backtrace (t); | ||
1038 | #endif | ||
1039 | } | ||
1040 | |||
1041 | |||
1042 | /** | ||
1001 | * Continue the current execution with the given function. This is | 1043 | * Continue the current execution with the given function. This is |
1002 | * similar to the other "add" functions except that there is no delay | 1044 | * similar to the other "add" functions except that there is no delay |
1003 | * and the reason code can be specified. | 1045 | * and the reason code can be specified. |
@@ -1015,19 +1057,10 @@ GNUNET_SCHEDULER_add_with_reason_and_priority (GNUNET_SCHEDULER_TaskCallback tas | |||
1015 | { | 1057 | { |
1016 | struct GNUNET_SCHEDULER_Task *t; | 1058 | struct GNUNET_SCHEDULER_Task *t; |
1017 | 1059 | ||
1018 | #if EXECINFO | ||
1019 | void *backtrace_array[50]; | ||
1020 | #endif | ||
1021 | |||
1022 | GNUNET_assert (NULL != task); | 1060 | GNUNET_assert (NULL != task); |
1023 | GNUNET_assert ((NULL != active_task) || | 1061 | GNUNET_assert ((NULL != active_task) || |
1024 | (GNUNET_SCHEDULER_REASON_STARTUP == reason)); | 1062 | (GNUNET_SCHEDULER_REASON_STARTUP == reason)); |
1025 | t = GNUNET_new (struct GNUNET_SCHEDULER_Task); | 1063 | t = GNUNET_new (struct GNUNET_SCHEDULER_Task); |
1026 | #if EXECINFO | ||
1027 | t->num_backtrace_strings = backtrace (backtrace_array, 50); | ||
1028 | t->backtrace_strings = | ||
1029 | backtrace_symbols (backtrace_array, t->num_backtrace_strings); | ||
1030 | #endif | ||
1031 | t->read_fd = -1; | 1064 | t->read_fd = -1; |
1032 | t->write_fd = -1; | 1065 | t->write_fd = -1; |
1033 | t->callback = task; | 1066 | t->callback = task; |
@@ -1041,6 +1074,7 @@ GNUNET_SCHEDULER_add_with_reason_and_priority (GNUNET_SCHEDULER_TaskCallback tas | |||
1041 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1074 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1042 | "Adding continuation task %p\n", | 1075 | "Adding continuation task %p\n", |
1043 | t); | 1076 | t); |
1077 | init_backtrace (t); | ||
1044 | queue_ready_task (t); | 1078 | queue_ready_task (t); |
1045 | } | 1079 | } |
1046 | 1080 | ||
@@ -1049,8 +1083,7 @@ GNUNET_SCHEDULER_add_with_reason_and_priority (GNUNET_SCHEDULER_TaskCallback tas | |||
1049 | * Schedule a new task to be run with a specified delay. The task | 1083 | * Schedule a new task to be run with a specified delay. The task |
1050 | * will be scheduled for execution once the delay has expired. | 1084 | * will be scheduled for execution once the delay has expired. |
1051 | * | 1085 | * |
1052 | * @param delay when should this operation time out? Use | 1086 | * @param delay when should this operation time out? |
1053 | * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
1054 | * @param priority priority to use for the task | 1087 | * @param priority priority to use for the task |
1055 | * @param task main function of the task | 1088 | * @param task main function of the task |
1056 | * @param task_cls closure of @a task | 1089 | * @param task_cls closure of @a task |
@@ -1067,20 +1100,11 @@ GNUNET_SCHEDULER_add_delayed_with_priority (struct GNUNET_TIME_Relative delay, | |||
1067 | struct GNUNET_SCHEDULER_Task *pos; | 1100 | struct GNUNET_SCHEDULER_Task *pos; |
1068 | struct GNUNET_SCHEDULER_Task *prev; | 1101 | struct GNUNET_SCHEDULER_Task *prev; |
1069 | 1102 | ||
1070 | #if EXECINFO | ||
1071 | void *backtrace_array[MAX_TRACE_DEPTH]; | ||
1072 | #endif | ||
1073 | |||
1074 | GNUNET_assert (NULL != active_task); | 1103 | GNUNET_assert (NULL != active_task); |
1075 | GNUNET_assert (NULL != task); | 1104 | GNUNET_assert (NULL != task); |
1076 | t = GNUNET_new (struct GNUNET_SCHEDULER_Task); | 1105 | t = GNUNET_new (struct GNUNET_SCHEDULER_Task); |
1077 | t->callback = task; | 1106 | t->callback = task; |
1078 | t->callback_cls = task_cls; | 1107 | t->callback_cls = task_cls; |
1079 | #if EXECINFO | ||
1080 | t->num_backtrace_strings = backtrace (backtrace_array, MAX_TRACE_DEPTH); | ||
1081 | t->backtrace_strings = | ||
1082 | backtrace_symbols (backtrace_array, t->num_backtrace_strings); | ||
1083 | #endif | ||
1084 | t->read_fd = -1; | 1108 | t->read_fd = -1; |
1085 | t->write_fd = -1; | 1109 | t->write_fd = -1; |
1086 | #if PROFILE_DELAYS | 1110 | #if PROFILE_DELAYS |
@@ -1127,16 +1151,7 @@ GNUNET_SCHEDULER_add_delayed_with_priority (struct GNUNET_TIME_Relative delay, | |||
1127 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1151 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1128 | "Adding task: %p\n", | 1152 | "Adding task: %p\n", |
1129 | t); | 1153 | t); |
1130 | #if EXECINFO | 1154 | init_backtrace (t); |
1131 | unsigned int i; | ||
1132 | |||
1133 | for (i = 0; i < t->num_backtrace_strings; i++) | ||
1134 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1135 | "Task %p trace %d: %s\n", | ||
1136 | t, | ||
1137 | i, | ||
1138 | t->backtrace_strings[i]); | ||
1139 | #endif | ||
1140 | return t; | 1155 | return t; |
1141 | } | 1156 | } |
1142 | 1157 | ||
@@ -1167,16 +1182,16 @@ GNUNET_SCHEDULER_add_with_priority (enum GNUNET_SCHEDULER_Priority prio, | |||
1167 | * will be scheduled for execution once the delay has expired. It | 1182 | * will be scheduled for execution once the delay has expired. It |
1168 | * will be run with the DEFAULT priority. | 1183 | * will be run with the DEFAULT priority. |
1169 | * | 1184 | * |
1170 | * @param delay when should this operation time out? Use | 1185 | * @param delay when should this operation time out? |
1171 | * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
1172 | * @param task main function of the task | 1186 | * @param task main function of the task |
1173 | * @param task_cls closure of task | 1187 | * @param task_cls closure of @a task |
1174 | * @return unique task identifier for the job | 1188 | * @return unique task identifier for the job |
1175 | * only valid until "task" is started! | 1189 | * only valid until @a task is started! |
1176 | */ | 1190 | */ |
1177 | struct GNUNET_SCHEDULER_Task * | 1191 | struct GNUNET_SCHEDULER_Task * |
1178 | GNUNET_SCHEDULER_add_delayed (struct GNUNET_TIME_Relative delay, | 1192 | GNUNET_SCHEDULER_add_delayed (struct GNUNET_TIME_Relative delay, |
1179 | GNUNET_SCHEDULER_TaskCallback task, void *task_cls) | 1193 | GNUNET_SCHEDULER_TaskCallback task, |
1194 | void *task_cls) | ||
1180 | { | 1195 | { |
1181 | return GNUNET_SCHEDULER_add_delayed_with_priority (delay, | 1196 | return GNUNET_SCHEDULER_add_delayed_with_priority (delay, |
1182 | GNUNET_SCHEDULER_PRIORITY_DEFAULT, | 1197 | GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
@@ -1197,12 +1212,56 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_TIME_Relative delay, | |||
1197 | * @param task main function of the task | 1212 | * @param task main function of the task |
1198 | * @param task_cls closure of @a task | 1213 | * @param task_cls closure of @a task |
1199 | * @return unique task identifier for the job | 1214 | * @return unique task identifier for the job |
1200 | * only valid until "task" is started! | 1215 | * only valid until @a task is started! |
1201 | */ | 1216 | */ |
1202 | struct GNUNET_SCHEDULER_Task * | 1217 | struct GNUNET_SCHEDULER_Task * |
1203 | GNUNET_SCHEDULER_add_now (GNUNET_SCHEDULER_TaskCallback task, void *task_cls) | 1218 | GNUNET_SCHEDULER_add_now (GNUNET_SCHEDULER_TaskCallback task, |
1219 | void *task_cls) | ||
1204 | { | 1220 | { |
1205 | return GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_ZERO, task, task_cls); | 1221 | return GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_ZERO, |
1222 | task, | ||
1223 | task_cls); | ||
1224 | } | ||
1225 | |||
1226 | |||
1227 | /** | ||
1228 | * Schedule a new task to be run on shutdown, that is when a CTRL-C | ||
1229 | * signal is received, or when #GNUNET_SCHEDULER_shutdown() is being | ||
1230 | * invoked. | ||
1231 | * | ||
1232 | * @param task main function of the task | ||
1233 | * @param task_cls closure of @a task | ||
1234 | * @return unique task identifier for the job | ||
1235 | * only valid until @a task is started! | ||
1236 | */ | ||
1237 | struct GNUNET_SCHEDULER_Task * | ||
1238 | GNUNET_SCHEDULER_add_shutdown (GNUNET_SCHEDULER_TaskCallback task, | ||
1239 | void *task_cls) | ||
1240 | { | ||
1241 | struct GNUNET_SCHEDULER_Task *t; | ||
1242 | |||
1243 | GNUNET_assert (NULL != active_task); | ||
1244 | GNUNET_assert (NULL != task); | ||
1245 | t = GNUNET_new (struct GNUNET_SCHEDULER_Task); | ||
1246 | t->callback = task; | ||
1247 | t->callback_cls = task_cls; | ||
1248 | t->read_fd = -1; | ||
1249 | t->write_fd = -1; | ||
1250 | #if PROFILE_DELAYS | ||
1251 | t->start_time = GNUNET_TIME_absolute_get (); | ||
1252 | #endif | ||
1253 | t->timeout = GNUNET_TIME_UNIT_FOREVER_ABS; | ||
1254 | t->priority = GNUNET_SCHEDULER_PRIORITY_SHUTDOWN; | ||
1255 | t->on_shutdown = GNUNET_YES; | ||
1256 | t->lifeness = GNUNET_YES; | ||
1257 | GNUNET_CONTAINER_DLL_insert (shutdown_head, | ||
1258 | shutdown_tail, | ||
1259 | t); | ||
1260 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1261 | "Adding task: %p\n", | ||
1262 | t); | ||
1263 | init_backtrace (t); | ||
1264 | return t; | ||
1206 | } | 1265 | } |
1207 | 1266 | ||
1208 | 1267 | ||
@@ -1246,12 +1305,10 @@ GNUNET_SCHEDULER_add_now_with_lifeness (int lifeness, | |||
1246 | * (prerequisite-run) | 1305 | * (prerequisite-run) |
1247 | * && (delay-ready | 1306 | * && (delay-ready |
1248 | * || any-rs-ready | 1307 | * || any-rs-ready |
1249 | * || any-ws-ready | 1308 | * || any-ws-ready) |
1250 | * || shutdown-active ) | ||
1251 | * </code> | 1309 | * </code> |
1252 | * | 1310 | * |
1253 | * @param delay how long should we wait? Use #GNUNET_TIME_UNIT_FOREVER_REL for "forever", | 1311 | * @param delay how long should we wait? |
1254 | * which means that the task will only be run after we receive SIGTERM | ||
1255 | * @param priority priority to use | 1312 | * @param priority priority to use |
1256 | * @param rfd file descriptor we want to read (can be -1) | 1313 | * @param rfd file descriptor we want to read (can be -1) |
1257 | * @param wfd file descriptors we want to write (can be -1) | 1314 | * @param wfd file descriptors we want to write (can be -1) |
@@ -1271,20 +1328,11 @@ add_without_sets (struct GNUNET_TIME_Relative delay, | |||
1271 | { | 1328 | { |
1272 | struct GNUNET_SCHEDULER_Task *t; | 1329 | struct GNUNET_SCHEDULER_Task *t; |
1273 | 1330 | ||
1274 | #if EXECINFO | ||
1275 | void *backtrace_array[MAX_TRACE_DEPTH]; | ||
1276 | #endif | ||
1277 | |||
1278 | GNUNET_assert (NULL != active_task); | 1331 | GNUNET_assert (NULL != active_task); |
1279 | GNUNET_assert (NULL != task); | 1332 | GNUNET_assert (NULL != task); |
1280 | t = GNUNET_new (struct GNUNET_SCHEDULER_Task); | 1333 | t = GNUNET_new (struct GNUNET_SCHEDULER_Task); |
1281 | t->callback = task; | 1334 | t->callback = task; |
1282 | t->callback_cls = task_cls; | 1335 | t->callback_cls = task_cls; |
1283 | #if EXECINFO | ||
1284 | t->num_backtrace_strings = backtrace (backtrace_array, MAX_TRACE_DEPTH); | ||
1285 | t->backtrace_strings = | ||
1286 | backtrace_symbols (backtrace_array, t->num_backtrace_strings); | ||
1287 | #endif | ||
1288 | #if DEBUG_FDS | 1336 | #if DEBUG_FDS |
1289 | if (-1 != rfd) | 1337 | if (-1 != rfd) |
1290 | { | 1338 | { |
@@ -1295,14 +1343,7 @@ add_without_sets (struct GNUNET_TIME_Relative delay, | |||
1295 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1343 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1296 | "Got invalid file descriptor %d!\n", | 1344 | "Got invalid file descriptor %d!\n", |
1297 | rfd); | 1345 | rfd); |
1298 | #if EXECINFO | 1346 | init_backtrace (t); |
1299 | unsigned int i; | ||
1300 | |||
1301 | for (i = 0; i < t->num_backtrace_strings; i++) | ||
1302 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
1303 | "Trace: %s\n", | ||
1304 | t->backtrace_strings[i]); | ||
1305 | #endif | ||
1306 | GNUNET_assert (0); | 1347 | GNUNET_assert (0); |
1307 | } | 1348 | } |
1308 | } | 1349 | } |
@@ -1315,14 +1356,7 @@ add_without_sets (struct GNUNET_TIME_Relative delay, | |||
1315 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1356 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1316 | "Got invalid file descriptor %d!\n", | 1357 | "Got invalid file descriptor %d!\n", |
1317 | wfd); | 1358 | wfd); |
1318 | #if EXECINFO | 1359 | init_backtrace (t); |
1319 | unsigned int i; | ||
1320 | |||
1321 | for (i = 0; i < t->num_backtrace_strings; i++) | ||
1322 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1323 | "Trace: %s\n", | ||
1324 | t->backtrace_strings[i]); | ||
1325 | #endif | ||
1326 | GNUNET_assert (0); | 1360 | GNUNET_assert (0); |
1327 | } | 1361 | } |
1328 | } | 1362 | } |
@@ -1344,16 +1378,7 @@ add_without_sets (struct GNUNET_TIME_Relative delay, | |||
1344 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1378 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1345 | "Adding task %p\n", | 1379 | "Adding task %p\n", |
1346 | t); | 1380 | t); |
1347 | #if EXECINFO | 1381 | init_backtrace (t); |
1348 | unsigned int i; | ||
1349 | |||
1350 | for (i = 0; i < t->num_backtrace_strings; i++) | ||
1351 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1352 | "Task %p trace %d: %s\n", | ||
1353 | t, | ||
1354 | i, | ||
1355 | t->backtrace_strings[i]); | ||
1356 | #endif | ||
1357 | return t; | 1382 | return t; |
1358 | } | 1383 | } |
1359 | #endif | 1384 | #endif |
@@ -1366,8 +1391,7 @@ add_without_sets (struct GNUNET_TIME_Relative delay, | |||
1366 | * scheduled for execution once either the delay has expired or the | 1391 | * scheduled for execution once either the delay has expired or the |
1367 | * socket operation is ready. It will be run with the DEFAULT priority. | 1392 | * socket operation is ready. It will be run with the DEFAULT priority. |
1368 | * | 1393 | * |
1369 | * @param delay when should this operation time out? Use | 1394 | * @param delay when should this operation time out? |
1370 | * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
1371 | * @param rfd read file-descriptor | 1395 | * @param rfd read file-descriptor |
1372 | * @param task main function of the task | 1396 | * @param task main function of the task |
1373 | * @param task_cls closure of @a task | 1397 | * @param task_cls closure of @a task |
@@ -1394,8 +1418,7 @@ GNUNET_SCHEDULER_add_read_net (struct GNUNET_TIME_Relative delay, | |||
1394 | * either the delay has expired or the socket operation is ready. It | 1418 | * either the delay has expired or the socket operation is ready. It |
1395 | * will be run with the DEFAULT priority. | 1419 | * will be run with the DEFAULT priority. |
1396 | * | 1420 | * |
1397 | * @param delay when should this operation time out? Use | 1421 | * @param delay when should this operation time out? |
1398 | * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
1399 | * @param priority priority to use for the task | 1422 | * @param priority priority to use for the task |
1400 | * @param rfd read file-descriptor | 1423 | * @param rfd read file-descriptor |
1401 | * @param task main function of the task | 1424 | * @param task main function of the task |
@@ -1426,8 +1449,7 @@ GNUNET_SCHEDULER_add_read_net_with_priority (struct GNUNET_TIME_Relative delay, | |||
1426 | * socket operation is ready. It will be run with the priority of | 1449 | * socket operation is ready. It will be run with the priority of |
1427 | * the calling task. | 1450 | * the calling task. |
1428 | * | 1451 | * |
1429 | * @param delay when should this operation time out? Use | 1452 | * @param delay when should this operation time out? |
1430 | * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
1431 | * @param wfd write file-descriptor | 1453 | * @param wfd write file-descriptor |
1432 | * @param task main function of the task | 1454 | * @param task main function of the task |
1433 | * @param task_cls closure of @a task | 1455 | * @param task_cls closure of @a task |
@@ -1454,8 +1476,7 @@ GNUNET_SCHEDULER_add_write_net (struct GNUNET_TIME_Relative delay, | |||
1454 | * scheduled for execution once either the delay has expired or the | 1476 | * scheduled for execution once either the delay has expired or the |
1455 | * socket operation is ready. | 1477 | * socket operation is ready. |
1456 | * | 1478 | * |
1457 | * @param delay when should this operation time out? Use | 1479 | * @param delay when should this operation time out? |
1458 | * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
1459 | * @param priority priority of the task | 1480 | * @param priority priority of the task |
1460 | * @param fd file-descriptor | 1481 | * @param fd file-descriptor |
1461 | * @param on_read whether to poll the file-descriptor for readability | 1482 | * @param on_read whether to poll the file-descriptor for readability |
@@ -1505,8 +1526,7 @@ GNUNET_SCHEDULER_add_net_with_priority (struct GNUNET_TIME_Relative delay, | |||
1505 | * scheduled for execution once either the delay has expired or the | 1526 | * scheduled for execution once either the delay has expired or the |
1506 | * socket operation is ready. It will be run with the DEFAULT priority. | 1527 | * socket operation is ready. It will be run with the DEFAULT priority. |
1507 | * | 1528 | * |
1508 | * @param delay when should this operation time out? Use | 1529 | * @param delay when should this operation time out? |
1509 | * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
1510 | * @param rfd read file-descriptor | 1530 | * @param rfd read file-descriptor |
1511 | * @param task main function of the task | 1531 | * @param task main function of the task |
1512 | * @param task_cls closure of @a task | 1532 | * @param task_cls closure of @a task |
@@ -1532,8 +1552,7 @@ GNUNET_SCHEDULER_add_read_file (struct GNUNET_TIME_Relative delay, | |||
1532 | * scheduled for execution once either the delay has expired or the | 1552 | * scheduled for execution once either the delay has expired or the |
1533 | * socket operation is ready. It will be run with the DEFAULT priority. | 1553 | * socket operation is ready. It will be run with the DEFAULT priority. |
1534 | * | 1554 | * |
1535 | * @param delay when should this operation time out? Use | 1555 | * @param delay when should this operation time out? |
1536 | * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
1537 | * @param wfd write file-descriptor | 1556 | * @param wfd write file-descriptor |
1538 | * @param task main function of the task | 1557 | * @param task main function of the task |
1539 | * @param task_cls closure of @a task | 1558 | * @param task_cls closure of @a task |
@@ -1559,8 +1578,7 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay, | |||
1559 | * scheduled for execution once either the delay has expired or the | 1578 | * scheduled for execution once either the delay has expired or the |
1560 | * socket operation is ready. | 1579 | * socket operation is ready. |
1561 | * | 1580 | * |
1562 | * @param delay when should this operation time out? Use | 1581 | * @param delay when should this operation time out? |
1563 | * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
1564 | * @param priority priority of the task | 1582 | * @param priority priority of the task |
1565 | * @param fd file-descriptor | 1583 | * @param fd file-descriptor |
1566 | * @param on_read whether to poll the file-descriptor for readability | 1584 | * @param on_read whether to poll the file-descriptor for readability |
@@ -1618,13 +1636,11 @@ GNUNET_SCHEDULER_add_file_with_priority (struct GNUNET_TIME_Relative delay, | |||
1618 | * (prerequisite-run) | 1636 | * (prerequisite-run) |
1619 | * && (delay-ready | 1637 | * && (delay-ready |
1620 | * || any-rs-ready | 1638 | * || any-rs-ready |
1621 | * || any-ws-ready | 1639 | * || any-ws-ready) ) |
1622 | * || (shutdown-active && run-on-shutdown) ) | ||
1623 | * </code> | 1640 | * </code> |
1624 | * | 1641 | * |
1625 | * @param prio how important is this task? | 1642 | * @param prio how important is this task? |
1626 | * @param delay how long should we wait? Use #GNUNET_TIME_UNIT_FOREVER_REL for "forever", | 1643 | * @param delay how long should we wait? |
1627 | * which means that the task will only be run after we receive SIGTERM | ||
1628 | * @param rs set of file descriptors we want to read (can be NULL) | 1644 | * @param rs set of file descriptors we want to read (can be NULL) |
1629 | * @param ws set of file descriptors we want to write (can be NULL) | 1645 | * @param ws set of file descriptors we want to write (can be NULL) |
1630 | * @param task main function of the task | 1646 | * @param task main function of the task |
@@ -1641,9 +1657,6 @@ GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, | |||
1641 | void *task_cls) | 1657 | void *task_cls) |
1642 | { | 1658 | { |
1643 | struct GNUNET_SCHEDULER_Task *t; | 1659 | struct GNUNET_SCHEDULER_Task *t; |
1644 | #if EXECINFO | ||
1645 | void *backtrace_array[MAX_TRACE_DEPTH]; | ||
1646 | #endif | ||
1647 | 1660 | ||
1648 | if ( (NULL == rs) && | 1661 | if ( (NULL == rs) && |
1649 | (NULL == ws) ) | 1662 | (NULL == ws) ) |
@@ -1656,11 +1669,6 @@ GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, | |||
1656 | t = GNUNET_new (struct GNUNET_SCHEDULER_Task); | 1669 | t = GNUNET_new (struct GNUNET_SCHEDULER_Task); |
1657 | t->callback = task; | 1670 | t->callback = task; |
1658 | t->callback_cls = task_cls; | 1671 | t->callback_cls = task_cls; |
1659 | #if EXECINFO | ||
1660 | t->num_backtrace_strings = backtrace (backtrace_array, MAX_TRACE_DEPTH); | ||
1661 | t->backtrace_strings = | ||
1662 | backtrace_symbols (backtrace_array, t->num_backtrace_strings); | ||
1663 | #endif | ||
1664 | t->read_fd = -1; | 1672 | t->read_fd = -1; |
1665 | t->write_fd = -1; | 1673 | t->write_fd = -1; |
1666 | if (NULL != rs) | 1674 | if (NULL != rs) |
@@ -1689,16 +1697,7 @@ GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, | |||
1689 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1697 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1690 | "Adding task %p\n", | 1698 | "Adding task %p\n", |
1691 | t); | 1699 | t); |
1692 | #if EXECINFO | 1700 | init_backtrace (t); |
1693 | int i; | ||
1694 | |||
1695 | for (i = 0; i < t->num_backtrace_strings; i++) | ||
1696 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1697 | "Task p trace %d: %s\n", | ||
1698 | t, | ||
1699 | i, | ||
1700 | t->backtrace_strings[i]); | ||
1701 | #endif | ||
1702 | return t; | 1701 | return t; |
1703 | } | 1702 | } |
1704 | 1703 | ||
diff --git a/src/util/server.c b/src/util/server.c index 8dedd28fd..00e37c9d9 100644 --- a/src/util/server.c +++ b/src/util/server.c | |||
@@ -400,12 +400,6 @@ process_listen_socket (void *cls) | |||
400 | 400 | ||
401 | server->listen_task = NULL; | 401 | server->listen_task = NULL; |
402 | tc = GNUNET_SCHEDULER_get_task_context (); | 402 | tc = GNUNET_SCHEDULER_get_task_context (); |
403 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
404 | { | ||
405 | /* ignore shutdown, someone else will take care of it! */ | ||
406 | GNUNET_SERVER_resume (server); | ||
407 | return; | ||
408 | } | ||
409 | for (i = 0; NULL != server->listen_sockets[i]; i++) | 403 | for (i = 0; NULL != server->listen_sockets[i]; i++) |
410 | { | 404 | { |
411 | if (GNUNET_NETWORK_fdset_isset (tc->read_ready, | 405 | if (GNUNET_NETWORK_fdset_isset (tc->read_ready, |
@@ -437,7 +431,8 @@ process_listen_socket (void *cls) | |||
437 | * @return NULL on error, otherwise the listen socket | 431 | * @return NULL on error, otherwise the listen socket |
438 | */ | 432 | */ |
439 | static struct GNUNET_NETWORK_Handle * | 433 | static struct GNUNET_NETWORK_Handle * |
440 | open_listen_socket (const struct sockaddr *server_addr, socklen_t socklen) | 434 | open_listen_socket (const struct sockaddr *server_addr, |
435 | socklen_t socklen) | ||
441 | { | 436 | { |
442 | struct GNUNET_NETWORK_Handle *sock; | 437 | struct GNUNET_NETWORK_Handle *sock; |
443 | uint16_t port; | 438 | uint16_t port; |
@@ -683,7 +678,7 @@ test_monitor_clients (struct GNUNET_SERVER_Handle *server) | |||
683 | if (GNUNET_NO == client->is_monitor) | 678 | if (GNUNET_NO == client->is_monitor) |
684 | return; /* not done yet */ | 679 | return; /* not done yet */ |
685 | server->in_soft_shutdown = GNUNET_SYSERR; | 680 | server->in_soft_shutdown = GNUNET_SYSERR; |
686 | GNUNET_SCHEDULER_add_now (&do_destroy, server); | 681 | (void) GNUNET_SCHEDULER_add_now (&do_destroy, server); |
687 | } | 682 | } |
688 | 683 | ||
689 | 684 | ||
@@ -720,8 +715,8 @@ GNUNET_SERVER_resume (struct GNUNET_SERVER_Handle *server) | |||
720 | return; /* nothing to do, no listen sockets! */ | 715 | return; /* nothing to do, no listen sockets! */ |
721 | if (NULL == server->listen_sockets[1]) | 716 | if (NULL == server->listen_sockets[1]) |
722 | { | 717 | { |
723 | /* simplified method: no fd set needed; this is then much simpler and | 718 | /* simplified method: no fd set needed; this is then much simpler |
724 | much more efficient */ | 719 | and much more efficient */ |
725 | server->listen_task = | 720 | server->listen_task = |
726 | GNUNET_SCHEDULER_add_read_net_with_priority (GNUNET_TIME_UNIT_FOREVER_REL, | 721 | GNUNET_SCHEDULER_add_read_net_with_priority (GNUNET_TIME_UNIT_FOREVER_REL, |
727 | GNUNET_SCHEDULER_PRIORITY_HIGH, | 722 | GNUNET_SCHEDULER_PRIORITY_HIGH, |
@@ -890,18 +885,16 @@ static void | |||
890 | warn_no_receive_done (void *cls) | 885 | warn_no_receive_done (void *cls) |
891 | { | 886 | { |
892 | struct GNUNET_SERVER_Client *client = cls; | 887 | struct GNUNET_SERVER_Client *client = cls; |
893 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
894 | 888 | ||
895 | GNUNET_break (0 != client->warn_type); /* type should never be 0 here, as we don't use 0 */ | 889 | GNUNET_break (0 != client->warn_type); /* type should never be 0 here, as we don't use 0 */ |
896 | client->warn_task = | 890 | client->warn_task = |
897 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, | 891 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, |
898 | &warn_no_receive_done, client); | 892 | &warn_no_receive_done, client); |
899 | tc = GNUNET_SCHEDULER_get_task_context (); | 893 | LOG (GNUNET_ERROR_TYPE_WARNING, |
900 | if (0 == (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | 894 | _("Processing code for message of type %u did not call `GNUNET_SERVER_receive_done' after %s\n"), |
901 | LOG (GNUNET_ERROR_TYPE_WARNING, | 895 | (unsigned int) client->warn_type, |
902 | _("Processing code for message of type %u did not call `GNUNET_SERVER_receive_done' after %s\n"), | 896 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (client->warn_start), |
903 | (unsigned int) client->warn_type, | 897 | GNUNET_YES)); |
904 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (client->warn_start), GNUNET_YES)); | ||
905 | } | 898 | } |
906 | 899 | ||
907 | 900 | ||
@@ -987,7 +980,8 @@ GNUNET_SERVER_inject (struct GNUNET_SERVER_Handle *server, | |||
987 | sender->warn_start = GNUNET_TIME_absolute_get (); | 980 | sender->warn_start = GNUNET_TIME_absolute_get (); |
988 | sender->warn_task = | 981 | sender->warn_task = |
989 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, | 982 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, |
990 | &warn_no_receive_done, sender); | 983 | &warn_no_receive_done, |
984 | sender); | ||
991 | sender->warn_type = type; | 985 | sender->warn_type = type; |
992 | } | 986 | } |
993 | sender->suspended++; | 987 | sender->suspended++; |
diff --git a/src/util/service.c b/src/util/service.c index 93a51f220..bdef17361 100644 --- a/src/util/service.c +++ b/src/util/service.c | |||
@@ -187,7 +187,7 @@ struct GNUNET_SERVICE_Context | |||
187 | /** | 187 | /** |
188 | * Task ID of the shutdown task. | 188 | * Task ID of the shutdown task. |
189 | */ | 189 | */ |
190 | struct GNUNET_SCHEDULER_Task * shutdown_task; | 190 | struct GNUNET_SCHEDULER_Task *shutdown_task; |
191 | 191 | ||
192 | /** | 192 | /** |
193 | * Idle timeout for server. | 193 | * Idle timeout for server. |
@@ -1151,11 +1151,7 @@ service_task (void *cls) | |||
1151 | { | 1151 | { |
1152 | struct GNUNET_SERVICE_Context *sctx = cls; | 1152 | struct GNUNET_SERVICE_Context *sctx = cls; |
1153 | unsigned int i; | 1153 | unsigned int i; |
1154 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
1155 | 1154 | ||
1156 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
1157 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | ||
1158 | return; | ||
1159 | (void) GNUNET_SPEEDUP_start_ (sctx->cfg); | 1155 | (void) GNUNET_SPEEDUP_start_ (sctx->cfg); |
1160 | GNUNET_RESOLVER_connect (sctx->cfg); | 1156 | GNUNET_RESOLVER_connect (sctx->cfg); |
1161 | if (NULL != sctx->lsocks) | 1157 | if (NULL != sctx->lsocks) |
@@ -1191,9 +1187,8 @@ service_task (void *cls) | |||
1191 | { | 1187 | { |
1192 | /* install a task that will kill the server | 1188 | /* install a task that will kill the server |
1193 | * process if the scheduler ever gets a shutdown signal */ | 1189 | * process if the scheduler ever gets a shutdown signal */ |
1194 | sctx->shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1190 | sctx->shutdown_task = GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
1195 | &shutdown_task, | 1191 | sctx); |
1196 | sctx); | ||
1197 | } | 1192 | } |
1198 | sctx->my_handlers = GNUNET_malloc (sizeof (defhandlers)); | 1193 | sctx->my_handlers = GNUNET_malloc (sizeof (defhandlers)); |
1199 | memcpy (sctx->my_handlers, defhandlers, sizeof (defhandlers)); | 1194 | memcpy (sctx->my_handlers, defhandlers, sizeof (defhandlers)); |
diff --git a/src/util/socks.c b/src/util/socks.c index cc59858dd..bda8765ad 100644 --- a/src/util/socks.c +++ b/src/util/socks.c | |||
@@ -328,7 +328,6 @@ register_reciever (struct GNUNET_SOCKS_Handshake *ih, int want) | |||
328 | * @param buf where the callee should write the message | 328 | * @param buf where the callee should write the message |
329 | * @return number of bytes written to @a buf | 329 | * @return number of bytes written to @a buf |
330 | */ | 330 | */ |
331 | |||
332 | size_t | 331 | size_t |
333 | transmit_ready (void *cls, | 332 | transmit_ready (void *cls, |
334 | size_t size, | 333 | size_t size, |
@@ -353,29 +352,19 @@ transmit_ready (void *cls, | |||
353 | * successful operations, including DNS resolution, do not use this. */ | 352 | * successful operations, including DNS resolution, do not use this. */ |
354 | if (NULL == buf) | 353 | if (NULL == buf) |
355 | { | 354 | { |
356 | const struct GNUNET_SCHEDULER_TaskContext *tc; | 355 | if (0 == ih->step) |
357 | 356 | { | |
358 | tc = GNUNET_SCHEDULER_get_task_context (); | 357 | LOG (GNUNET_ERROR_TYPE_WARNING, |
359 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 358 | "Timeout contacting SOCKS server, retrying indefinitely, but probably hopeless.\n"); |
360 | return 0; | 359 | register_sender (ih); |
361 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) { | 360 | } |
362 | if (0==ih->step) | 361 | else |
363 | { | 362 | { |
364 | LOG (GNUNET_ERROR_TYPE_WARNING, | 363 | LOG (GNUNET_ERROR_TYPE_ERROR, |
365 | "Timeout contacting SOCKS server, retrying indefinitely, but probably hopeless.\n"); | 364 | "Timeout during mid SOCKS handshake (step %u), probably not a SOCKS server.\n", |
366 | register_sender (ih); | 365 | ih->step); |
367 | } | 366 | GNUNET_break (0); |
368 | else | ||
369 | { | ||
370 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
371 | "Timeout during mid SOCKS handshake (step %u), probably not a SOCKS server.\n", | ||
372 | ih->step); | ||
373 | GNUNET_break (0); | ||
374 | } | ||
375 | return 0; | ||
376 | } | 367 | } |
377 | /* if (reason == 48) register_sender (ih); */ | ||
378 | /* GNUNET_break(0); */ | ||
379 | return 0; | 368 | return 0; |
380 | } | 369 | } |
381 | 370 | ||
diff --git a/src/util/speedup.c b/src/util/speedup.c index 6dce6a490..97df65c8e 100644 --- a/src/util/speedup.c +++ b/src/util/speedup.c | |||
@@ -41,18 +41,16 @@ static void | |||
41 | do_speedup (void *cls) | 41 | do_speedup (void *cls) |
42 | { | 42 | { |
43 | static long long current_offset; | 43 | static long long current_offset; |
44 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
45 | 44 | ||
46 | speedup_task = NULL; | 45 | speedup_task = NULL; |
47 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
48 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | ||
49 | return; | ||
50 | current_offset += delta.rel_value_us; | 46 | current_offset += delta.rel_value_us; |
51 | GNUNET_TIME_set_offset (current_offset); | 47 | GNUNET_TIME_set_offset (current_offset); |
52 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 48 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
53 | "Speeding up execution time by %s\n", | 49 | "Speeding up execution time by %s\n", |
54 | GNUNET_STRINGS_relative_time_to_string (delta, GNUNET_NO)); | 50 | GNUNET_STRINGS_relative_time_to_string (delta, GNUNET_NO)); |
55 | speedup_task = GNUNET_SCHEDULER_add_delayed (interval, &do_speedup, NULL); | 51 | speedup_task = GNUNET_SCHEDULER_add_delayed (interval, |
52 | &do_speedup, | ||
53 | NULL); | ||
56 | } | 54 | } |
57 | 55 | ||
58 | 56 | ||
@@ -65,16 +63,22 @@ do_speedup (void *cls) | |||
65 | int | 63 | int |
66 | GNUNET_SPEEDUP_start_ (const struct GNUNET_CONFIGURATION_Handle *cfg) | 64 | GNUNET_SPEEDUP_start_ (const struct GNUNET_CONFIGURATION_Handle *cfg) |
67 | { | 65 | { |
66 | GNUNET_assert (NULL == speedup_task); | ||
68 | if (GNUNET_OK != | 67 | if (GNUNET_OK != |
69 | GNUNET_CONFIGURATION_get_value_time (cfg, "testing", | 68 | GNUNET_CONFIGURATION_get_value_time (cfg, |
70 | "SPEEDUP_INTERVAL", &interval)) | 69 | "testing", |
70 | "SPEEDUP_INTERVAL", | ||
71 | &interval)) | ||
71 | return GNUNET_SYSERR; | 72 | return GNUNET_SYSERR; |
72 | if (GNUNET_OK != | 73 | if (GNUNET_OK != |
73 | GNUNET_CONFIGURATION_get_value_time (cfg, "testing", | 74 | GNUNET_CONFIGURATION_get_value_time (cfg, |
74 | "SPEEDUP_DELTA", &delta)) | 75 | "testing", |
76 | "SPEEDUP_DELTA", | ||
77 | &delta)) | ||
75 | return GNUNET_SYSERR; | 78 | return GNUNET_SYSERR; |
76 | 79 | ||
77 | if ((0 == interval.rel_value_us) || (0 == delta.rel_value_us)) | 80 | if ( (0 == interval.rel_value_us) || |
81 | (0 == delta.rel_value_us) ) | ||
78 | { | 82 | { |
79 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 83 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
80 | "Speed up disabled\n"); | 84 | "Speed up disabled\n"); |
@@ -87,7 +91,8 @@ GNUNET_SPEEDUP_start_ (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
87 | "Speed up executed every %s\n", | 91 | "Speed up executed every %s\n", |
88 | GNUNET_STRINGS_relative_time_to_string (interval, GNUNET_NO)); | 92 | GNUNET_STRINGS_relative_time_to_string (interval, GNUNET_NO)); |
89 | speedup_task = GNUNET_SCHEDULER_add_now_with_lifeness (GNUNET_NO, | 93 | speedup_task = GNUNET_SCHEDULER_add_now_with_lifeness (GNUNET_NO, |
90 | &do_speedup, NULL); | 94 | &do_speedup, |
95 | NULL); | ||
91 | return GNUNET_OK; | 96 | return GNUNET_OK; |
92 | } | 97 | } |
93 | 98 | ||
@@ -109,6 +114,4 @@ GNUNET_SPEEDUP_stop_ () | |||
109 | "Stopped execution speed up\n"); | 114 | "Stopped execution speed up\n"); |
110 | } | 115 | } |
111 | 116 | ||
112 | |||
113 | |||
114 | /* end of speedup.c */ | 117 | /* end of speedup.c */ |
diff --git a/src/util/test_common_logging_runtime_loglevels.c b/src/util/test_common_logging_runtime_loglevels.c index 21eb3c6c6..033b16ce1 100644 --- a/src/util/test_common_logging_runtime_loglevels.c +++ b/src/util/test_common_logging_runtime_loglevels.c | |||
@@ -234,7 +234,8 @@ read_call (void *cls) | |||
234 | FPRINTF (stderr, "got %d bytes, reading more\n", rd); | 234 | FPRINTF (stderr, "got %d bytes, reading more\n", rd); |
235 | #endif | 235 | #endif |
236 | read_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | 236 | read_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
237 | stdout_read_handle, &read_call, | 237 | stdout_read_handle, |
238 | &read_call, | ||
238 | (void*) stdout_read_handle); | 239 | (void*) stdout_read_handle); |
239 | return; | 240 | return; |
240 | } | 241 | } |
@@ -411,7 +412,8 @@ runone () | |||
411 | 412 | ||
412 | die_task = | 413 | die_task = |
413 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 414 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
414 | (GNUNET_TIME_UNIT_SECONDS, 10), &end_task, | 415 | (GNUNET_TIME_UNIT_SECONDS, 10), |
416 | &end_task, | ||
415 | NULL); | 417 | NULL); |
416 | 418 | ||
417 | bytes = 0; | 419 | bytes = 0; |
@@ -419,7 +421,8 @@ runone () | |||
419 | memset (&buf, 0, sizeof (buf)); | 421 | memset (&buf, 0, sizeof (buf)); |
420 | 422 | ||
421 | read_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | 423 | read_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
422 | stdout_read_handle, &read_call, | 424 | stdout_read_handle, |
425 | &read_call, | ||
423 | (void*) stdout_read_handle); | 426 | (void*) stdout_read_handle); |
424 | } | 427 | } |
425 | 428 | ||
diff --git a/src/util/test_connection_receive_cancel.c b/src/util/test_connection_receive_cancel.c index 9ec96d8a6..9c0ab699e 100644 --- a/src/util/test_connection_receive_cancel.c +++ b/src/util/test_connection_receive_cancel.c | |||
@@ -60,7 +60,8 @@ open_listen_socket () | |||
60 | GNUNET_assert (desc != NULL); | 60 | GNUNET_assert (desc != NULL); |
61 | if (GNUNET_NETWORK_socket_setsockopt | 61 | if (GNUNET_NETWORK_socket_setsockopt |
62 | (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) | 62 | (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) |
63 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt"); | 63 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
64 | "setsockopt"); | ||
64 | GNUNET_assert (GNUNET_OK == | 65 | GNUNET_assert (GNUNET_OK == |
65 | GNUNET_NETWORK_socket_bind (desc, (const struct sockaddr *) &sa, | 66 | GNUNET_NETWORK_socket_bind (desc, (const struct sockaddr *) &sa, |
66 | sizeof (sa))); | 67 | sizeof (sa))); |
@@ -69,10 +70,13 @@ open_listen_socket () | |||
69 | } | 70 | } |
70 | 71 | ||
71 | 72 | ||
72 | |||
73 | static void | 73 | static void |
74 | dead_receive (void *cls, const void *buf, size_t available, | 74 | dead_receive (void *cls, |
75 | const struct sockaddr *addr, socklen_t addrlen, int errCode) | 75 | const void *buf, |
76 | size_t available, | ||
77 | const struct sockaddr *addr, | ||
78 | socklen_t addrlen, | ||
79 | int errCode) | ||
76 | { | 80 | { |
77 | GNUNET_assert (0); | 81 | GNUNET_assert (0); |
78 | } | 82 | } |
@@ -87,7 +91,8 @@ run_accept_cancel (void *cls) | |||
87 | GNUNET_CONNECTION_destroy (lsock); | 91 | GNUNET_CONNECTION_destroy (lsock); |
88 | GNUNET_CONNECTION_receive (asock, 1024, | 92 | GNUNET_CONNECTION_receive (asock, 1024, |
89 | GNUNET_TIME_relative_multiply | 93 | GNUNET_TIME_relative_multiply |
90 | (GNUNET_TIME_UNIT_SECONDS, 5), &dead_receive, cls); | 94 | (GNUNET_TIME_UNIT_SECONDS, 5), |
95 | &dead_receive, cls); | ||
91 | } | 96 | } |
92 | 97 | ||
93 | 98 | ||
@@ -103,7 +108,6 @@ receive_cancel_task (void *cls) | |||
103 | } | 108 | } |
104 | 109 | ||
105 | 110 | ||
106 | |||
107 | static void | 111 | static void |
108 | task_receive_cancel (void *cls) | 112 | task_receive_cancel (void *cls) |
109 | { | 113 | { |
@@ -112,14 +116,16 @@ task_receive_cancel (void *cls) | |||
112 | GNUNET_assert (lsock != NULL); | 116 | GNUNET_assert (lsock != NULL); |
113 | csock = GNUNET_CONNECTION_create_from_connect (cfg, "localhost", PORT); | 117 | csock = GNUNET_CONNECTION_create_from_connect (cfg, "localhost", PORT); |
114 | GNUNET_assert (csock != NULL); | 118 | GNUNET_assert (csock != NULL); |
115 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, ls, | 119 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
116 | &run_accept_cancel, cls); | 120 | ls, |
117 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &receive_cancel_task, | 121 | &run_accept_cancel, |
122 | cls); | ||
123 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | ||
124 | &receive_cancel_task, | ||
118 | cls); | 125 | cls); |
119 | } | 126 | } |
120 | 127 | ||
121 | 128 | ||
122 | |||
123 | /** | 129 | /** |
124 | * Main method, starts scheduler with task_timeout. | 130 | * Main method, starts scheduler with task_timeout. |
125 | */ | 131 | */ |
@@ -130,7 +136,9 @@ check_receive_cancel () | |||
130 | 136 | ||
131 | ok = 1; | 137 | ok = 1; |
132 | cfg = GNUNET_CONFIGURATION_create (); | 138 | cfg = GNUNET_CONFIGURATION_create (); |
133 | GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", | 139 | GNUNET_CONFIGURATION_set_value_string (cfg, |
140 | "resolver", | ||
141 | "HOSTNAME", | ||
134 | "localhost"); | 142 | "localhost"); |
135 | GNUNET_SCHEDULER_run (&task_receive_cancel, &ok); | 143 | GNUNET_SCHEDULER_run (&task_receive_cancel, &ok); |
136 | GNUNET_CONFIGURATION_destroy (cfg); | 144 | GNUNET_CONFIGURATION_destroy (cfg); |
diff --git a/src/util/test_disk.c b/src/util/test_disk.c index 055e155e9..7b9a6d45c 100644 --- a/src/util/test_disk.c +++ b/src/util/test_disk.c | |||
@@ -28,6 +28,7 @@ | |||
28 | 28 | ||
29 | #define TESTSTRING "Hello World\0" | 29 | #define TESTSTRING "Hello World\0" |
30 | 30 | ||
31 | |||
31 | static int | 32 | static int |
32 | testReadWrite () | 33 | testReadWrite () |
33 | { | 34 | { |
@@ -79,6 +80,7 @@ testReadWrite () | |||
79 | return 0; | 80 | return 0; |
80 | } | 81 | } |
81 | 82 | ||
83 | |||
82 | static int | 84 | static int |
83 | testOpenClose () | 85 | testOpenClose () |
84 | { | 86 | { |
@@ -104,6 +106,7 @@ testOpenClose () | |||
104 | 106 | ||
105 | static int ok; | 107 | static int ok; |
106 | 108 | ||
109 | |||
107 | static int | 110 | static int |
108 | scan_callback (void *want, const char *filename) | 111 | scan_callback (void *want, const char *filename) |
109 | { | 112 | { |
@@ -112,41 +115,83 @@ scan_callback (void *want, const char *filename) | |||
112 | return GNUNET_OK; | 115 | return GNUNET_OK; |
113 | } | 116 | } |
114 | 117 | ||
118 | |||
115 | static int | 119 | static int |
116 | testDirScan () | 120 | testDirScan () |
117 | { | 121 | { |
118 | if (GNUNET_OK != | 122 | if (GNUNET_OK != |
119 | GNUNET_DISK_directory_create ("test" DIR_SEPARATOR_STR "entry")) | 123 | GNUNET_DISK_directory_create ("test" DIR_SEPARATOR_STR "entry")) |
124 | { | ||
125 | GNUNET_break (0); | ||
120 | return 1; | 126 | return 1; |
127 | } | ||
121 | if (GNUNET_OK != | 128 | if (GNUNET_OK != |
122 | GNUNET_DISK_directory_create ("test" DIR_SEPARATOR_STR "entry_more")) | 129 | GNUNET_DISK_directory_create ("test" DIR_SEPARATOR_STR "entry_more")) |
130 | { | ||
131 | GNUNET_break (0); | ||
123 | return 1; | 132 | return 1; |
133 | } | ||
124 | GNUNET_DISK_directory_scan ("test", &scan_callback, | 134 | GNUNET_DISK_directory_scan ("test", &scan_callback, |
125 | "test" DIR_SEPARATOR_STR "entry"); | 135 | "test" DIR_SEPARATOR_STR "entry"); |
126 | if (GNUNET_OK != GNUNET_DISK_directory_remove ("test")) | 136 | if (GNUNET_OK != GNUNET_DISK_directory_remove ("test")) |
137 | { | ||
138 | GNUNET_break (0); | ||
127 | return 1; | 139 | return 1; |
140 | } | ||
128 | if (ok < 2) | 141 | if (ok < 2) |
142 | { | ||
143 | GNUNET_break (0); | ||
129 | return 1; | 144 | return 1; |
145 | } | ||
130 | return 0; | 146 | return 0; |
131 | } | 147 | } |
132 | 148 | ||
133 | 149 | ||
134 | static int | 150 | static int |
151 | iter_callback (void *cls, | ||
152 | const char *filename) | ||
153 | { | ||
154 | int *i = cls; | ||
155 | |||
156 | (*i)++; | ||
157 | return GNUNET_OK; | ||
158 | } | ||
159 | |||
160 | |||
161 | static int | ||
135 | testDirIter () | 162 | testDirIter () |
136 | { | 163 | { |
137 | int i; | 164 | int i; |
138 | 165 | ||
139 | i = 0; | 166 | i = 0; |
140 | if (GNUNET_OK != GNUNET_DISK_directory_create ("test/entry")) | 167 | if (GNUNET_OK != GNUNET_DISK_directory_create ("test/entry")) |
168 | { | ||
169 | GNUNET_break (0); | ||
141 | return 1; | 170 | return 1; |
171 | } | ||
142 | if (GNUNET_OK != GNUNET_DISK_directory_create ("test/entry_many")) | 172 | if (GNUNET_OK != GNUNET_DISK_directory_create ("test/entry_many")) |
173 | { | ||
174 | GNUNET_break (0); | ||
143 | return 1; | 175 | return 1; |
176 | } | ||
144 | if (GNUNET_OK != GNUNET_DISK_directory_create ("test/entry_more")) | 177 | if (GNUNET_OK != GNUNET_DISK_directory_create ("test/entry_more")) |
178 | { | ||
179 | GNUNET_break (0); | ||
145 | return 1; | 180 | return 1; |
181 | } | ||
182 | GNUNET_DISK_directory_scan ("test", | ||
183 | &iter_callback, | ||
184 | &i); | ||
146 | if (GNUNET_OK != GNUNET_DISK_directory_remove ("test")) | 185 | if (GNUNET_OK != GNUNET_DISK_directory_remove ("test")) |
186 | { | ||
187 | GNUNET_break (0); | ||
147 | return 1; | 188 | return 1; |
189 | } | ||
148 | if (i < 3) | 190 | if (i < 3) |
191 | { | ||
192 | GNUNET_break (0); | ||
149 | return 1; | 193 | return 1; |
194 | } | ||
150 | return 0; | 195 | return 0; |
151 | } | 196 | } |
152 | 197 | ||
@@ -183,19 +228,40 @@ static int | |||
183 | testDirMani () | 228 | testDirMani () |
184 | { | 229 | { |
185 | if (GNUNET_OK != GNUNET_DISK_directory_create_for_file ("test/ing")) | 230 | if (GNUNET_OK != GNUNET_DISK_directory_create_for_file ("test/ing")) |
231 | { | ||
232 | GNUNET_break (0); | ||
186 | return 1; | 233 | return 1; |
234 | } | ||
187 | if (GNUNET_NO != GNUNET_DISK_file_test ("test")) | 235 | if (GNUNET_NO != GNUNET_DISK_file_test ("test")) |
236 | { | ||
237 | GNUNET_break (0); | ||
188 | return 1; | 238 | return 1; |
239 | } | ||
189 | if (GNUNET_NO != GNUNET_DISK_file_test ("test/ing")) | 240 | if (GNUNET_NO != GNUNET_DISK_file_test ("test/ing")) |
241 | { | ||
242 | GNUNET_break (0); | ||
190 | return 1; | 243 | return 1; |
244 | } | ||
191 | if (GNUNET_OK != GNUNET_DISK_directory_remove ("test")) | 245 | if (GNUNET_OK != GNUNET_DISK_directory_remove ("test")) |
246 | { | ||
247 | GNUNET_break (0); | ||
192 | return 1; | 248 | return 1; |
249 | } | ||
193 | if (GNUNET_OK != GNUNET_DISK_directory_create ("test")) | 250 | if (GNUNET_OK != GNUNET_DISK_directory_create ("test")) |
251 | { | ||
252 | GNUNET_break (0); | ||
194 | return 1; | 253 | return 1; |
254 | } | ||
195 | if (GNUNET_YES != GNUNET_DISK_directory_test ("test", GNUNET_YES)) | 255 | if (GNUNET_YES != GNUNET_DISK_directory_test ("test", GNUNET_YES)) |
256 | { | ||
257 | GNUNET_break (0); | ||
196 | return 1; | 258 | return 1; |
259 | } | ||
197 | if (GNUNET_OK != GNUNET_DISK_directory_remove ("test")) | 260 | if (GNUNET_OK != GNUNET_DISK_directory_remove ("test")) |
261 | { | ||
262 | GNUNET_break (0); | ||
198 | return 1; | 263 | return 1; |
264 | } | ||
199 | return 0; | 265 | return 0; |
200 | } | 266 | } |
201 | 267 | ||
@@ -213,9 +279,11 @@ main (int argc, char *argv[]) | |||
213 | failureCount += testCanonicalize (); | 279 | failureCount += testCanonicalize (); |
214 | failureCount += testChangeOwner (); | 280 | failureCount += testChangeOwner (); |
215 | failureCount += testDirMani (); | 281 | failureCount += testDirMani (); |
216 | if (failureCount != 0) | 282 | if (0 != failureCount) |
217 | { | 283 | { |
218 | FPRINTF (stderr, "\n%u TESTS FAILED!\n", failureCount); | 284 | FPRINTF (stderr, |
285 | "\n%u TESTS FAILED!\n", | ||
286 | failureCount); | ||
219 | return -1; | 287 | return -1; |
220 | } | 288 | } |
221 | return 0; | 289 | return 0; |
diff --git a/src/util/test_os_start_process.c b/src/util/test_os_start_process.c index c617917cc..929b24232 100644 --- a/src/util/test_os_start_process.c +++ b/src/util/test_os_start_process.c | |||
@@ -55,7 +55,9 @@ struct read_context | |||
55 | const struct GNUNET_DISK_FileHandle *stdout_read_handle; | 55 | const struct GNUNET_DISK_FileHandle *stdout_read_handle; |
56 | }; | 56 | }; |
57 | 57 | ||
58 | struct read_context rc; | 58 | |
59 | static struct read_context rc; | ||
60 | |||
59 | 61 | ||
60 | static void | 62 | static void |
61 | end_task (void *cls) | 63 | end_task (void *cls) |
@@ -77,35 +79,39 @@ read_call (void *cls) | |||
77 | { | 79 | { |
78 | int bytes; | 80 | int bytes; |
79 | 81 | ||
80 | bytes = GNUNET_DISK_file_read (rc.stdout_read_handle, &rc.buf[rc.buf_offset], \ | 82 | bytes = GNUNET_DISK_file_read (rc.stdout_read_handle, |
81 | sizeof (rc.buf) - rc.buf_offset); | 83 | &rc.buf[rc.buf_offset], |
82 | 84 | sizeof (rc.buf) - rc.buf_offset); | |
83 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "bytes is %d\n", bytes); | 85 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
86 | "bytes is %d\n", | ||
87 | bytes); | ||
84 | 88 | ||
85 | if (bytes < 1) | 89 | if (bytes < 1) |
86 | { | 90 | { |
87 | GNUNET_break (0); | 91 | GNUNET_break (0); |
88 | ok = 1; | 92 | ok = 1; |
89 | GNUNET_SCHEDULER_cancel (die_task); | 93 | GNUNET_SCHEDULER_cancel (die_task); |
90 | GNUNET_SCHEDULER_add_now (&end_task, NULL); | 94 | (void) GNUNET_SCHEDULER_add_now (&end_task, NULL); |
91 | return; | 95 | return; |
92 | } | 96 | } |
93 | 97 | ||
94 | ok = strncmp (rc.buf, test_phrase, strlen (test_phrase)); | 98 | ok = strncmp (rc.buf, test_phrase, strlen (test_phrase)); |
95 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "read %s\n", &rc.buf[rc.buf_offset]); | 99 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
100 | "read %s\n", | ||
101 | &rc.buf[rc.buf_offset]); | ||
96 | rc.buf_offset += bytes; | 102 | rc.buf_offset += bytes; |
97 | 103 | ||
98 | if (0 == ok) | 104 | if (0 == ok) |
99 | { | 105 | { |
100 | GNUNET_SCHEDULER_cancel (die_task); | 106 | GNUNET_SCHEDULER_cancel (die_task); |
101 | GNUNET_SCHEDULER_add_now (&end_task, NULL); | 107 | (void) GNUNET_SCHEDULER_add_now (&end_task, NULL); |
102 | return; | 108 | return; |
103 | } | 109 | } |
104 | 110 | ||
105 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | 111 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
106 | rc.stdout_read_handle, &read_call, | 112 | rc.stdout_read_handle, |
113 | &read_call, | ||
107 | NULL); | 114 | NULL); |
108 | |||
109 | } | 115 | } |
110 | 116 | ||
111 | 117 | ||
@@ -164,13 +170,15 @@ run_task (void *cls) | |||
164 | 170 | ||
165 | die_task = | 171 | die_task = |
166 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 172 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
167 | (GNUNET_TIME_UNIT_MINUTES, 1), &end_task, | 173 | (GNUNET_TIME_UNIT_MINUTES, 1), |
174 | &end_task, | ||
168 | NULL); | 175 | NULL); |
169 | 176 | ||
170 | memset (&rc, 0, sizeof (rc)); | 177 | memset (&rc, 0, sizeof (rc)); |
171 | rc.stdout_read_handle = stdout_read_handle; | 178 | rc.stdout_read_handle = stdout_read_handle; |
172 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | 179 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
173 | stdout_read_handle, &read_call, | 180 | stdout_read_handle, |
181 | &read_call, | ||
174 | NULL); | 182 | NULL); |
175 | } | 183 | } |
176 | 184 | ||
@@ -205,9 +213,12 @@ check_kill () | |||
205 | fn = GNUNET_OS_get_libexec_binary_path ("gnunet-service-resolver"); | 213 | fn = GNUNET_OS_get_libexec_binary_path ("gnunet-service-resolver"); |
206 | proc = | 214 | proc = |
207 | GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_ERR, | 215 | GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_ERR, |
208 | hello_pipe_stdin, hello_pipe_stdout, NULL, | 216 | hello_pipe_stdin, |
217 | hello_pipe_stdout, | ||
218 | NULL, | ||
209 | fn, | 219 | fn, |
210 | "gnunet-service-resolver", "-", NULL); | 220 | "gnunet-service-resolver", "-", |
221 | NULL); | ||
211 | sleep (1); /* give process time to start, so we actually use the pipe-kill mechanism! */ | 222 | sleep (1); /* give process time to start, so we actually use the pipe-kill mechanism! */ |
212 | GNUNET_free (fn); | 223 | GNUNET_free (fn); |
213 | if (0 != GNUNET_OS_process_kill (proc, GNUNET_TERM_SIG)) | 224 | if (0 != GNUNET_OS_process_kill (proc, GNUNET_TERM_SIG)) |
diff --git a/src/util/test_scheduler.c b/src/util/test_scheduler.c index a246d75c5..55d4c7137 100644 --- a/src/util/test_scheduler.c +++ b/src/util/test_scheduler.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include "gnunet_util_lib.h" | 25 | #include "gnunet_util_lib.h" |
26 | 26 | ||
27 | 27 | ||
28 | struct GNUNET_DISK_PipeHandle *p; | 28 | static struct GNUNET_DISK_PipeHandle *p; |
29 | 29 | ||
30 | static const struct GNUNET_DISK_FileHandle *fds[2]; | 30 | static const struct GNUNET_DISK_FileHandle *fds[2]; |
31 | 31 | ||
@@ -80,7 +80,6 @@ taskLast (void *cls) | |||
80 | { | 80 | { |
81 | int *ok = cls; | 81 | int *ok = cls; |
82 | 82 | ||
83 | /* t4 should be ready (albeit with lower priority) */ | ||
84 | GNUNET_assert (8 == *ok); | 83 | GNUNET_assert (8 == *ok); |
85 | (*ok) = 0; | 84 | (*ok) = 0; |
86 | } | 85 | } |
@@ -98,8 +97,8 @@ taskRd (void *cls) | |||
98 | GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, fds[0])); | 97 | GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, fds[0])); |
99 | GNUNET_assert (1 == GNUNET_DISK_file_read (fds[0], &c, 1)); | 98 | GNUNET_assert (1 == GNUNET_DISK_file_read (fds[0], &c, 1)); |
100 | (*ok) = 8; | 99 | (*ok) = 8; |
101 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, &taskLast, | 100 | GNUNET_SCHEDULER_add_shutdown (&taskLast, |
102 | cls); | 101 | cls); |
103 | GNUNET_SCHEDULER_shutdown (); | 102 | GNUNET_SCHEDULER_shutdown (); |
104 | } | 103 | } |
105 | 104 | ||
@@ -115,10 +114,14 @@ task4 (void *cls) | |||
115 | GNUNET_assert (NULL != p); | 114 | GNUNET_assert (NULL != p); |
116 | fds[0] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_READ); | 115 | fds[0] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_READ); |
117 | fds[1] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_WRITE); | 116 | fds[1] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_WRITE); |
118 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, fds[0], &taskRd, | 117 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
118 | fds[0], | ||
119 | &taskRd, | ||
119 | cls); | 120 | cls); |
120 | GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, fds[1], | 121 | GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, |
121 | &taskWrt, cls); | 122 | fds[1], |
123 | &taskWrt, | ||
124 | cls); | ||
122 | } | 125 | } |
123 | 126 | ||
124 | 127 | ||
@@ -130,9 +133,12 @@ task1 (void *cls) | |||
130 | GNUNET_assert (1 == *ok); | 133 | GNUNET_assert (1 == *ok); |
131 | (*ok) = 2; | 134 | (*ok) = 2; |
132 | GNUNET_SCHEDULER_add_now (&task3, cls); | 135 | GNUNET_SCHEDULER_add_now (&task3, cls); |
133 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_UI, &task2, | 136 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_UI, |
137 | &task2, | ||
134 | cls); | 138 | cls); |
135 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &task4, cls); | 139 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
140 | &task4, | ||
141 | cls); | ||
136 | } | 142 | } |
137 | 143 | ||
138 | 144 | ||
@@ -158,7 +164,7 @@ taskShutdown (void *cls) | |||
158 | 164 | ||
159 | GNUNET_assert (1 == *ok); | 165 | GNUNET_assert (1 == *ok); |
160 | *ok = 8; | 166 | *ok = 8; |
161 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &taskLast, cls); | 167 | GNUNET_SCHEDULER_add_shutdown (&taskLast, cls); |
162 | GNUNET_SCHEDULER_shutdown (); | 168 | GNUNET_SCHEDULER_shutdown (); |
163 | } | 169 | } |
164 | 170 | ||
@@ -186,8 +192,9 @@ taskSig (void *cls) | |||
186 | 192 | ||
187 | GNUNET_assert (1 == *ok); | 193 | GNUNET_assert (1 == *ok); |
188 | *ok = 8; | 194 | *ok = 8; |
189 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &taskLast, cls); | 195 | GNUNET_SCHEDULER_add_shutdown (&taskLast, cls); |
190 | GNUNET_break (0 == PLIBC_KILL (getpid (), GNUNET_TERM_SIG)); | 196 | GNUNET_break (0 == PLIBC_KILL (getpid (), |
197 | GNUNET_TERM_SIG)); | ||
191 | } | 198 | } |
192 | 199 | ||
193 | 200 | ||
@@ -214,8 +221,7 @@ taskCancel (void *cls) | |||
214 | 221 | ||
215 | GNUNET_assert (1 == *ok); | 222 | GNUNET_assert (1 == *ok); |
216 | *ok = 0; | 223 | *ok = 0; |
217 | GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_add_now | 224 | GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_add_now (&taskNeverRun, NULL)); |
218 | (&taskNeverRun, NULL)); | ||
219 | } | 225 | } |
220 | 226 | ||
221 | 227 | ||
diff --git a/src/util/test_scheduler_delay.c b/src/util/test_scheduler_delay.c index c55f28e9b..93568cd81 100644 --- a/src/util/test_scheduler_delay.c +++ b/src/util/test_scheduler_delay.c | |||
@@ -62,7 +62,8 @@ test_task (void *cls) | |||
62 | return; | 62 | return; |
63 | } | 63 | } |
64 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 64 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
65 | (GNUNET_TIME_UNIT_MICROSECONDS, i), &test_task, | 65 | (GNUNET_TIME_UNIT_MICROSECONDS, i), |
66 | &test_task, | ||
66 | NULL); | 67 | NULL); |
67 | i += INCR; | 68 | i += INCR; |
68 | } | 69 | } |
@@ -71,7 +72,9 @@ test_task (void *cls) | |||
71 | int | 72 | int |
72 | main (int argc, char *argv[]) | 73 | main (int argc, char *argv[]) |
73 | { | 74 | { |
74 | GNUNET_log_setup ("test-scheduler-delay", "WARNING", NULL); | 75 | GNUNET_log_setup ("test-scheduler-delay", |
76 | "WARNING", | ||
77 | NULL); | ||
75 | target = GNUNET_TIME_absolute_get (); | 78 | target = GNUNET_TIME_absolute_get (); |
76 | GNUNET_SCHEDULER_run (&test_task, NULL); | 79 | GNUNET_SCHEDULER_run (&test_task, NULL); |
77 | FPRINTF (stdout, | 80 | FPRINTF (stdout, |
diff --git a/src/util/test_server_disconnect.c b/src/util/test_server_disconnect.c index 21abf92bb..f59fa547f 100644 --- a/src/util/test_server_disconnect.c +++ b/src/util/test_server_disconnect.c | |||
@@ -76,7 +76,8 @@ server_disconnect (void *cls) | |||
76 | 76 | ||
77 | 77 | ||
78 | static void | 78 | static void |
79 | recv_cb (void *cls, struct GNUNET_SERVER_Client *client, | 79 | recv_cb (void *cls, |
80 | struct GNUNET_SERVER_Client *client, | ||
80 | const struct GNUNET_MessageHeader *message) | 81 | const struct GNUNET_MessageHeader *message) |
81 | { | 82 | { |
82 | GNUNET_assert (ok == 2); | 83 | GNUNET_assert (ok == 2); |
diff --git a/src/util/test_server_with_client_unix.c b/src/util/test_server_with_client_unix.c index ec84b08f8..64f1d9c23 100644 --- a/src/util/test_server_with_client_unix.c +++ b/src/util/test_server_with_client_unix.c | |||
@@ -50,16 +50,18 @@ send_done (void *cls) | |||
50 | 50 | ||
51 | 51 | ||
52 | static void | 52 | static void |
53 | recv_cb (void *cls, struct GNUNET_SERVER_Client *argclient, | 53 | recv_cb (void *cls, |
54 | struct GNUNET_SERVER_Client *argclient, | ||
54 | const struct GNUNET_MessageHeader *message) | 55 | const struct GNUNET_MessageHeader *message) |
55 | { | 56 | { |
56 | switch (ok) | 57 | switch (ok) |
57 | { | 58 | { |
58 | case 2: | 59 | case 2: |
59 | ok++; | 60 | ok++; |
60 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 61 | (void) GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
61 | (GNUNET_TIME_UNIT_MILLISECONDS, 50), | 62 | (GNUNET_TIME_UNIT_MILLISECONDS, 50), |
62 | &send_done, argclient); | 63 | &send_done, |
64 | argclient); | ||
63 | break; | 65 | break; |
64 | case 4: | 66 | case 4: |
65 | ok++; | 67 | ok++; |
@@ -91,13 +93,14 @@ clean_up (void *cls) | |||
91 | * @param client identification of the client | 93 | * @param client identification of the client |
92 | */ | 94 | */ |
93 | static void | 95 | static void |
94 | notify_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | 96 | notify_disconnect (void *cls, |
97 | struct GNUNET_SERVER_Client *client) | ||
95 | { | 98 | { |
96 | if (client == NULL) | 99 | if (client == NULL) |
97 | return; | 100 | return; |
98 | GNUNET_assert (ok == 5); | 101 | GNUNET_assert (ok == 5); |
99 | ok = 0; | 102 | ok = 0; |
100 | GNUNET_SCHEDULER_add_now (&clean_up, NULL); | 103 | (void) GNUNET_SCHEDULER_add_now (&clean_up, NULL); |
101 | } | 104 | } |
102 | 105 | ||
103 | 106 | ||
diff --git a/src/util/test_speedup.c b/src/util/test_speedup.c index 5d46e3127..b9f2cfb4d 100644 --- a/src/util/test_speedup.c +++ b/src/util/test_speedup.c | |||
@@ -53,7 +53,9 @@ run (void *cls) | |||
53 | fprintf (stderr, "..%u", cycles); | 53 | fprintf (stderr, "..%u", cycles); |
54 | if (cycles <= 5) | 54 | if (cycles <= 5) |
55 | { | 55 | { |
56 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &run, NULL); | 56 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
57 | &run, | ||
58 | NULL); | ||
57 | return; | 59 | return; |
58 | } | 60 | } |
59 | end = GNUNET_TIME_absolute_get(); | 61 | end = GNUNET_TIME_absolute_get(); |
@@ -66,21 +68,22 @@ run (void *cls) | |||
66 | * | 68 | * |
67 | */ | 69 | */ |
68 | static void | 70 | static void |
69 | check (void *cls, char *const *args, | 71 | check (void *cls, |
72 | char *const *args, | ||
70 | const char *cfgfile, | 73 | const char *cfgfile, |
71 | const struct GNUNET_CONFIGURATION_Handle * | 74 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
72 | cfg) | ||
73 | { | 75 | { |
74 | fprintf (stderr, "0"); | 76 | fprintf (stderr, "0"); |
75 | fflush(stdout); | 77 | fflush (stdout); |
76 | GNUNET_SCHEDULER_add_now(&run, NULL); | 78 | GNUNET_SCHEDULER_add_now (&run, NULL); |
77 | } | 79 | } |
78 | 80 | ||
79 | 81 | ||
80 | int | 82 | int |
81 | main (int argc, char *argv[]) | 83 | main (int argc, char *argv[]) |
82 | { | 84 | { |
83 | static char *const argvn[] = { "test-speedup", | 85 | static char *const argvn[] = { |
86 | "test-speedup", | ||
84 | "-c", "test_speedup_data.conf", | 87 | "-c", "test_speedup_data.conf", |
85 | NULL | 88 | NULL |
86 | }; | 89 | }; |
diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c index 58eda367f..2c3ac72fa 100644 --- a/src/vpn/gnunet-service-vpn.c +++ b/src/vpn/gnunet-service-vpn.c | |||
@@ -3099,9 +3099,8 @@ run (void *cls, | |||
3099 | &message_token, NULL, NULL); | 3099 | &message_token, NULL, NULL); |
3100 | nc = GNUNET_SERVER_notification_context_create (server, 1); | 3100 | nc = GNUNET_SERVER_notification_context_create (server, 1); |
3101 | GNUNET_SERVER_add_handlers (server, service_handlers); | 3101 | GNUNET_SERVER_add_handlers (server, service_handlers); |
3102 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 3102 | GNUNET_SCHEDULER_add_shutdown (&cleanup, |
3103 | &cleanup, | 3103 | NULL); |
3104 | NULL); | ||
3105 | } | 3104 | } |
3106 | 3105 | ||
3107 | 3106 | ||
diff --git a/src/vpn/gnunet-vpn.c b/src/vpn/gnunet-vpn.c index d4acee49e..2e7daf7f7 100644 --- a/src/vpn/gnunet-vpn.c +++ b/src/vpn/gnunet-vpn.c | |||
@@ -163,7 +163,9 @@ allocation_cb (void *cls, | |||
163 | * @param cfg configuration | 163 | * @param cfg configuration |
164 | */ | 164 | */ |
165 | static void | 165 | static void |
166 | run (void *cls, char *const *args, const char *cfgfile, | 166 | run (void *cls, |
167 | char *const *args, | ||
168 | const char *cfgfile, | ||
167 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 169 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
168 | { | 170 | { |
169 | int dst_af; | 171 | int dst_af; |
@@ -177,8 +179,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
177 | struct GNUNET_TIME_Absolute etime; | 179 | struct GNUNET_TIME_Absolute etime; |
178 | 180 | ||
179 | etime = GNUNET_TIME_relative_to_absolute (duration); | 181 | etime = GNUNET_TIME_relative_to_absolute (duration); |
180 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 182 | GNUNET_SCHEDULER_add_shutdown (&do_disconnect, NULL); |
181 | &do_disconnect, NULL); | ||
182 | handle = GNUNET_VPN_connect (cfg); | 183 | handle = GNUNET_VPN_connect (cfg); |
183 | if (NULL == handle) | 184 | if (NULL == handle) |
184 | goto error; | 185 | goto error; |