aboutsummaryrefslogtreecommitdiff
path: root/src/arm/gnunet-arm.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-01-13 13:23:38 +0100
committerChristian Grothoff <christian@grothoff.org>2017-01-13 13:23:38 +0100
commit553da9baaee28de37ac70af6e59549cabdd18373 (patch)
treee7dae2ff1600b0b56233c0ae0cbdeba9380f62e0 /src/arm/gnunet-arm.c
parentcdb78737878d73db365e2af9be5729d39fbab2bb (diff)
downloadgnunet-553da9baaee28de37ac70af6e59549cabdd18373.tar.gz
gnunet-553da9baaee28de37ac70af6e59549cabdd18373.zip
implement -T option for gnunet-arm (#4854)
Diffstat (limited to 'src/arm/gnunet-arm.c')
-rw-r--r--src/arm/gnunet-arm.c37
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 */
115static struct GNUNET_TIME_Relative timeout; 114static struct GNUNET_TIME_Relative timeout;
116 115
117/** 116/**
117 * Task to be run on timeout.
118 */
119static 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 */
120static unsigned int no_stdout; 124static 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 */
697static void
698timeout_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 */
752int 777int
753main (int argc, char *const *argv) 778main (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}