diff options
-rw-r--r-- | src/arm/gnunet-arm.c | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/src/arm/gnunet-arm.c b/src/arm/gnunet-arm.c index 3b024ea93..b6f4d99a8 100644 --- a/src/arm/gnunet-arm.c +++ b/src/arm/gnunet-arm.c | |||
@@ -110,11 +110,15 @@ static unsigned int phase; | |||
110 | 110 | ||
111 | /** | 111 | /** |
112 | * User defined timestamp for completing operations. | 112 | * User defined timestamp for completing operations. |
113 | * FIXME: to be implemented! | ||
114 | */ | 113 | */ |
115 | static struct GNUNET_TIME_Relative timeout; | 114 | static struct GNUNET_TIME_Relative timeout; |
116 | 115 | ||
117 | /** | 116 | /** |
117 | * Task to be run on timeout. | ||
118 | */ | ||
119 | static struct GNUNET_SCHEDULER_Task *timeout_task; | ||
120 | |||
121 | /** | ||
118 | * Do we want to give our stdout to gnunet-service-arm? | 122 | * Do we want to give our stdout to gnunet-service-arm? |
119 | */ | 123 | */ |
120 | static unsigned int no_stdout; | 124 | static unsigned int no_stdout; |
@@ -191,6 +195,11 @@ shutdown_task (void *cls) | |||
191 | GNUNET_ARM_monitor_stop (m); | 195 | GNUNET_ARM_monitor_stop (m); |
192 | m = NULL; | 196 | m = NULL; |
193 | } | 197 | } |
198 | if (NULL != timeout_task) | ||
199 | { | ||
200 | GNUNET_SCHEDULER_cancel (timeout_task); | ||
201 | timeout_task = NULL; | ||
202 | } | ||
194 | if ((GNUNET_YES == end) && (GNUNET_YES == delete)) | 203 | if ((GNUNET_YES == end) && (GNUNET_YES == delete)) |
195 | delete_files (); | 204 | delete_files (); |
196 | GNUNET_CONFIGURATION_destroy (cfg); | 205 | GNUNET_CONFIGURATION_destroy (cfg); |
@@ -683,6 +692,18 @@ srv_status (void *cls, | |||
683 | 692 | ||
684 | 693 | ||
685 | /** | 694 | /** |
695 | * Task run on timeout (if -T is given). | ||
696 | */ | ||
697 | static void | ||
698 | timeout_task_cb (void *cls) | ||
699 | { | ||
700 | timeout_task = NULL; | ||
701 | ret = 2; | ||
702 | GNUNET_SCHEDULER_shutdown (); | ||
703 | } | ||
704 | |||
705 | |||
706 | /** | ||
686 | * Main function that will be run by the scheduler. | 707 | * Main function that will be run by the scheduler. |
687 | * | 708 | * |
688 | * @param cls closure | 709 | * @param cls closure |
@@ -739,6 +760,10 @@ run (void *cls, | |||
739 | NULL); | 760 | NULL); |
740 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, | 761 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
741 | NULL); | 762 | NULL); |
763 | if (0 != timeout.rel_value_us) | ||
764 | timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, | ||
765 | &timeout_task_cb, | ||
766 | NULL); | ||
742 | } | 767 | } |
743 | 768 | ||
744 | 769 | ||
@@ -747,7 +772,7 @@ run (void *cls, | |||
747 | * | 772 | * |
748 | * @param argc number of arguments from the command line | 773 | * @param argc number of arguments from the command line |
749 | * @param argv command line arguments | 774 | * @param argv command line arguments |
750 | * @return 0 ok, 1 on error | 775 | * @return 0 ok, 1 on error, 2 on timeout |
751 | */ | 776 | */ |
752 | int | 777 | int |
753 | main (int argc, char *const *argv) | 778 | main (int argc, char *const *argv) |
@@ -793,10 +818,10 @@ main (int argc, char *const *argv) | |||
793 | gettext_noop | 818 | gettext_noop |
794 | ("Control services and the Automated Restart Manager (ARM)"), | 819 | ("Control services and the Automated Restart Manager (ARM)"), |
795 | options, &run, NULL)) | 820 | options, &run, NULL)) |
796 | { | 821 | { |
797 | GNUNET_free ((void *) argv); | 822 | GNUNET_free ((void *) argv); |
798 | return ret; | 823 | return ret; |
799 | } | 824 | } |
800 | GNUNET_free ((void*) argv); | 825 | GNUNET_free ((void*) argv); |
801 | return 1; | 826 | return 1; |
802 | } | 827 | } |