diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-07-19 14:23:07 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-07-19 14:23:07 +0000 |
commit | c854cbb57bb5aa9edf56e00a94b0bbee63ad31de (patch) | |
tree | 8654b668bcbd21be7794492ba7cd85a185a2d091 /src/arm | |
parent | cf6eb6844411557c5860a9cd17004edfb189f9d6 (diff) | |
download | gnunet-c854cbb57bb5aa9edf56e00a94b0bbee63ad31de.tar.gz gnunet-c854cbb57bb5aa9edf56e00a94b0bbee63ad31de.zip |
cleaning up ARM shutdown
Diffstat (limited to 'src/arm')
-rw-r--r-- | src/arm/gnunet-service-arm.c | 192 |
1 files changed, 71 insertions, 121 deletions
diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c index c388d0c42..05c6fb438 100644 --- a/src/arm/gnunet-service-arm.c +++ b/src/arm/gnunet-service-arm.c | |||
@@ -29,14 +29,12 @@ | |||
29 | * configuration were changed (anything in the section for the service) | 29 | * configuration were changed (anything in the section for the service) |
30 | * - should have a way to specify dependencies between services and | 30 | * - should have a way to specify dependencies between services and |
31 | * manage restarts of groups of services | 31 | * manage restarts of groups of services |
32 | * | ||
33 | * + install handler for disconnecting clients!? | ||
32 | */ | 34 | */ |
33 | #include "platform.h" | 35 | #include "platform.h" |
34 | #include "gnunet_client_lib.h" | 36 | #include "gnunet_util_lib.h" |
35 | #include "gnunet_getopt_lib.h" | ||
36 | #include "gnunet_os_lib.h" | ||
37 | #include "gnunet_protocols.h" | 37 | #include "gnunet_protocols.h" |
38 | #include "gnunet_service_lib.h" | ||
39 | #include "gnunet_signal_lib.h" | ||
40 | #include "gnunet-service-arm.h" | 38 | #include "gnunet-service-arm.h" |
41 | #include "arm.h" | 39 | #include "arm.h" |
42 | 40 | ||
@@ -51,8 +49,6 @@ | |||
51 | */ | 49 | */ |
52 | #define EXPONENTIAL_BACKOFF_THRESHOLD (1000 * 60 * 30) | 50 | #define EXPONENTIAL_BACKOFF_THRESHOLD (1000 * 60 * 30) |
53 | 51 | ||
54 | #define DELAY_SHUTDOWN GNUNET_NO | ||
55 | |||
56 | /** | 52 | /** |
57 | * List of our services. | 53 | * List of our services. |
58 | */ | 54 | */ |
@@ -65,11 +61,16 @@ struct ServiceList; | |||
65 | struct ServiceList | 61 | struct ServiceList |
66 | { | 62 | { |
67 | /** | 63 | /** |
68 | * This is a linked list. | 64 | * This is a doubly-linked list. |
69 | */ | 65 | */ |
70 | struct ServiceList *next; | 66 | struct ServiceList *next; |
71 | 67 | ||
72 | /** | 68 | /** |
69 | * This is a doubly-linked list. | ||
70 | */ | ||
71 | struct ServiceList *prev; | ||
72 | |||
73 | /** | ||
73 | * Name of the service. | 74 | * Name of the service. |
74 | */ | 75 | */ |
75 | char *name; | 76 | char *name; |
@@ -116,7 +117,12 @@ struct ServiceList | |||
116 | /** | 117 | /** |
117 | * List of running services. | 118 | * List of running services. |
118 | */ | 119 | */ |
119 | static struct ServiceList *running; | 120 | static struct ServiceList *running_head; |
121 | |||
122 | /** | ||
123 | * List of running services. | ||
124 | */ | ||
125 | static struct ServiceList *running_tail; | ||
120 | 126 | ||
121 | /** | 127 | /** |
122 | * Our configuration | 128 | * Our configuration |
@@ -188,10 +194,10 @@ config_change_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
188 | struct ServiceList *pos; | 194 | struct ServiceList *pos; |
189 | struct stat sbuf; | 195 | struct stat sbuf; |
190 | 196 | ||
191 | pos = running; | 197 | pos = running_head; |
192 | while (pos != NULL) | 198 | while (pos != NULL) |
193 | { | 199 | { |
194 | /* FIXME: this test for config change is a bit too coarse grained */ | 200 | /* FIXME: this test for config change may be a bit too coarse grained */ |
195 | if ( (0 == STAT (pos->config, &sbuf)) && | 201 | if ( (0 == STAT (pos->config, &sbuf)) && |
196 | (pos->mtime < sbuf.st_mtime) && | 202 | (pos->mtime < sbuf.st_mtime) && |
197 | (pos->proc != NULL) ) | 203 | (pos->proc != NULL) ) |
@@ -208,7 +214,6 @@ config_change_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
208 | } | 214 | } |
209 | 215 | ||
210 | 216 | ||
211 | |||
212 | /** | 217 | /** |
213 | * Transmit a status result message. | 218 | * Transmit a status result message. |
214 | * | 219 | * |
@@ -243,7 +248,6 @@ write_result (void *cls, size_t size, void *buf) | |||
243 | } | 248 | } |
244 | 249 | ||
245 | 250 | ||
246 | |||
247 | /** | 251 | /** |
248 | * Signal our client that we will start or stop the | 252 | * Signal our client that we will start or stop the |
249 | * service. | 253 | * service. |
@@ -283,31 +287,21 @@ signal_result (struct GNUNET_SERVER_Client *client, | |||
283 | 287 | ||
284 | /** | 288 | /** |
285 | * Find the process with the given service | 289 | * Find the process with the given service |
286 | * name in the given list, remove it and return it. | 290 | * name in the given list and return it. |
287 | * | 291 | * |
288 | * @param name which service entry to look up | 292 | * @param name which service entry to look up |
289 | * @return NULL if it was not found | 293 | * @return NULL if it was not found |
290 | */ | 294 | */ |
291 | static struct ServiceList * | 295 | static struct ServiceList * |
292 | find_name (const char *name) | 296 | find_service (const char *name) |
293 | { | 297 | { |
294 | struct ServiceList *pos; | 298 | struct ServiceList *pos; |
295 | struct ServiceList *prev; | ||
296 | 299 | ||
297 | pos = running; | 300 | pos = running_head; |
298 | prev = NULL; | ||
299 | while (pos != NULL) | 301 | while (pos != NULL) |
300 | { | 302 | { |
301 | if (0 == strcmp (pos->name, name)) | 303 | if (0 == strcmp (pos->name, name)) |
302 | { | 304 | return pos; |
303 | if (prev == NULL) | ||
304 | running = pos->next; | ||
305 | else | ||
306 | prev->next = pos->next; | ||
307 | pos->next = NULL; | ||
308 | return pos; | ||
309 | } | ||
310 | prev = pos; | ||
311 | pos = pos->next; | 305 | pos = pos->next; |
312 | } | 306 | } |
313 | return NULL; | 307 | return NULL; |
@@ -315,21 +309,26 @@ find_name (const char *name) | |||
315 | 309 | ||
316 | 310 | ||
317 | /** | 311 | /** |
318 | * Free an entry in the service list. | 312 | * Remove and free an entry in the service list. |
319 | * | 313 | * |
320 | * @param pos entry to free | 314 | * @param pos entry to free |
321 | */ | 315 | */ |
322 | static void | 316 | static void |
323 | free_entry (struct ServiceList *pos) | 317 | free_service (struct ServiceList *pos) |
324 | { | 318 | { |
319 | GNUNET_CONTAINER_DLL_remove (running_head, | ||
320 | running_tail, | ||
321 | pos); | ||
325 | GNUNET_free_non_null (pos->config); | 322 | GNUNET_free_non_null (pos->config); |
326 | GNUNET_free_non_null (pos->binary); | 323 | GNUNET_free_non_null (pos->binary); |
327 | GNUNET_free (pos->name); | 324 | GNUNET_free (pos->name); |
328 | GNUNET_free (pos); | 325 | GNUNET_free (pos); |
329 | } | 326 | } |
330 | 327 | ||
328 | |||
331 | #include "do_start_process.c" | 329 | #include "do_start_process.c" |
332 | 330 | ||
331 | |||
333 | /** | 332 | /** |
334 | * Actually start the process for the given service. | 333 | * Actually start the process for the given service. |
335 | * | 334 | * |
@@ -462,13 +461,11 @@ start_service (struct GNUNET_SERVER_Client *client, | |||
462 | signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN); | 461 | signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN); |
463 | return GNUNET_SYSERR; | 462 | return GNUNET_SYSERR; |
464 | } | 463 | } |
465 | sl = find_name (servicename); | 464 | sl = find_service (servicename); |
466 | if (sl != NULL) | 465 | if (sl != NULL) |
467 | { | 466 | { |
468 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 467 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
469 | _("Service `%s' already running.\n"), servicename); | 468 | _("Service `%s' already running.\n"), servicename); |
470 | sl->next = running; | ||
471 | running = sl; | ||
472 | signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_UP); | 469 | signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_UP); |
473 | return GNUNET_SYSERR; | 470 | return GNUNET_SYSERR; |
474 | } | 471 | } |
@@ -500,14 +497,14 @@ start_service (struct GNUNET_SERVER_Client *client, | |||
500 | (void) stop_listening (servicename); | 497 | (void) stop_listening (servicename); |
501 | sl = GNUNET_malloc (sizeof (struct ServiceList)); | 498 | sl = GNUNET_malloc (sizeof (struct ServiceList)); |
502 | sl->name = GNUNET_strdup (servicename); | 499 | sl->name = GNUNET_strdup (servicename); |
503 | sl->next = running; | ||
504 | sl->binary = binary; | 500 | sl->binary = binary; |
505 | sl->config = config; | 501 | sl->config = config; |
506 | sl->mtime = sbuf.st_mtime; | 502 | sl->mtime = sbuf.st_mtime; |
507 | sl->backoff = GNUNET_TIME_UNIT_MILLISECONDS; | 503 | sl->backoff = GNUNET_TIME_UNIT_MILLISECONDS; |
508 | sl->restartAt = GNUNET_TIME_UNIT_FOREVER_ABS; | 504 | sl->restartAt = GNUNET_TIME_UNIT_FOREVER_ABS; |
509 | 505 | GNUNET_CONTAINER_DLL_insert (running_head, | |
510 | running = sl; | 506 | running_tail, |
507 | sl); | ||
511 | start_process (sl, lsocks); | 508 | start_process (sl, lsocks); |
512 | if (NULL != client) | 509 | if (NULL != client) |
513 | signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_UP); | 510 | signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_UP); |
@@ -529,7 +526,7 @@ stop_service (struct GNUNET_SERVER_Client *client, | |||
529 | 526 | ||
530 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 527 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
531 | _("Preparing to stop `%s'\n"), servicename); | 528 | _("Preparing to stop `%s'\n"), servicename); |
532 | pos = find_name (servicename); | 529 | pos = find_service (servicename); |
533 | if (pos == NULL) | 530 | if (pos == NULL) |
534 | { | 531 | { |
535 | if (GNUNET_OK == stop_listening (servicename)) | 532 | if (GNUNET_OK == stop_listening (servicename)) |
@@ -548,8 +545,6 @@ stop_service (struct GNUNET_SERVER_Client *client, | |||
548 | #endif | 545 | #endif |
549 | signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN); | 546 | signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN); |
550 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 547 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
551 | pos->next = running; | ||
552 | running = pos; | ||
553 | return; | 548 | return; |
554 | } | 549 | } |
555 | 550 | ||
@@ -562,14 +557,12 @@ stop_service (struct GNUNET_SERVER_Client *client, | |||
562 | #endif | 557 | #endif |
563 | signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN); | 558 | signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN); |
564 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 559 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
565 | pos->next = running; | ||
566 | running = pos; | ||
567 | return; | 560 | return; |
568 | } | 561 | } |
569 | if (pos->proc == NULL) | 562 | if (pos->proc == NULL) |
570 | { | 563 | { |
571 | /* process is in delayed restart, simply remove it! */ | 564 | /* process is in delayed restart, simply remove it! */ |
572 | free_entry (pos); | 565 | free_service (pos); |
573 | signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN); | 566 | signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN); |
574 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 567 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
575 | return; | 568 | return; |
@@ -581,8 +574,6 @@ stop_service (struct GNUNET_SERVER_Client *client, | |||
581 | #endif | 574 | #endif |
582 | if (0 != GNUNET_OS_process_kill (pos->proc, SIGTERM)) | 575 | if (0 != GNUNET_OS_process_kill (pos->proc, SIGTERM)) |
583 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | 576 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); |
584 | pos->next = running; | ||
585 | running = pos; | ||
586 | pos->killing_client = client; | 577 | pos->killing_client = client; |
587 | GNUNET_SERVER_client_keep (client); | 578 | GNUNET_SERVER_client_keep (client); |
588 | } | 579 | } |
@@ -659,24 +650,13 @@ clean_up_running () | |||
659 | { | 650 | { |
660 | struct ServiceList *pos; | 651 | struct ServiceList *pos; |
661 | struct ServiceList *next; | 652 | struct ServiceList *next; |
662 | struct ServiceList *prev; | ||
663 | 653 | ||
664 | pos = running; | 654 | next = running_head; |
665 | prev = NULL; | 655 | while (NULL != (pos = next)) |
666 | while (NULL != pos) | ||
667 | { | 656 | { |
668 | next = pos->next; | 657 | next = pos->next; |
669 | if (pos->proc == NULL) | 658 | if (pos->proc == NULL) |
670 | { | 659 | free_service (pos); |
671 | if (prev == NULL) | ||
672 | running = next; | ||
673 | else | ||
674 | prev->next = next; | ||
675 | free_entry (pos); | ||
676 | } | ||
677 | else | ||
678 | prev = pos; | ||
679 | pos = next; | ||
680 | } | 660 | } |
681 | } | 661 | } |
682 | 662 | ||
@@ -700,17 +680,6 @@ do_shutdown () | |||
700 | } | 680 | } |
701 | } | 681 | } |
702 | 682 | ||
703 | #if DELAY_SHUTDOWN | ||
704 | /** | ||
705 | * Dummy task to delay arm shutdown. | ||
706 | */ | ||
707 | void dummy_task (void *cls, | ||
708 | const struct GNUNET_SCHEDULER_TaskContext * tc) | ||
709 | { | ||
710 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Dummy task executing\n"); | ||
711 | return; | ||
712 | } | ||
713 | #endif | ||
714 | 683 | ||
715 | /** | 684 | /** |
716 | * Task run for shutdown. | 685 | * Task run for shutdown. |
@@ -719,16 +688,23 @@ void dummy_task (void *cls, | |||
719 | * @param tc context | 688 | * @param tc context |
720 | */ | 689 | */ |
721 | static void | 690 | static void |
722 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 691 | shutdown_task (void *cls, |
692 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
723 | { | 693 | { |
724 | struct ServiceList *pos; | 694 | struct ServiceList *pos; |
725 | 695 | ||
726 | #if DEBUG_ARM | 696 | #if DEBUG_ARM |
727 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Stopping all services\n")); | 697 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
698 | _("Stopping all services\n")); | ||
728 | #endif | 699 | #endif |
729 | stop_listening (NULL); | 700 | if (GNUNET_SCHEDULER_NO_TASK != child_restart_task) |
701 | { | ||
702 | GNUNET_SCHEDULER_cancel (child_restart_task); | ||
703 | child_restart_task = GNUNET_SCHEDULER_NO_TASK; | ||
704 | } | ||
730 | in_shutdown = GNUNET_YES; | 705 | in_shutdown = GNUNET_YES; |
731 | pos = running; | 706 | stop_listening (NULL); |
707 | pos = running_head; | ||
732 | while (NULL != pos) | 708 | while (NULL != pos) |
733 | { | 709 | { |
734 | if (pos->proc != NULL) | 710 | if (pos->proc != NULL) |
@@ -741,10 +717,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
741 | } | 717 | } |
742 | pos = pos->next; | 718 | pos = pos->next; |
743 | } | 719 | } |
744 | #if DELAY_SHUTDOWN | 720 | if (running_head == NULL) |
745 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), &dummy_task, NULL); | ||
746 | #endif | ||
747 | if (running == NULL) | ||
748 | do_shutdown (); | 721 | do_shutdown (); |
749 | } | 722 | } |
750 | 723 | ||
@@ -763,21 +736,16 @@ delayed_restart_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
763 | 736 | ||
764 | child_restart_task = GNUNET_SCHEDULER_NO_TASK; | 737 | child_restart_task = GNUNET_SCHEDULER_NO_TASK; |
765 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 738 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
766 | { | 739 | return; |
767 | clean_up_running (); | 740 | GNUNET_assert (GNUNET_NO == in_shutdown); |
768 | if (NULL == running) | ||
769 | do_shutdown (); | ||
770 | return; | ||
771 | } | ||
772 | lowestRestartDelay = GNUNET_TIME_UNIT_FOREVER_REL; | 741 | lowestRestartDelay = GNUNET_TIME_UNIT_FOREVER_REL; |
773 | 742 | ||
774 | /* check for services that need to be restarted due to | 743 | /* check for services that need to be restarted due to |
775 | configuration changes or because the last restart failed */ | 744 | configuration changes or because the last restart failed */ |
776 | pos = running; | 745 | pos = running_head; |
777 | while (pos != NULL) | 746 | while (pos != NULL) |
778 | { | 747 | { |
779 | if ( (pos->proc == NULL) && | 748 | if (pos->proc == NULL) |
780 | (GNUNET_YES != in_shutdown) ) | ||
781 | { | 749 | { |
782 | if (GNUNET_TIME_absolute_get_remaining (pos->restartAt).rel_value == 0) | 750 | if (GNUNET_TIME_absolute_get_remaining (pos->restartAt).rel_value == 0) |
783 | { | 751 | { |
@@ -822,7 +790,6 @@ maint_child_death (void *cls, | |||
822 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 790 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
823 | { | 791 | { |
824 | struct ServiceList *pos; | 792 | struct ServiceList *pos; |
825 | struct ServiceList *prev; | ||
826 | struct ServiceList *next; | 793 | struct ServiceList *next; |
827 | const char *statstr; | 794 | const char *statstr; |
828 | int statcode; | 795 | int statcode; |
@@ -834,6 +801,7 @@ maint_child_death (void *cls, | |||
834 | child_death_task = GNUNET_SCHEDULER_NO_TASK; | 801 | child_death_task = GNUNET_SCHEDULER_NO_TASK; |
835 | if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) | 802 | if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) |
836 | { | 803 | { |
804 | /* shutdown scheduled us, ignore! */ | ||
837 | child_death_task = | 805 | child_death_task = |
838 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, pr, | 806 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, pr, |
839 | &maint_child_death, NULL); | 807 | &maint_child_death, NULL); |
@@ -843,26 +811,19 @@ maint_child_death (void *cls, | |||
843 | GNUNET_break (0 < GNUNET_DISK_file_read (pr, &c, sizeof (c))); | 811 | GNUNET_break (0 < GNUNET_DISK_file_read (pr, &c, sizeof (c))); |
844 | 812 | ||
845 | /* check for services that died (WAITPID) */ | 813 | /* check for services that died (WAITPID) */ |
846 | prev = NULL; | 814 | next = running_head; |
847 | next = running; | ||
848 | while (NULL != (pos = next)) | 815 | while (NULL != (pos = next)) |
849 | { | 816 | { |
850 | next = pos->next; | 817 | next = pos->next; |
851 | if (pos->proc == NULL) | 818 | if (pos->proc == NULL) |
852 | { | 819 | continue; |
853 | prev = pos; | ||
854 | continue; | ||
855 | } | ||
856 | if ((GNUNET_SYSERR == (ret = GNUNET_OS_process_status (pos->proc, | 820 | if ((GNUNET_SYSERR == (ret = GNUNET_OS_process_status (pos->proc, |
857 | &statusType, | 821 | &statusType, |
858 | &statusCode))) || | 822 | &statusCode))) || |
859 | ( (ret == GNUNET_NO) || | 823 | ( (ret == GNUNET_NO) || |
860 | (statusType == GNUNET_OS_PROCESS_STOPPED) || | 824 | (statusType == GNUNET_OS_PROCESS_STOPPED) || |
861 | (statusType == GNUNET_OS_PROCESS_RUNNING)) ) | 825 | (statusType == GNUNET_OS_PROCESS_RUNNING)) ) |
862 | { | 826 | continue; |
863 | prev = pos; | ||
864 | continue; | ||
865 | } | ||
866 | 827 | ||
867 | if (statusType == GNUNET_OS_PROCESS_EXITED) | 828 | if (statusType == GNUNET_OS_PROCESS_EXITED) |
868 | { | 829 | { |
@@ -883,10 +844,6 @@ maint_child_death (void *cls, | |||
883 | pos->proc = NULL; | 844 | pos->proc = NULL; |
884 | if (NULL != pos->killing_client) | 845 | if (NULL != pos->killing_client) |
885 | { | 846 | { |
886 | if (prev == NULL) | ||
887 | running = next; | ||
888 | else | ||
889 | prev->next = next; | ||
890 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 847 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
891 | _("Service `%s' stopped\n"), | 848 | _("Service `%s' stopped\n"), |
892 | pos->name); | 849 | pos->name); |
@@ -894,16 +851,15 @@ maint_child_death (void *cls, | |||
894 | pos->name, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN); | 851 | pos->name, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN); |
895 | GNUNET_SERVER_receive_done (pos->killing_client, GNUNET_OK); | 852 | GNUNET_SERVER_receive_done (pos->killing_client, GNUNET_OK); |
896 | GNUNET_SERVER_client_drop (pos->killing_client); | 853 | GNUNET_SERVER_client_drop (pos->killing_client); |
897 | free_entry (pos); | 854 | free_service (pos); |
898 | continue; | 855 | continue; |
899 | } | 856 | } |
900 | if ( (GNUNET_YES != in_shutdown) && | 857 | if (GNUNET_YES != in_shutdown) |
901 | (0 == (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) ) | ||
902 | { | 858 | { |
903 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 859 | if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
904 | _ | 860 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
905 | ("Service `%s' terminated with status %s/%d, will try to restart it!\n"), | 861 | _("Service `%s' terminated with status %s/%d, will try to restart it!\n"), |
906 | pos->name, statstr, statcode); | 862 | pos->name, statstr, statcode); |
907 | /* schedule restart */ | 863 | /* schedule restart */ |
908 | pos->restartAt | 864 | pos->restartAt |
909 | = GNUNET_TIME_relative_to_absolute (pos->backoff); | 865 | = GNUNET_TIME_relative_to_absolute (pos->backoff); |
@@ -923,21 +879,15 @@ maint_child_death (void *cls, | |||
923 | "Service `%s' terminated with status %s/%d\n", | 879 | "Service `%s' terminated with status %s/%d\n", |
924 | pos->name, statstr, statcode); | 880 | pos->name, statstr, statcode); |
925 | #endif | 881 | #endif |
926 | prev = pos; | ||
927 | } | 882 | } |
928 | if (in_shutdown) | 883 | child_death_task = |
884 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, pr, | ||
885 | &maint_child_death, NULL); | ||
886 | if (GNUNET_YES == in_shutdown) | ||
929 | clean_up_running (); | 887 | clean_up_running (); |
930 | if ( (running == NULL) && | 888 | if ( (NULL == running_head) && |
931 | (in_shutdown) ) | 889 | (GNUNET_YES == in_shutdown) ) |
932 | { | 890 | do_shutdown (); |
933 | GNUNET_SERVER_destroy (server); | ||
934 | } | ||
935 | else | ||
936 | { | ||
937 | child_death_task = | ||
938 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, pr, | ||
939 | &maint_child_death, NULL); | ||
940 | } | ||
941 | } | 891 | } |
942 | 892 | ||
943 | 893 | ||
@@ -970,6 +920,7 @@ transmit_shutdown_ack (void *cls, size_t size, void *buf) | |||
970 | return sizeof (struct GNUNET_MessageHeader); | 920 | return sizeof (struct GNUNET_MessageHeader); |
971 | } | 921 | } |
972 | 922 | ||
923 | |||
973 | /** | 924 | /** |
974 | * Handler for SHUTDOWN message. | 925 | * Handler for SHUTDOWN message. |
975 | * | 926 | * |
@@ -985,7 +936,6 @@ handle_shutdown (void *cls, | |||
985 | GNUNET_SERVER_client_keep(client); | 936 | GNUNET_SERVER_client_keep(client); |
986 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 937 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
987 | _("Initiating shutdown as requested by client.\n")); | 938 | _("Initiating shutdown as requested by client.\n")); |
988 | |||
989 | GNUNET_SERVER_notify_transmit_ready (client, | 939 | GNUNET_SERVER_notify_transmit_ready (client, |
990 | sizeof(struct GNUNET_MessageHeader), | 940 | sizeof(struct GNUNET_MessageHeader), |
991 | GNUNET_TIME_UNIT_FOREVER_REL, | 941 | GNUNET_TIME_UNIT_FOREVER_REL, |