From: Christian Grothoff Date: Tue, 11 May 2010 19:40:39 +0000 (+0000) Subject: die unstoppable multi api, die X-Git-Tag: initial-import-from-subversion-38251~21742 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5882a0a99902e4555f78a05a3d68dc72f864437f;p=oweals%2Fgnunet.git die unstoppable multi api, die --- diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c index cd4343dbd..45a38ea9b 100644 --- a/src/arm/arm_api.c +++ b/src/arm/arm_api.c @@ -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 */ diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c index 6b8387461..676bbb29c 100644 --- a/src/core/test_core_api.c +++ b/src/core/test_core_api.c @@ -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); diff --git a/src/core/test_core_api_start_only.c b/src/core/test_core_api_start_only.c index f33597836..a655d0b51 100644 --- a/src/core/test_core_api_start_only.c +++ b/src/core/test_core_api_start_only.c @@ -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 diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c index 1c50dabee..c8b4f2e91 100644 --- a/src/datastore/datastore_api.c +++ b/src/datastore/datastore_api.c @@ -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; diff --git a/src/hostlist/test_gnunet_daemon_hostlist.c b/src/hostlist/test_gnunet_daemon_hostlist.c index 3e179e5d9..a70caa986 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist.c +++ b/src/hostlist/test_gnunet_daemon_hostlist.c @@ -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); } diff --git a/src/hostlist/test_gnunet_daemon_hostlist.conf b/src/hostlist/test_gnunet_daemon_hostlist.conf index eedb1cd42..9541f6de5 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist.conf +++ b/src/hostlist/test_gnunet_daemon_hostlist.conf @@ -16,6 +16,7 @@ PLUGINS = tcp [arm] PORT = 12466 +DEFAULTSERVICES = hostlist #GLOBAL_PREFIX = xterm -e valgrind --tool=memcheck [statistics] diff --git a/src/include/gnunet_arm_service.h b/src/include/gnunet_arm_service.h index 8e68cd5ee..07722c97f 100644 --- a/src/include/gnunet_arm_service.h +++ b/src/include/gnunet_arm_service.h @@ -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 */ { diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index a392b65fb..aaea7162c 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c @@ -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;