-
- /* Use the created connection to kill the doNothingTask */
- GNUNET_CLIENT_service_shutdown(doNothingConnection);
- trialCount++;
- if (startedWaitingAt.value == 0)
- waitedFor.value = 0;
- startedWaitingAt = GNUNET_TIME_absolute_get();
- GNUNET_SCHEDULER_add_delayed (sched,
- waitedFor,
- &do_test,
- NULL);
+ 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);
+ }
+ }
+}
+
+
+static void
+arm_start_cb (void *cls,
+ enum GNUNET_ARM_RequestStatus status,
+ enum GNUNET_ARM_Result result)
+{
+ GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK);
+ GNUNET_break (result == GNUNET_ARM_RESULT_STARTING);
+ GNUNET_break (phase == 0);
+ LOG ("Sent 'START' request for arm to ARM %s\n",
+ (status == GNUNET_ARM_REQUEST_SENT_OK) ? "successfully" : "unsuccessfully");