/**
- * Attempts to delete configuration file and SERVICEHOME
+ * Attempts to delete configuration file and GNUNET_HOME
* on ARM shutdown provided the end and delete options
* were specified when gnunet-arm was run.
*/
"Will attempt to remove configuration file %s and service directory %s\n",
config_file, dir);
- if (UNLINK (config_file) != 0)
+ if (0 != UNLINK (config_file))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Failed to remove configuration file %s\n"), config_file);
+ _("Failed to remove configuration file %s\n"),
+ config_file);
}
- if (GNUNET_DISK_directory_remove (dir) != GNUNET_OK)
+ if (GNUNET_OK != GNUNET_DISK_directory_remove (dir))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Failed to remove servicehome directory %s\n"), dir);
-
+ _("Failed to remove servicehome directory %s\n"),
+ dir);
+
}
}
GNUNET_ARM_monitor_disconnect_and_free (m);
m = NULL;
}
- if ((end == GNUNET_YES) && (delete == GNUNET_YES))
- delete_files ();
+ if ((GNUNET_YES == end) && (GNUNET_YES == delete))
+ delete_files ();
GNUNET_CONFIGURATION_destroy (cfg);
cfg = NULL;
}
* @param cls closure
* @param tc scheudler context
*/
-static void
+static void
action_loop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
* GNUNET_SYSERR on error.
*/
static void
-conn_status (void *cls,
+conn_status (void *cls,
int connected)
{
static int once;
-
+
if ( (GNUNET_SYSERR == connected) &&
(0 == once) )
{
GNUNET_free (msg);
GNUNET_SCHEDULER_shutdown ();
return;
- }
+ }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM service [re]start successful\n");
start = 0;
GNUNET_SCHEDULER_add_now (action_loop, NULL);
* according to ARM
*/
static void
-stop_callback (void *cls,
+stop_callback (void *cls,
enum GNUNET_ARM_RequestStatus rs, const char *service,
enum GNUNET_ARM_Result result)
{
if (GNUNET_ARM_REQUEST_SENT_OK != rs)
{
- GNUNET_asprintf (&msg, "%s",
+ GNUNET_asprintf (&msg, "%s",
_("Failed to send a stop request to the ARM service: %s\n"));
FPRINTF (stdout, msg, req_string (rs));
GNUNET_free (msg);
GNUNET_SCHEDULER_shutdown ();
return;
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"ARM service shutdown successful\n");
end = 0;
if (restart)
{
restart = 0;
start = 1;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Initiating an ARM restart\n");
}
GNUNET_SCHEDULER_add_now (&action_loop, NULL);
* according to ARM
*/
static void
-init_callback (void *cls,
+init_callback (void *cls,
enum GNUNET_ARM_RequestStatus rs, const char *service,
enum GNUNET_ARM_Result result)
{
char *msg;
-
+
if (GNUNET_ARM_REQUEST_SENT_OK != rs)
{
- GNUNET_asprintf (&msg, _("Failed to send a request to start the `%s' service: %%s\n"), init);
+ GNUNET_asprintf (&msg,
+ _("Failed to send a request to start the `%s' service: %%s\n"),
+ init);
FPRINTF (stdout, msg, req_string (rs));
GNUNET_free (msg);
GNUNET_SCHEDULER_shutdown ();
GNUNET_SCHEDULER_shutdown ();
return;
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Service %s [re]started successfully\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Service %s [re]started successfully\n",
init);
+ GNUNET_free (init);
init = NULL;
GNUNET_SCHEDULER_add_now (&action_loop, NULL);
}
* according to ARM
*/
static void
-term_callback (void *cls,
+term_callback (void *cls,
enum GNUNET_ARM_RequestStatus rs, const char *service,
enum GNUNET_ARM_Result result)
{
if ((GNUNET_ARM_RESULT_STOPPED != result) &&
(GNUNET_ARM_RESULT_IS_STOPPED_ALREADY != result))
{
- GNUNET_asprintf (&msg,
+ GNUNET_asprintf (&msg,
_("Failed to kill the `%s' service: %s\n"),
term, ret_string (result));
FPRINTF (stdout, msg, service);
return;
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Service %s stopped successfully\n", term);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Service %s stopped successfully\n",
+ term);
+ GNUNET_free (term);
term = NULL;
GNUNET_SCHEDULER_add_now (&action_loop, NULL);
}
* @param list list of services that are running
*/
static void
-list_callback (void *cls,
+list_callback (void *cls,
enum GNUNET_ARM_RequestStatus rs, unsigned int count,
const char *const*list)
{
GNUNET_asprintf (&msg, "%s", _("Failed to request a list of services: %s\n"));
FPRINTF (stdout, msg, req_string (rs));
GNUNET_free (msg);
+ ret = 3;
GNUNET_SCHEDULER_shutdown ();
}
if (NULL == list)
{
FPRINTF (stderr, "%s", _("Error communicating with ARM. ARM not running?\n"));
GNUNET_SCHEDULER_shutdown ();
+ ret = 3;
return;
}
FPRINTF (stdout, "%s", _("Running services:\n"));
if (NULL != term)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Termination action\n");
- GNUNET_ARM_request_service_stop (h, term,
+ GNUNET_ARM_request_service_stop (h, term,
(0 == timeout.rel_value_us) ? STOP_TIMEOUT : timeout,
&term_callback, NULL);
return;
if (end || restart)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "End action\n");
- GNUNET_ARM_request_service_stop (h, "arm",
+ GNUNET_ARM_request_service_stop (h, "arm",
(0 == timeout.rel_value_us) ? STOP_TIMEOUT_ARM : timeout,
&stop_callback, NULL);
return;
}
break;
case 4:
- if (list)
+ if (list)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Going to list all running services controlled by ARM.\n");
+ "Going to list all running services controlled by ARM.\n");
GNUNET_ARM_request_service_list (h,
(0 == timeout.rel_value_us) ? LIST_TIMEOUT : timeout,
&list_callback, &list);
return;
- }
+ }
break;
case 5:
- if (monitor)
+ if (monitor)
{
if (! quiet)
fprintf (stderr,
* @param status status of the service
*/
static void
-srv_status (void *cls,
+srv_status (void *cls,
const char *service, enum GNUNET_ARM_ServiceStatus status)
{
const char *msg;
* @param c configuration
*/
static void
-run (void *cls,
- char *const *args,
+run (void *cls,
+ char *const *args,
const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *c)
{
cfg = GNUNET_CONFIGURATION_dup (c);
config_file = cfgfile;
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "SERVICEHOME", &dir))
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "GNUNET_HOME", &dir))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- "PATHS", "SERVICEHOME");
+ "PATHS", "GNUNET_HOME");
return;
}
if (NULL != cfgfile)