Ejemplo n.º 1
0
static void
task (void *cls,
      char *const *args,
      const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *c)
{
  cfg = c;
  arm = GNUNET_ARM_connect (cfg, NULL, NULL);
  if (NULL == arm)
  {
    GNUNET_break (0);
    return;
  }
  mon = GNUNET_ARM_monitor_start (cfg,
                                  &srv_status,
                                  NULL);
  if (NULL == mon)
  {
    GNUNET_break (0);
    GNUNET_ARM_disconnect (arm);
    arm = NULL;
    return;
  }
  GNUNET_ARM_request_service_start (arm,
                                    "arm",
                                    GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
                                    &arm_start_cb,
                                    NULL);
  GNUNET_SCHEDULER_add_shutdown (&trigger_disconnect,
                                 NULL);
}
Ejemplo n.º 2
0
static void
srv_status (void *cls,
            const char *service,
            enum GNUNET_ARM_ServiceStatus status)
{
  if (status == GNUNET_ARM_SERVICE_MONITORING_STARTED)
  {
    LOG ("ARM monitor started, starting mock service\n");
    phase++;
    GNUNET_ARM_request_service_start (arm,
                                      SERVICE,
                                      GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
                                      NULL,
                                      NULL);
    return;
  }
  if (0 != strcasecmp (service, SERVICE))
    return; /* not what we care about */
  if (phase == 1)
  {
    GNUNET_break (status == GNUNET_ARM_SERVICE_STARTING);
    GNUNET_break (phase == 1);
    LOG ("do-nothing is starting\n");
    phase++;
    ok = 1;
    GNUNET_assert (NULL == kt);
    startedWaitingAt = GNUNET_TIME_absolute_get ();
    kt = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
                                       &kill_task,
                                       NULL);
  }
  else if (phase == 2)
  {
    /* We passively monitor ARM for status updates. ARM should tell us
     * when do-nothing dies (no need to run a service upness test ourselves).
     */
    if (status == GNUNET_ARM_SERVICE_STARTING)
    {
      waitedFor = GNUNET_TIME_absolute_get_duration (startedWaitingAt);
      LOG ("Waited for: %s\n",
           GNUNET_STRINGS_relative_time_to_string (waitedFor,
                                                   GNUNET_YES));

      LOG ("do-nothing is starting, killing it...\n");
      GNUNET_assert (NULL == kt);
      kt = GNUNET_SCHEDULER_add_now (&kill_task, &ok);
    }
    else if ((status == GNUNET_ARM_SERVICE_STOPPED) && (trialCount == 14))
    {
      phase++;
      LOG ("do-nothing stopped working %u times, we are done here\n",
           (unsigned int) trialCount);
      GNUNET_ARM_request_service_stop (arm,
                                       "arm",
                                       &arm_stop_cb,
                                       NULL);
    }
  }
}
Ejemplo n.º 3
0
static void
run (void *cls,
     char *const *args,
     const char *cfgfile,
     const struct GNUNET_CONFIGURATION_Handle *c)
{
  arm = GNUNET_ARM_connect (c, NULL, NULL);
  GNUNET_ARM_request_service_start (arm, "arm",
                                    GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
                                    START_TIMEOUT,
                                    &arm_start_cb, NULL);
}