die unstoppable multi api, die
authorChristian Grothoff <christian@grothoff.org>
Tue, 11 May 2010 19:40:39 +0000 (19:40 +0000)
committerChristian Grothoff <christian@grothoff.org>
Tue, 11 May 2010 19:40:39 +0000 (19:40 +0000)
src/arm/arm_api.c
src/core/test_core_api.c
src/core/test_core_api_start_only.c
src/datastore/datastore_api.c
src/hostlist/test_gnunet_daemon_hostlist.c
src/hostlist/test_gnunet_daemon_hostlist.conf
src/include/gnunet_arm_service.h
src/transport/transport_api.c

index cd4343dbd09466899585e6d03e3035a6cb8312b3..45a38ea9bcb4350ea61853af25f7607277d39ead 100644 (file)
@@ -706,171 +706,4 @@ GNUNET_ARM_stop_service (struct GNUNET_ARM_Handle *h,
 }
 
 
-/**
- * Function to call for each service.
- *
- * @param h handle to ARM
- * @param service_name name of the service
- * @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
- */
-typedef void (*ServiceOperation) (struct GNUNET_ARM_Handle *h,
-                                 const char *service_name,
-                                 struct GNUNET_TIME_Relative timeout,
-                                 GNUNET_ARM_Callback cb, void *cb_cls);
-
-
-/**
- * Context for starting or stopping multiple services.
- */
-struct MultiContext
-{
-  /**
-   * NULL-terminated array of services to start or stop.
-   */
-  char **services;
-
-  /**
-   * Our handle to ARM.
-   */
-  struct GNUNET_ARM_Handle *h;
-
-  /**
-   * Identifies the operation (start or stop).
-   */
-  ServiceOperation op;
-
-  /**
-   * Current position in "services".
-   */
-  unsigned int pos;
-};
-
-
-/**
- * Run the operation for the next service in the multi-service
- * request.
- *
- * @param cls the "struct MultiContext" that is being processed
- * @param success status of the previous operation (ignored)
- */
-static void
-next_operation (void *cls,
-               int success)
-{
-  struct MultiContext *mc = cls;
-  char *pos;
-
-  if (NULL == (pos = mc->services[mc->pos]))
-    {
-      GNUNET_free (mc->services);
-      GNUNET_ARM_disconnect (mc->h);
-      GNUNET_free (mc);
-      return;
-    }
-  mc->pos++;
-  mc->op (mc->h, pos, MULTI_TIMEOUT, &next_operation, mc);
-  GNUNET_free (pos);
-}
-
-
-/**
- * Run a multi-service request.
- *
- * @param cfg configuration to use (needed to contact ARM;
- *        the ARM service may internally use a different
- *        configuration to determine how to start the service).
- * @param sched scheduler to use
- * @param op the operation to perform for each service
- * @param va NULL-terminated list of services
- */
-static void
-run_multi_request (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                  struct GNUNET_SCHEDULER_Handle *sched,
-                  ServiceOperation op,
-                  va_list va)
-{
-  va_list cp;
-  unsigned int total;
-  struct MultiContext *mc;
-  struct GNUNET_ARM_Handle *h;
-  const char *c;
-
-  h = GNUNET_ARM_connect (cfg, sched, NULL);
-  if (NULL == h)
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                 _("Error while trying to transmit to ARM service\n"));
-      return;
-    }
-  total = 1;
-  va_copy (cp, va);
-  while (NULL != (va_arg (cp, const char*))) total++;
-  va_end (cp);
-  mc = GNUNET_malloc (sizeof(struct MultiContext));
-  mc->services = GNUNET_malloc (total * sizeof (char*));
-  mc->h = h;
-  mc->op = op;
-  total = 0;
-  va_copy (cp, va);
-  while (NULL != (c = va_arg (cp, const char*)))
-    mc->services[total++] = GNUNET_strdup (c);
-  va_end (cp);
-  next_operation (mc, GNUNET_YES);
-}
-
-
-/**
- * Start multiple services in the specified order.  Convenience
- * function.  Works asynchronously, failures are not reported.
- *
- * @param cfg configuration to use (needed to contact ARM;
- *        the ARM service may internally use a different
- *        configuration to determine how to start the service).
- * @param sched scheduler to use
- * @param ... NULL-terminated list of service names (const char*)
- */
-void
-GNUNET_ARM_start_services (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                          struct GNUNET_SCHEDULER_Handle *sched,
-                          ...)
-{
-  va_list ap;
-
-  va_start (ap, sched);
-  run_multi_request (cfg, sched, &GNUNET_ARM_start_service, ap);
-  va_end (ap);
-}
-
-
-/**
- * Stop multiple services in the specified order.  Convenience
- * function.  Works asynchronously, failures are not reported.
- * Should normally only be called from gnunet-arm or testcases,
- * stopping a service is generally otherwise a bad idea.
- *
- * @param cfg configuration to use (needed to contact ARM;
- *        the ARM service may internally use a different
- *        configuration to determine how to start the service).
- * @param sched scheduler to use
- * @param ... NULL-terminated list of service names (const char*)
- */
-void
-GNUNET_ARM_stop_services (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                         struct GNUNET_SCHEDULER_Handle *sched,
-                         ...)
-{
-  va_list ap;
-
-  va_start (ap, sched);
-  run_multi_request (cfg, sched, &GNUNET_ARM_stop_service, ap);
-  va_end (ap);
-}
-
-
-
-
-
-
 /* end of arm_api.c */
index 6b838746114b548da6a5845bdc2675f3defa1b4f..676bbb29c9f71ae501b975f5f87bfd3d641b6fb1 100644 (file)
@@ -82,8 +82,6 @@ terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   GNUNET_CORE_disconnect (p2.ch);
   GNUNET_TRANSPORT_disconnect (p1.th);
   GNUNET_TRANSPORT_disconnect (p2.th);
-  GNUNET_ARM_stop_services (p1.cfg, sched, "core", NULL);
-  GNUNET_ARM_stop_services (p2.cfg, sched, "core", NULL);
   ok = 0;
 }
 
@@ -99,8 +97,6 @@ terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   GNUNET_CORE_disconnect (p2.ch);
   GNUNET_TRANSPORT_disconnect (p1.th);
   GNUNET_TRANSPORT_disconnect (p2.th);
-  GNUNET_ARM_stop_services (p1.cfg, sched, "core", NULL);
-  GNUNET_ARM_stop_services (p2.cfg, sched, "core", NULL);
   ok = 42;
 }
 
@@ -300,7 +296,6 @@ setup_peer (struct PeerContext *p, const char *cfgname)
                                         "-c", cfgname, NULL);
 #endif
   GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
-  GNUNET_ARM_start_services (p->cfg, sched, "core", NULL);
   p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, p, NULL, NULL, NULL);
   GNUNET_assert (p->th != NULL);
   GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
index f335978364647556f0011ca53d508096f68720bd..a655d0b51778f0bae95fe8d0b2faa8c48960b985 100644 (file)
@@ -31,7 +31,7 @@
 #include "gnunet_program_lib.h"
 #include "gnunet_scheduler_lib.h"
 
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
 
 #define START_ARM GNUNET_YES
 
@@ -142,9 +142,6 @@ init_notify (void *cls,
       GNUNET_assert (cls == &p2);
       GNUNET_CORE_disconnect (p1.ch);
       GNUNET_CORE_disconnect (p2.ch);
-      GNUNET_ARM_stop_services (p1.cfg, sched, "core", NULL);
-      GNUNET_ARM_stop_services (p2.cfg, sched, "core", NULL);
-
       ok = 0;
     }
 }
@@ -163,7 +160,6 @@ setup_peer (struct PeerContext *p, const char *cfgname)
                                         "-c", cfgname, NULL);
 #endif
   GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
-  GNUNET_ARM_start_services (p->cfg, sched, "core", NULL);
 }
 
 
@@ -209,7 +205,7 @@ stop_arm (struct PeerContext *p)
 static int
 check ()
 {
-  char *const argv[] = { "test-core-api",
+  char *const argv[] = { "test-core-api-start-only",
     "-c",
     "test_core_api_data.conf",
 #if VERBOSE
@@ -223,7 +219,7 @@ check ()
 
   ok = 1;
   GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
-                      argv, "test-core-api", "nohelp", options, &run, &ok);
+                      argv, "test-core-api-start-only", "nohelp", options, &run, &ok);
   stop_arm (&p1);
   stop_arm (&p2);
   return ok;
@@ -234,7 +230,7 @@ main (int argc, char *argv[])
 {
   int ret;
 
-  GNUNET_log_setup ("test-core-api",
+  GNUNET_log_setup ("test-core-api-start-only",
 #if VERBOSE
                     "DEBUG",
 #else
index 1c50dabee705ed476e7a1993bba742faa81d0a0a..c8b4f2e915e2d9b1f2adc5b0911b21d0d55c3a9c 100644 (file)
@@ -97,7 +97,6 @@ struct GNUNET_DATASTORE_Handle *GNUNET_DATASTORE_connect (const struct
   c = GNUNET_CLIENT_connect (sched, "datastore", cfg);
   if (c == NULL)
     return NULL; /* oops */
-  GNUNET_ARM_start_services (cfg, sched, "datastore", NULL);
   h = GNUNET_malloc (sizeof(struct GNUNET_DATASTORE_Handle) + 
                     GNUNET_SERVER_MAX_MESSAGE_SIZE);
   h->client = c;
index 3e179e5d979eb678a771ed53f893904d30f9bfb2..a70caa986a0601f16ce2f90924b4adb76c980f87 100644 (file)
@@ -127,7 +127,6 @@ process_hello (void *cls,
   GNUNET_TRANSPORT_get_hello_cancel (p->th, &process_hello, p);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Received HELLO, starting hostlist service.\n");
-  GNUNET_ARM_start_services (p->cfg, sched, "hostlist", NULL);
 }
 
 
index eedb1cd425f38bcb91975365bd35d224c106e348..9541f6de56ddb6b809301892df568a0607a231fa 100644 (file)
@@ -16,6 +16,7 @@ PLUGINS = tcp
 
 [arm]
 PORT = 12466
+DEFAULTSERVICES = hostlist
 #GLOBAL_PREFIX = xterm -e valgrind --tool=memcheck
 
 [statistics]
index 8e68cd5ee2fdcf796029710daba45d44def41448..07722c97fae53f5206379ccfcb466736e2ee8121 100644 (file)
@@ -132,37 +132,6 @@ GNUNET_ARM_stop_service (struct GNUNET_ARM_Handle *h,
                          GNUNET_ARM_Callback cb, void *cb_cls);
 
 
-/**
- * Start multiple services in the specified order.  Convenience
- * function.  Works asynchronously, failures are not reported.
- *
- * @param cfg configuration to use (needed to contact ARM;
- *        the ARM service may internally use a different
- *        configuration to determine how to start the service).
- * @param sched scheduler to use
- * @param ... NULL-terminated list of service names (const char*)
- */
-void
-GNUNET_ARM_start_services (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                          struct GNUNET_SCHEDULER_Handle *sched,
-                          ...);
-
-
-/**
- * Stop multiple services in the specified order.  Convenience
- * function.  Works asynchronously, failures are not reported.
- *
- * @param cfg configuration to use (needed to contact ARM;
- *        the ARM service may internally use a different
- *        configuration to determine how to start the service).
- * @param sched scheduler to use
- * @param ... NULL-terminated list of service names (const char*)
- */
-void
-GNUNET_ARM_stop_services (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                         struct GNUNET_SCHEDULER_Handle *sched,
-                         ...);
-
 
 #if 0                           /* keep Emacsens' auto-indent happy */
 {
index a392b65fb104dfb084073de3db3a7e1a9b946665..aaea7162cef4b0f5743985f2f9587c43970c32a8 100644 (file)
@@ -1278,7 +1278,6 @@ GNUNET_TRANSPORT_connect (struct GNUNET_SCHEDULER_Handle *sched,
 {
   struct GNUNET_TRANSPORT_Handle *ret;
 
-  GNUNET_ARM_start_services (cfg, sched, "peerinfo", "transport", NULL);
   ret = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_Handle));
   ret->sched = sched;
   ret->cfg = cfg;