summaryrefslogtreecommitdiff
path: root/src/arm
diff options
context:
space:
mode:
Diffstat (limited to 'src/arm')
-rw-r--r--src/arm/arm.conf.in4
-rw-r--r--src/arm/gnunet-service-arm.c91
-rw-r--r--src/arm/test_arm_api_data.conf17
-rw-r--r--src/arm/test_gnunet_service_arm.c97
4 files changed, 117 insertions, 92 deletions
diff --git a/src/arm/arm.conf.in b/src/arm/arm.conf.in
index 83582659a..53731586b 100644
--- a/src/arm/arm.conf.in
+++ b/src/arm/arm.conf.in
@@ -1,11 +1,13 @@
-
[arm]
@UNIXONLY@ PORT = 2087
HOSTNAME = localhost
BINARY = gnunet-service-arm
ACCEPT_FROM = 127.0.0.1;
ACCEPT_FROM6 = ::1;
+
+
DEFAULTSERVICES = topology hostlist dht nse cadet fs revocation
+
# Special case, uses user runtime dir even for per-system service.
UNIXPATH = $GNUNET_USER_RUNTIME_DIR/gnunet-service-arm.sock
UNIX_MATCH_UID = YES
diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c
index 1249fe003..c6259c273 100644
--- a/src/arm/gnunet-service-arm.c
+++ b/src/arm/gnunet-service-arm.c
@@ -163,7 +163,7 @@ struct ServiceList
* to start it)? #GNUNET_NO if the service is started only upon 'accept' on a
* listen socket or possibly explicitly by a client changing the value.
*/
- int is_default;
+ int force_start;
/**
* Should we use pipes to signal this process? (YES for Java binaries and if we
@@ -669,7 +669,7 @@ create_listen_socket (struct sockaddr *sa, socklen_t addr_len,
#ifdef LINUX
/* Permission settings are not required when abstract sockets are used */
&& ('\0' != ((const struct sockaddr_un *)sa)->sun_path[0])
-#endif
+#endif
)
{
match_uid =
@@ -735,7 +735,8 @@ free_service (struct ServiceList *sl)
* #GNUNET_SYSERR to close it (signal serious error)
*/
static void
-handle_start (void *cls, struct GNUNET_SERVER_Client *client,
+handle_start (void *cls,
+ struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
const char *servicename;
@@ -770,7 +771,7 @@ handle_start (void *cls, struct GNUNET_SERVER_Client *client,
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
- sl->is_default = GNUNET_YES;
+ sl->force_start = GNUNET_YES;
if (NULL != sl->proc)
{
signal_result (client, servicename, request_id,
@@ -790,9 +791,11 @@ handle_start (void *cls, struct GNUNET_SERVER_Client *client,
* @param tc task context
*/
static void
-trigger_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+trigger_shutdown (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Triggering shutdown\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Triggering shutdown\n");
GNUNET_SCHEDULER_shutdown ();
}
@@ -807,7 +810,8 @@ trigger_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
* #GNUNET_SYSERR to close it (signal serious error)
*/
static void
-handle_stop (void *cls, struct GNUNET_SERVER_Client *client,
+handle_stop (void *cls,
+ struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
struct ServiceList *sl;
@@ -846,7 +850,7 @@ handle_stop (void *cls, struct GNUNET_SERVER_Client *client,
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
- sl->is_default = GNUNET_NO;
+ sl->force_start = GNUNET_NO;
if (GNUNET_YES == in_shutdown)
{
/* shutdown in progress */
@@ -1002,7 +1006,8 @@ list_count (struct ServiceList *running_head)
* @param tc context
*/
static void
-shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+shutdown_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct ServiceList *pos;
struct ServiceList *nxt;
@@ -1093,11 +1098,12 @@ delayed_restart_task (void *cls,
if (0 == GNUNET_TIME_absolute_get_remaining (sl->restart_at).rel_value_us)
{
/* restart is now allowed */
- if (sl->is_default)
+ if (sl->force_start)
{
/* process should run by default, start immediately */
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("Restarting service `%s'.\n"), sl->name);
+ _("Restarting service `%s'.\n"),
+ sl->name);
start_process (sl, NULL, 0);
}
else
@@ -1377,9 +1383,18 @@ setup_service (void *cls, const char *section)
#endif
GNUNET_CONTAINER_DLL_insert (running_head, running_tail, sl);
- if (GNUNET_YES !=
- GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "AUTOSTART"))
+ if (GNUNET_YES ==
+ GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "FORCESTART"))
+ {
+ sl->force_start = GNUNET_YES;
return;
+ }
+ else
+ {
+ if (GNUNET_YES !=
+ GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "AUTOSTART"))
+ return;
+ }
if (0 >= (ret = GNUNET_SERVICE_get_server_addresses (section, cfg,
&addrs, &addr_lens)))
return;
@@ -1451,8 +1466,6 @@ run (void *cls, struct GNUNET_SERVER_Handle *serv,
sizeof (struct GNUNET_ARM_Message)},
{NULL, NULL, 0, 0}
};
- char *defaultservices;
- const char *pos;
struct ServiceList *sl;
cfg = c;
@@ -1490,45 +1503,17 @@ run (void *cls, struct GNUNET_SERVER_Handle *serv,
GNUNET_CONFIGURATION_iterate_sections (cfg, &setup_service, NULL);
/* start default services... */
- if (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_string (cfg,
- "ARM",
- "DEFAULTSERVICES",
- &defaultservices))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("Starting default services `%s'\n"),
- defaultservices);
- if (0 < strlen (defaultservices))
- {
- for (pos = strtok (defaultservices, " "); NULL != pos;
- pos = strtok (NULL, " "))
- {
- sl = find_service (pos);
- if (NULL == sl)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Default service `%s' not configured correctly!\n"),
- pos);
- continue;
- }
- sl->is_default = GNUNET_YES;
- start_process (sl, NULL, 0);
- }
- }
- GNUNET_free (defaultservices);
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("No default services configured, GNUnet will not really start right now.\n"));
- }
-
- notifier =
- GNUNET_SERVER_notification_context_create (server, MAX_NOTIFY_QUEUE);
- GNUNET_SERVER_connect_notify (server, handle_client_connecting, NULL);
+ for (sl = running_head; NULL != sl; sl = sl->next)
+ if (GNUNET_YES == sl->force_start)
+ start_process (sl, NULL, 0);
+ notifier
+ = GNUNET_SERVER_notification_context_create (server,
+ MAX_NOTIFY_QUEUE);
+ GNUNET_SERVER_connect_notify (server,
+ &handle_client_connecting, NULL);
/* process client requests */
- GNUNET_SERVER_add_handlers (server, handlers);
+ GNUNET_SERVER_add_handlers (server,
+ handlers);
}
diff --git a/src/arm/test_arm_api_data.conf b/src/arm/test_arm_api_data.conf
index d8354477e..3ae5271a1 100644
--- a/src/arm/test_arm_api_data.conf
+++ b/src/arm/test_arm_api_data.conf
@@ -3,7 +3,6 @@ GNUNET_TEST_HOME = /tmp/test-gnunetd-arm/
[arm]
PORT = 23354
-DEFAULTSERVICES =
BINARY = gnunet-service-arm
OPTIONS = -L ERROR
#PREFIX = valgrind --tool=memcheck --leak-check=yes
@@ -22,6 +21,7 @@ ACCEPT_FROM6 = ::1;
[fs]
AUTOSTART = NO
+FORCESTART = NO
[datastore]
AUTOSTART = NO
@@ -46,5 +46,20 @@ AUTOSTART = NO
[nse]
AUTOSTART = NO
+FORCESTART = NO
+[hostlist]
+AUTOSTART = NO
+FORCESTART = NO
+
+[dht]
+AUTOSTART = NO
+FORCESTART = NO
+[cadet]
+AUTOSTART = NO
+FORCESTART = NO
+
+[revocation]
+AUTOSTART = NO
+FORCESTART = NO
diff --git a/src/arm/test_gnunet_service_arm.c b/src/arm/test_gnunet_service_arm.c
index 5c08293a4..77b6f36dd 100644
--- a/src/arm/test_gnunet_service_arm.c
+++ b/src/arm/test_gnunet_service_arm.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2009 Christian Grothoff (and other contributing authors)
+ (C) 2009, 2014 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
@@ -40,14 +40,16 @@
static int ret = 1;
-static int resolved_ok = 0;
+static int resolved_ok;
-static int asked_for_a_list = 0;
+static int asked_for_a_list;
static struct GNUNET_ARM_Handle *arm;
+
static void
-trigger_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+trigger_disconnect (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
GNUNET_ARM_disconnect_and_free (arm);
arm = NULL;
@@ -71,40 +73,52 @@ arm_stop_cb (void *cls,
static void
service_list (void *cls,
enum GNUNET_ARM_RequestStatus rs,
- unsigned int count, const char *const*list)
+ unsigned int count,
+ const char *const*list)
{
+ unsigned int i;
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"%u services are are currently running\n",
count);
if (GNUNET_ARM_REQUEST_SENT_OK != rs)
goto stop_arm;
- if (1 == count)
+ for (i=0;i<count;i++)
{
- GNUNET_break (0 == strcasecmp (list[0], "resolver (gnunet-service-resolver)"));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got service list, now stopping arm\n");
- ret = 0;
+ if (0 == strcasecmp (list[i],
+ "resolver (gnunet-service-resolver)"));
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Got service list, now stopping arm\n");
+ ret = 0;
+ }
}
stop_arm:
- GNUNET_ARM_request_service_stop (arm, "arm", TIMEOUT, arm_stop_cb, NULL);
+ GNUNET_ARM_request_service_stop (arm, "arm", TIMEOUT,
+ &arm_stop_cb, NULL);
}
static void
-hostNameResolveCB (void *cls, const struct sockaddr *addr, socklen_t addrlen)
+hostNameResolveCB (void *cls,
+ const struct sockaddr *addr,
+ socklen_t addrlen)
{
if ((ret == 0) || (ret == 4) || (resolved_ok == 1))
return;
if (NULL == addr)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Name not resolved!\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Name not resolved!\n");
ret = 3;
- GNUNET_ARM_request_service_stop (arm, "arm", TIMEOUT, arm_stop_cb, NULL);
+ GNUNET_ARM_request_service_stop (arm, "arm", TIMEOUT,
+ &arm_stop_cb, NULL);
}
else if (asked_for_a_list == 0)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Resolved hostname, now checking the service list\n");
+ "Resolved hostname, now checking the service list\n");
GNUNET_ARM_request_service_list (arm, TIMEOUT, service_list, NULL);
asked_for_a_list = 1;
resolved_ok = 1;
@@ -121,21 +135,26 @@ arm_start_cb (void *cls,
GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK);
GNUNET_break (result == GNUNET_ARM_RESULT_STARTING);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Trying to resolve our own hostname!\n");
+ "Trying to resolve our own hostname!\n");
/* connect to the resolver service */
- if (NULL == GNUNET_RESOLVER_hostname_resolve (
- AF_UNSPEC, TIMEOUT, &hostNameResolveCB, NULL))
+ if (NULL ==
+ GNUNET_RESOLVER_hostname_resolve (AF_UNSPEC, TIMEOUT,
+ &hostNameResolveCB, NULL))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unable initiate connection to resolver service\n");
ret = 2;
- GNUNET_ARM_request_service_stop (arm, "arm", TIMEOUT, arm_stop_cb, NULL);
+ GNUNET_ARM_request_service_stop (arm,
+ "arm", TIMEOUT,
+ &arm_stop_cb, NULL);
}
}
static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls,
+ char *const *args,
+ const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *c)
{
char *armconfig;
@@ -144,10 +163,10 @@ run (void *cls, char *const *args, const char *cfgfile,
{
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (c, "arm", "CONFIG",
- &armconfig))
+ &armconfig))
{
- GNUNET_CONFIGURATION_set_value_string ((struct GNUNET_CONFIGURATION_Handle
- *) c, "arm", "CONFIG",
+ GNUNET_CONFIGURATION_set_value_string ((struct GNUNET_CONFIGURATION_Handle *) c,
+ "arm", "CONFIG",
cfgfile);
}
else
@@ -155,7 +174,9 @@ run (void *cls, char *const *args, const char *cfgfile,
}
arm = GNUNET_ARM_connect (c, NULL, NULL);
GNUNET_ARM_request_service_start (arm, "arm",
- GNUNET_OS_INHERIT_STD_OUT_AND_ERR, START_TIMEOUT, arm_start_cb, NULL);
+ GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
+ START_TIMEOUT,
+ &arm_start_cb, NULL);
}
@@ -173,27 +194,29 @@ main (int argc, char *av[])
char hostname[GNUNET_OS_get_hostname_max_length () + 1];
if (0 != gethostname (hostname, sizeof (hostname) - 1))
- {
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "gethostname");
- FPRINTF (stderr,
- "%s", "Failed to determine my own hostname, testcase not run.\n");
- return 0;
- }
+ {
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+ "gethostname");
+ FPRINTF (stderr,
+ "%s",
+ "Failed to determine my own hostname, testcase not run.\n");
+ return 0;
+ }
if (NULL == gethostbyname (hostname))
- {
- FPRINTF (stderr,
- "Failed to resolve my hostname `%s', testcase not run.\n",
- hostname);
- return 0;
- }
+ {
+ FPRINTF (stderr,
+ "Failed to resolve my hostname `%s', testcase not run.\n",
+ hostname);
+ return 0;
+ }
GNUNET_log_setup ("test-gnunet-service-arm",
"WARNING",
NULL);
GNUNET_break (GNUNET_OK ==
GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
argv, "test-gnunet-service-arm",
- "nohelp", options, &run, NULL));
+ "nohelp", options,
+ &run, NULL));
return ret;
}