- verboser log, faster start
[oweals/gnunet.git] / src / arm / arm_api.c
index c352cbdae2beca55b34e973569ecae5cff416c70..fd49a18a5aaded165b29a6005c44e51d37703636 100644 (file)
  */
 #include "platform.h"
 #include "gnunet_arm_service.h"
-#include "gnunet_client_lib.h"
-#include "gnunet_getopt_lib.h"
-#include "gnunet_os_lib.h"
+#include "gnunet_util_lib.h"
 #include "gnunet_protocols.h"
-#include "gnunet_server_lib.h"
 #include "arm.h"
 
 #define LOG(kind,...) GNUNET_log_from (kind, "arm-api",__VA_ARGS__)
@@ -87,11 +84,6 @@ struct ShutdownContext
    */
   struct GNUNET_CLIENT_TransmitHandle *th;
 
-  /**
-   * Result of the operation
-   */
-  enum GNUNET_ARM_ProcessStatus confirmed;
-
 };
 
 
@@ -110,45 +102,23 @@ static void
 service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg)
 {
   struct ShutdownContext *shutdown_ctx = cls;
-  const struct GNUNET_ARM_ResultMessage *rmsg;
 
-  if (msg == NULL)
+  if (NULL != msg)
   {
-    if (shutdown_ctx->cont != NULL)
-    {
-      if (shutdown_ctx->confirmed == GNUNET_ARM_PROCESS_SHUTDOWN)
-      {
-       /* shutdown is now complete, as we waited for the network disconnect... */
-       shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_ARM_PROCESS_DOWN);
-      }
-      else
-      {
-       /* communication error */
-       shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_ARM_PROCESS_COMMUNICATION_ERROR);
-      }
-    }
+    /* We just expected a disconnect! Report the error and be done with it... */
+    GNUNET_break (0);
+    shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_ARM_PROCESS_COMMUNICATION_ERROR);
     GNUNET_SCHEDULER_cancel (shutdown_ctx->cancel_task);
-    GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO);
+    GNUNET_CLIENT_disconnect (shutdown_ctx->sock);
     GNUNET_free (shutdown_ctx);
     return;
   }
-  if (ntohs (msg->size) ==
-      sizeof (struct GNUNET_ARM_ResultMessage))
-  {
-    rmsg = (const struct GNUNET_ARM_ResultMessage*) msg;
-    shutdown_ctx->confirmed = (enum GNUNET_ARM_ProcessStatus) ntohl (rmsg->status);
-    if (shutdown_ctx->confirmed != GNUNET_ARM_PROCESS_SHUTDOWN)
-    {
-      /* ARM is not shutting down, well, report the error and be done with it... */
-      shutdown_ctx->cont (shutdown_ctx->cont_cls, shutdown_ctx->confirmed);
-      GNUNET_SCHEDULER_cancel (shutdown_ctx->cancel_task);
-      GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO);
-      GNUNET_free (shutdown_ctx);
-      return;
-    }
-  }
-  GNUNET_CLIENT_receive (shutdown_ctx->sock, &service_shutdown_handler,
-                        shutdown_ctx, GNUNET_TIME_UNIT_FOREVER_REL);
+  if (NULL != shutdown_ctx->cont)
+    /* shutdown is now complete, as we waited for the network disconnect... */
+    shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_ARM_PROCESS_DOWN);    
+  GNUNET_SCHEDULER_cancel (shutdown_ctx->cancel_task);
+  GNUNET_CLIENT_disconnect (shutdown_ctx->sock);
+  GNUNET_free (shutdown_ctx);
 }
 
 
@@ -165,7 +135,7 @@ service_shutdown_cancel (void *cls,
   struct ShutdownContext *shutdown_ctx = cls;
 
   shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_ARM_PROCESS_COMMUNICATION_TIMEOUT);
-  GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO);
+  GNUNET_CLIENT_disconnect (shutdown_ctx->sock);
   GNUNET_free (shutdown_ctx);
 }
 
@@ -187,15 +157,14 @@ write_shutdown (void *cls, size_t size, void *buf)
 
   shutdown_ctx->th = NULL;
   if (size < sizeof (struct GNUNET_MessageHeader))
-    {
-      LOG (GNUNET_ERROR_TYPE_WARNING,
-          _("Failed to transmit shutdown request to client.\n"));
-      shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_ARM_PROCESS_COMMUNICATION_ERROR);
-      GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO);
-      GNUNET_free (shutdown_ctx);
-      return 0;                        /* client disconnected */
-    }
-
+  {
+    LOG (GNUNET_ERROR_TYPE_WARNING,
+        _("Failed to transmit shutdown request to client.\n"));
+    shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_ARM_PROCESS_COMMUNICATION_ERROR);
+    GNUNET_CLIENT_disconnect (shutdown_ctx->sock);
+    GNUNET_free (shutdown_ctx);
+    return 0;                  /* client disconnected */
+  }
   GNUNET_CLIENT_receive (shutdown_ctx->sock, &service_shutdown_handler,
                         shutdown_ctx, GNUNET_TIME_UNIT_FOREVER_REL);
   shutdown_ctx->cancel_task =
@@ -234,7 +203,6 @@ arm_service_shutdown (struct GNUNET_CLIENT_Connection *sock,
   shutdown_ctx->cont_cls = cont_cls;
   shutdown_ctx->sock = sock;
   shutdown_ctx->timeout = GNUNET_TIME_relative_to_absolute (timeout);
-  shutdown_ctx->confirmed = GNUNET_ARM_PROCESS_COMMUNICATION_ERROR;    
   shutdown_ctx->th = GNUNET_CLIENT_notify_transmit_ready (sock,
                                                          sizeof (struct GNUNET_MessageHeader),
                                                          timeout, GNUNET_NO, &write_shutdown,
@@ -273,7 +241,7 @@ void
 GNUNET_ARM_disconnect (struct GNUNET_ARM_Handle *h)
 {
   if (h->client != NULL)
-    GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
+    GNUNET_CLIENT_disconnect (h->client);
   GNUNET_CONFIGURATION_destroy (h->cfg);
   GNUNET_free (h);
 }
@@ -324,6 +292,11 @@ struct RequestContext
    */
   uint16_t type;
 
+  /**
+   * Flags for passing std descriptors to ARM (when starting ARM).
+   */
+  enum GNUNET_OS_InheritStdioFlags std_inheritance;
+
 };
 
 #include "do_start_process.c"
@@ -343,28 +316,25 @@ arm_service_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct RequestContext *pos = cls;
   struct GNUNET_OS_Process *proc;
+  char *cbinary;
   char *binary;
   char *config;
   char *loprefix;
   char *lopostfix;
 
   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE))
-    {
-#if DEBUG_ARM
-      LOG (GNUNET_ERROR_TYPE_DEBUG, "Looks like `%s' is already running.\n",
-          "gnunet-service-arm");
-#endif
-      /* arm is running! */
-      if (pos->callback != NULL)
-       pos->callback (pos->cls, GNUNET_ARM_PROCESS_ALREADY_RUNNING);
-      GNUNET_free (pos);
-      return;
-    }
-#if DEBUG_ARM
+  {
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "Looks like `%s' is already running.\n",
+        "gnunet-service-arm");
+    /* arm is running! */
+    if (pos->callback != NULL)
+      pos->callback (pos->cls, GNUNET_ARM_PROCESS_ALREADY_RUNNING);
+    GNUNET_free (pos);
+    return;
+  }
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Looks like `%s' is not running, will start it.\n",
        "gnunet-service-arm");
-#endif
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_string (pos->h->cfg, "arm", "PREFIX",
                                             &loprefix))
@@ -375,34 +345,23 @@ arm_service_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     lopostfix = GNUNET_strdup ("");
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_string (pos->h->cfg, "arm", "BINARY",
-                                            &binary))
-    {
-      LOG (GNUNET_ERROR_TYPE_WARNING,
-          _
-          ("Configuration failes to specify option `%s' in section `%s'!\n"),
-          "BINARY", "arm");
-      if (pos->callback != NULL)
-       pos->callback (pos->cls, GNUNET_ARM_PROCESS_UNKNOWN);
-      GNUNET_free (pos);
-      GNUNET_free (loprefix);
-      GNUNET_free (lopostfix);
-      return;
-    }
+                                            &cbinary))
+  {
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
+                              "arm", "BINARY");
+    if (pos->callback != NULL)
+      pos->callback (pos->cls, GNUNET_ARM_PROCESS_UNKNOWN);
+    GNUNET_free (pos);
+    GNUNET_free (loprefix);
+    GNUNET_free (lopostfix);
+    return;
+  }
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_filename (pos->h->cfg, "arm", "CONFIG",
                                               &config))
-    {
-      LOG (GNUNET_ERROR_TYPE_WARNING,
-          _("Configuration fails to specify option `%s' in section `%s'!\n"),
-          "CONFIG", "arm");
-      if (pos->callback != NULL)
-       pos->callback (pos->cls, GNUNET_ARM_PROCESS_UNKNOWN);
-      GNUNET_free (binary);
-      GNUNET_free (pos);
-      GNUNET_free (loprefix);
-      GNUNET_free (lopostfix);
-      return;
-    }
+    config = NULL;
+  binary = GNUNET_OS_get_libexec_binary_path (cbinary);
+  GNUNET_free (cbinary);
   if ((GNUNET_YES ==
        GNUNET_CONFIGURATION_have_value (pos->h->cfg, "TESTING", "WEAKRANDOM"))
       && (GNUNET_YES ==
@@ -411,37 +370,42 @@ arm_service_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       && (GNUNET_NO ==
          GNUNET_CONFIGURATION_have_value (pos->h->cfg, "TESTING",
                                           "HOSTFILE")))
-    {
-      /* Means we are ONLY running locally */
-      /* we're clearly running a test, don't daemonize */
-      proc = do_start_process (GNUNET_NO,
+  {
+    /* Means we are ONLY running locally */
+    /* we're clearly running a test, don't daemonize */
+    if (NULL == config)
+      proc = do_start_process (GNUNET_NO, pos->std_inheritance,
+                              NULL, loprefix, binary,
+                              /* no daemonization! */
+                              lopostfix, NULL);
+    else
+      proc = do_start_process (GNUNET_NO, pos->std_inheritance,
                               NULL, loprefix, binary, "-c", config,
-#if DEBUG_ARM
-                              "-L", "DEBUG",
-#endif
                               /* no daemonization! */
                               lopostfix, NULL);
-    }
+  }
   else
-    {
-      proc = do_start_process (GNUNET_NO,
+  {
+    if (NULL == config)
+      proc = do_start_process (GNUNET_NO, pos->std_inheritance,
+                              NULL, loprefix, binary,
+                              "-d", lopostfix, NULL);
+    else
+      proc = do_start_process (GNUNET_NO, pos->std_inheritance,
                               NULL, loprefix, binary, "-c", config,
-#if DEBUG_ARM
-                              "-L", "DEBUG",
-#endif
                               "-d", lopostfix, NULL);
-    }
+  }
   GNUNET_free (binary);
-  GNUNET_free (config);
+  GNUNET_free_non_null (config);
   GNUNET_free (loprefix);
   GNUNET_free (lopostfix);
-  if (proc == NULL)
-    {
-      if (pos->callback != NULL)
-       pos->callback (pos->cls, GNUNET_ARM_PROCESS_FAILURE);
-      GNUNET_free (pos);
-      return;
-    }
+  if (NULL == proc)
+  {
+    if (pos->callback != NULL)
+      pos->callback (pos->cls, GNUNET_ARM_PROCESS_FAILURE);
+    GNUNET_free (pos);
+    return;
+  }
   if (pos->callback != NULL)
     pos->callback (pos->cls, GNUNET_ARM_PROCESS_STARTING);
   GNUNET_free (proc);
@@ -465,26 +429,20 @@ handle_response (void *cls, const struct GNUNET_MessageHeader *msg)
 
   if ((msg == NULL) ||
       (ntohs (msg->size) != sizeof (struct GNUNET_ARM_ResultMessage)))
-    {
-      LOG (GNUNET_ERROR_TYPE_WARNING,
-          _
-          ("Error receiving response to `%s' request from ARM for service `%s'\n"),
-          (sc->type == GNUNET_MESSAGE_TYPE_ARM_START) ? "START" : "STOP",
-          (const char *) &sc[1]);
-      GNUNET_CLIENT_disconnect (sc->h->client, GNUNET_NO);
-      sc->h->client = GNUNET_CLIENT_connect ("arm", sc->h->cfg);
-      GNUNET_assert (NULL != sc->h->client);
-      if (sc->callback != NULL)
-       sc->callback (sc->cls, GNUNET_ARM_PROCESS_COMMUNICATION_ERROR);
-      GNUNET_free (sc);
-      return;
-    }
+  {
+    GNUNET_break (0);
+    GNUNET_CLIENT_disconnect (sc->h->client);
+    sc->h->client = GNUNET_CLIENT_connect ("arm", sc->h->cfg);
+    GNUNET_assert (NULL != sc->h->client);
+    if (sc->callback != NULL)
+      sc->callback (sc->cls, GNUNET_ARM_PROCESS_COMMUNICATION_ERROR);
+    GNUNET_free (sc);
+    return;
+  }
   res = (const struct GNUNET_ARM_ResultMessage *) msg;
-#if DEBUG_ARM
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Received response from ARM for service `%s': %u\n",
        (const char *) &sc[1], ntohs (msg->type));
-#endif
   status = (enum GNUNET_ARM_ProcessStatus) ntohl (res->status);
   if (sc->callback != NULL)
     sc->callback (sc->cls, status);
@@ -514,19 +472,17 @@ change_service (struct GNUNET_ARM_Handle *h, const char *service_name,
   slen = strlen (service_name) + 1;
   if (slen + sizeof (struct GNUNET_MessageHeader) >=
       GNUNET_SERVER_MAX_MESSAGE_SIZE)
-    {
-      GNUNET_break (0);
-      if (cb != NULL)
-       cb (cb_cls, GNUNET_NO);
-      return;
-    }
-#if DEBUG_ARM
+  {
+    GNUNET_break (0);
+    if (cb != NULL)
+      cb (cb_cls, GNUNET_NO);
+    return;
+  }
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        (type ==
        GNUNET_MESSAGE_TYPE_ARM_START) ?
-       _("Requesting start of service `%s'.\n") :
-       _("Requesting termination of service `%s'.\n"), service_name);
-#endif
+       "Requesting start of service `%s'.\n" :
+       "Requesting termination of service `%s'.\n", service_name);
   sctx = GNUNET_malloc (sizeof (struct RequestContext) + slen);
   sctx->h = h;
   sctx->callback = cb;
@@ -543,20 +499,14 @@ change_service (struct GNUNET_ARM_Handle *h, const char *service_name,
                                               GNUNET_TIME_absolute_get_remaining
                                               (sctx->timeout), GNUNET_YES,
                                               &handle_response, sctx))
-    {
-      LOG (GNUNET_ERROR_TYPE_WARNING,
-          (type ==
-           GNUNET_MESSAGE_TYPE_ARM_START) ?
-          _("Error while trying to transmit request to start `%s' to ARM\n")
-          :
-          _("Error while trying to transmit request to stop `%s' to ARM\n"),
-          (const char *) &service_name);
-      if (cb != NULL)
-       cb (cb_cls, GNUNET_SYSERR);
-      GNUNET_free (sctx);
-      GNUNET_free (msg);
-      return;
-    }
+  {
+    GNUNET_break (0);
+    if (cb != NULL)
+      cb (cb_cls, GNUNET_SYSERR);
+    GNUNET_free (sctx);
+    GNUNET_free (msg);
+    return;
+  }
   GNUNET_free (msg);
 }
 
@@ -566,6 +516,7 @@ change_service (struct GNUNET_ARM_Handle *h, const char *service_name,
  *
  * @param h handle to ARM
  * @param service_name name of the service
+ * @param std_inheritance inheritance of std streams
  * @param timeout how long to wait before failing for good
  * @param cb callback to invoke when service is ready
  * @param cb_cls closure for callback
@@ -573,6 +524,7 @@ change_service (struct GNUNET_ARM_Handle *h, const char *service_name,
 void
 GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h,
                          const char *service_name,
+                          enum GNUNET_OS_InheritStdioFlags std_inheritance,
                          struct GNUNET_TIME_Relative timeout,
                          GNUNET_ARM_Callback cb, void *cb_cls)
 {
@@ -580,38 +532,37 @@ GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h,
   struct GNUNET_CLIENT_Connection *client;
   size_t slen;
 
-#if DEBUG_ARM
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-       _("Asked to start service `%s' within %llu ms\n"), service_name,
-       (unsigned long long) timeout.rel_value);
-#endif
+       "Asked to start service `%s' within %s\n", service_name,
+       GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_NO));
   if (0 == strcasecmp ("arm", service_name))
+  {
+    slen = strlen ("arm") + 1;
+    sctx = GNUNET_malloc (sizeof (struct RequestContext) + slen);
+    sctx->h = h;
+    sctx->callback = cb;
+    sctx->cls = cb_cls;
+    sctx->timeout = GNUNET_TIME_relative_to_absolute (timeout);
+    sctx->std_inheritance = std_inheritance;
+    memcpy (&sctx[1], service_name, slen);
+    GNUNET_CLIENT_service_test ("arm", h->cfg, timeout, &arm_service_report,
+                               sctx);
+    return;
+  }
+  if (NULL == h->client)
+  {
+    client = GNUNET_CLIENT_connect ("arm", h->cfg);
+    if (client == NULL)
     {
-      slen = strlen ("arm") + 1;
-      sctx = GNUNET_malloc (sizeof (struct RequestContext) + slen);
-      sctx->h = h;
-      sctx->callback = cb;
-      sctx->cls = cb_cls;
-      sctx->timeout = GNUNET_TIME_relative_to_absolute (timeout);
-      memcpy (&sctx[1], service_name, slen);
-      GNUNET_CLIENT_service_test ("arm", h->cfg, timeout, &arm_service_report,
-                                 sctx);
-      return;
-    }
-  if (h->client == NULL)
-    {
-      client = GNUNET_CLIENT_connect ("arm", h->cfg);
-      if (client == NULL)
-       {
-         LOG (GNUNET_ERROR_TYPE_DEBUG,
-              "arm_api, GNUNET_CLIENT_connect returned NULL\n");
-         cb (cb_cls, GNUNET_ARM_PROCESS_COMMUNICATION_ERROR);
-         return;
-       }
       LOG (GNUNET_ERROR_TYPE_DEBUG,
-          "arm_api, GNUNET_CLIENT_connect returned non-NULL\n");
-      h->client = client;
+          "arm_api, GNUNET_CLIENT_connect returned NULL\n");
+      cb (cb_cls, GNUNET_ARM_PROCESS_COMMUNICATION_ERROR);
+      return;
     }
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+        "arm_api, GNUNET_CLIENT_connect returned non-NULL\n");
+    h->client = client;
+  }
   LOG (GNUNET_ERROR_TYPE_DEBUG, "arm_api, h->client non-NULL\n");
   change_service (h, service_name, timeout, cb, cb_cls,
                  GNUNET_MESSAGE_TYPE_ARM_START);
@@ -632,7 +583,6 @@ arm_shutdown_callback (void *cls, enum GNUNET_ARM_ProcessStatus reason)
 
   if (arm_shutdown_ctx->cb != NULL)
     arm_shutdown_ctx->cb (arm_shutdown_ctx->cb_cls, reason);
-
   GNUNET_free (arm_shutdown_ctx);
 }
 
@@ -655,28 +605,30 @@ GNUNET_ARM_stop_service (struct GNUNET_ARM_Handle *h,
   struct ARM_ShutdownContext *arm_shutdown_ctx;
   struct GNUNET_CLIENT_Connection *client;
 
-  LOG (GNUNET_ERROR_TYPE_INFO, _("Stopping service `%s' within %llu ms\n"),
-       service_name, (unsigned long long) timeout.rel_value);
+  LOG (GNUNET_ERROR_TYPE_DEBUG, 
+       "Stopping service `%s' within %s\n",
+       service_name, 
+       GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_NO));
   if (h->client == NULL)
+  {
+    client = GNUNET_CLIENT_connect ("arm", h->cfg);
+    if (client == NULL)
     {
-      client = GNUNET_CLIENT_connect ("arm", h->cfg);
-      if (client == NULL)
-       {
-         cb (cb_cls, GNUNET_SYSERR);
-         return;
-       }
-      h->client = client;
-    }
-  if (0 == strcasecmp ("arm", service_name))
-    {
-      arm_shutdown_ctx = GNUNET_malloc (sizeof (struct ARM_ShutdownContext));
-      arm_shutdown_ctx->cb = cb;
-      arm_shutdown_ctx->cb_cls = cb_cls;
-      arm_service_shutdown (h->client, timeout, &arm_shutdown_callback,
-                           arm_shutdown_ctx);
-      h->client = NULL;
+      cb (cb_cls, GNUNET_SYSERR);
       return;
     }
+    h->client = client;
+  }
+  if (0 == strcasecmp ("arm", service_name))
+  {
+    arm_shutdown_ctx = GNUNET_malloc (sizeof (struct ARM_ShutdownContext));
+    arm_shutdown_ctx->cb = cb;
+    arm_shutdown_ctx->cb_cls = cb_cls;
+    arm_service_shutdown (h->client, timeout, &arm_shutdown_callback,
+                         arm_shutdown_ctx);
+    h->client = NULL;
+    return;
+  }
   change_service (h, service_name, timeout, cb, cb_cls,
                  GNUNET_MESSAGE_TYPE_ARM_STOP);
 }
@@ -728,9 +680,8 @@ handle_list_response (void *cls, const struct GNUNET_MessageHeader *msg)
   
   if (NULL == msg)
   {
-    LOG (GNUNET_ERROR_TYPE_WARNING,
-        "Error receiving response to LIST request from ARM\n");
-    GNUNET_CLIENT_disconnect (sc->h->client, GNUNET_NO);
+    GNUNET_break (0);
+    GNUNET_CLIENT_disconnect (sc->h->client);
     sc->h->client = GNUNET_CLIENT_connect ("arm", sc->h->cfg);
     GNUNET_assert (NULL != sc->h->client);
     if (sc->callback != NULL)
@@ -799,21 +750,18 @@ GNUNET_ARM_list_running_services (struct GNUNET_ARM_Handle *h,
   struct GNUNET_MessageHeader msg;
   struct GNUNET_CLIENT_Connection *client;
   
-    if (h->client == NULL)
+  if (h->client == NULL)
+  {
+    client = GNUNET_CLIENT_connect ("arm", h->cfg);
+    if (client == NULL)
     {
-      client = GNUNET_CLIENT_connect ("arm", h->cfg);
-      if (client == NULL)
-        {
-          LOG (GNUNET_ERROR_TYPE_DEBUG,
-               "arm_api, GNUNET_CLIENT_connect returned NULL\n");
-          cb (cb_cls, GNUNET_ARM_PROCESS_COMMUNICATION_ERROR, 0, NULL);
-          return;
-        }
-      LOG (GNUNET_ERROR_TYPE_DEBUG,
-           "arm_api, GNUNET_CLIENT_connect returned non-NULL\n");
-      h->client = client;
+      GNUNET_break (0);
+      cb (cb_cls, GNUNET_ARM_PROCESS_COMMUNICATION_ERROR, 0, NULL);
+      return;
     }
-
+    h->client = client;
+  }
+  
   sctx = GNUNET_malloc (sizeof (struct RequestContext));
   sctx->h = h;
   sctx->callback = cb;
@@ -823,10 +771,10 @@ GNUNET_ARM_list_running_services (struct GNUNET_ARM_Handle *h,
   msg.type = htons (GNUNET_MESSAGE_TYPE_ARM_LIST);
   
   LOG (GNUNET_ERROR_TYPE_DEBUG, 
-       "Requesting LIST from ARM service with timeout: %llu ms\n", 
-       (unsigned long long)timeout.rel_value);
+       "Requesting LIST from ARM service with timeout: %s\n", 
+       GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_YES));
   
-    if (GNUNET_OK !=
+  if (GNUNET_OK !=
       GNUNET_CLIENT_transmit_and_get_response (sctx->h->client, 
                                                &msg,
                                                GNUNET_TIME_absolute_get_remaining
@@ -834,14 +782,13 @@ GNUNET_ARM_list_running_services (struct GNUNET_ARM_Handle *h,
                                                GNUNET_YES,
                                                &handle_list_response, 
                                                sctx))
-    {
-      LOG (GNUNET_ERROR_TYPE_WARNING, 
-           "Error while trying to transmit request to list services to ARM\n");
-      if (cb != NULL)
-        cb (cb_cls, GNUNET_SYSERR, 0, NULL);
-      GNUNET_free (sctx);
-      return;
-    }
+  {
+    GNUNET_break (0);
+    if (cb != NULL)
+      cb (cb_cls, GNUNET_SYSERR, 0, NULL);
+    GNUNET_free (sctx);
+    return;
+  }
 }
 
 /* end of arm_api.c */