Smallers steps to keep plugin running
[oweals/gnunet.git] / src / arm / arm_api.c
index 45a38ea9bcb4350ea61853af25f7607277d39ead..66747a624acde3d7190926e1044ad00df255301d 100644 (file)
@@ -1,10 +1,10 @@
 /*
      This file is part of GNUnet.
-     (C) 2009 Christian Grothoff (and other contributing authors)
+     (C) 2009, 2010 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 2, or (at your
+     by the Free Software Foundation; either version 3, or (at your
      option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
 #include "arm.h"
 
 
-/**
- * How long are we willing to wait for a service operation during the multi-operation
- * request processing?
- */
-#define MULTI_TIMEOUT  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
-
-
 /**
  * Handle for interacting with ARM.
  */
@@ -134,8 +127,10 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg)
     }
   else if ((msg == NULL) && (shutdown_ctx->confirmed == GNUNET_YES))
     {
+#if DEBUG_ARM
       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
                 "Service shutdown complete.\n");
+#endif
       if (shutdown_ctx->cont != NULL)
         shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_NO);
 
@@ -149,8 +144,10 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg)
       switch (ntohs(msg->type))
        {
        case GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN_ACK:
+#if DEBUG_ARM
          GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
                     "Received confirmation for service shutdown.\n");
+#endif
          shutdown_ctx->confirmed = GNUNET_YES;
          GNUNET_CLIENT_receive (shutdown_ctx->sock,
                                 &service_shutdown_handler,
@@ -158,8 +155,10 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg)
                                 GNUNET_TIME_UNIT_FOREVER_REL);
          break;
        default: /* Fall through */
+#if DEBUG_ARM
          GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
                     "Service shutdown refused!\n");
+#endif
          if (shutdown_ctx->cont != NULL)
            shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_YES);
 
@@ -259,7 +258,7 @@ arm_service_shutdown (struct GNUNET_SCHEDULER_Handle *sched,
                                       sizeof (struct
                                               GNUNET_MessageHeader),
                                       timeout,
-                                      GNUNET_NO,
+                                      GNUNET_YES,
                                       &write_shutdown, shutdown_ctx);
 }
 
@@ -435,15 +434,42 @@ arm_service_report (void *cls,
       GNUNET_free (lopostfix);
       return;
     }
-  pid = do_start_process (loprefix,
-                         binary,
-                         "-c", config,
+  if ((GNUNET_YES == GNUNET_CONFIGURATION_have_value (pos->h->cfg,
+                                                      "TESTING",
+                                                      "WEAKRANDOM")) &&
+      (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (pos->h->cfg,
+                                                           "TESTING",
+                                                           "WEAKRANDOM")) &&
+      (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 */
+      pid = do_start_process (NULL,
+                             loprefix,
+                             binary,
+                             "-c", config,
+#if DEBUG_ARM
+                             "-L", "DEBUG",
+#endif
+                             /* no daemonization! */
+                             lopostfix,
+                             NULL);
+    }
+  else
+    {
+      pid = do_start_process (NULL,
+                             loprefix,
+                             binary,
+                             "-c", config,
 #if DEBUG_ARM
-                         "-L", "DEBUG",
+                             "-L", "DEBUG",
 #endif
-                         "-d",
-                         lopostfix,
-                         NULL);
+                             "-d",
+                             lopostfix,
+                             NULL);
+    }
   GNUNET_free (binary);
   GNUNET_free (config);
   GNUNET_free (loprefix);
@@ -541,8 +567,7 @@ change_service (struct GNUNET_ARM_Handle *h,
   struct GNUNET_MessageHeader *msg;
 
   slen = strlen (service_name) + 1;
-  if (slen + sizeof (struct GNUNET_MessageHeader) >
-      GNUNET_SERVER_MAX_MESSAGE_SIZE)
+  if (slen + sizeof (struct GNUNET_MessageHeader) >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
     {
       GNUNET_break (0);
       if (cb != NULL)