wip
[oweals/gnunet.git] / src / arm / gnunet-arm.c
index 7ec717a5adf4fa8251e757e632231fb4d89b0f1e..ba74e8223b6110401241385fd91926d363e90c60 100644 (file)
 /**
  * Timeout for stopping services.  Long to give some services a real chance.
  */
-#define STOP_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
+#define STOP_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
+
+/**
+ * Timeout for stopping ARM.  Extra-long since ARM needs to stop everyone else.
+ */
+#define STOP_TIMEOUT_ARM GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
 
 /**
  * Timeout for starting services, very short because of the strange way start works
@@ -110,11 +115,6 @@ static int ret;
  */
 static struct GNUNET_ARM_Handle *h;
 
-/**
- * Our scheduler.
- */
-static struct GNUNET_SCHEDULER_Handle *sched;
-
 /**
  * Our configuration.
  */
@@ -179,8 +179,7 @@ confirm_cb (void *cls, int success)
       break;
     }
 
-  GNUNET_SCHEDULER_add_continuation (sched,
-                                    &cps_loop,
+  GNUNET_SCHEDULER_add_continuation (&cps_loop,
                                     NULL,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
 }
@@ -208,8 +207,7 @@ confirm_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       if (quiet != GNUNET_YES)
         fprintf(stdout, _("Service `%s' is not running.\n"), service);
     }
-  GNUNET_SCHEDULER_add_continuation (sched,
-                                    &cps_loop,
+  GNUNET_SCHEDULER_add_continuation (&cps_loop,
                                     NULL,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
 }
@@ -219,19 +217,16 @@ confirm_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
  * Main function that will be run by the scheduler.
  *
  * @param cls closure
- * @param s the scheduler to use
  * @param args remaining command-line arguments
  * @param cfgfile name of the configuration file used (for saving, can be NULL!)
  * @param c configuration
  */
 static void
 run (void *cls,
-     struct GNUNET_SCHEDULER_Handle *s,
      char *const *args,
      const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *c)
 {
-  sched = s;
   cfg = c;
   config_file = cfgfile;
   if (GNUNET_CONFIGURATION_get_value_string(cfg, "PATHS", "SERVICEHOME", &dir) != GNUNET_OK)
@@ -242,7 +237,7 @@ run (void *cls,
                  "PATHS");
       return;
     }
-  h = GNUNET_ARM_connect (cfg, sched, NULL);
+  h = GNUNET_ARM_connect (cfg, NULL);
   if (h == NULL)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -250,8 +245,7 @@ run (void *cls,
       ret = 1;
       return;
     }
-  GNUNET_SCHEDULER_add_continuation (sched,
-                                    &cps_loop,
+  GNUNET_SCHEDULER_add_continuation (&cps_loop,
                                     NULL,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
 }
@@ -304,7 +298,7 @@ cps_loop (void *cls,
        case 1:
          if ((end) || (restart))
            {
-             GNUNET_ARM_stop_service (h, "arm", STOP_TIMEOUT, &confirm_cb, "arm");
+             GNUNET_ARM_stop_service (h, "arm", STOP_TIMEOUT_ARM, &confirm_cb, "arm");
              return;
            }
          break;
@@ -325,7 +319,7 @@ cps_loop (void *cls,
        case 4:
          if (test != NULL)
            {
-             GNUNET_CLIENT_service_test (sched, test, cfg, TEST_TIMEOUT, &confirm_task, test);
+             GNUNET_CLIENT_service_test (test, cfg, TEST_TIMEOUT, &confirm_task, test);
              return;
            }
          break;
@@ -337,7 +331,7 @@ cps_loop (void *cls,
               end = 0;
               start = 1;
               restart = 0;
-              h = GNUNET_ARM_connect (cfg, sched, NULL);
+              h = GNUNET_ARM_connect (cfg, NULL);
               if (h == NULL)
                 {
                   GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -345,7 +339,7 @@ cps_loop (void *cls,
                   ret = 1;
                   return;
                 }
-              GNUNET_SCHEDULER_add_now(sched, &cps_loop, NULL);
+              GNUNET_SCHEDULER_add_now(&cps_loop, NULL);
               return;
            }
          /* Fall through */