testing.c   testing.c 
skipping to change at line 40 skipping to change at line 40
* *
*/ */
#include "platform.h" #include "platform.h"
#include "gnunet_arm_service.h" #include "gnunet_arm_service.h"
#include "gnunet_core_service.h" #include "gnunet_core_service.h"
#include "gnunet_constants.h" #include "gnunet_constants.h"
#include "gnunet_testing_lib.h" #include "gnunet_testing_lib.h"
#include "gnunet_transport_service.h" #include "gnunet_transport_service.h"
#include "gnunet_hello_lib.h" #include "gnunet_hello_lib.h"
#define DEBUG_TESTING GNUNET_EXTRA_LOGGING
#define DEBUG_TESTING_RECONNECT GNUNET_EXTRA_LOGGING
/** /**
* Hack to deal with initial HELLO's being often devoid of addresses. * Hack to deal with initial HELLO's being often devoid of addresses.
* This hack causes 'process_hello' to ignore HELLOs without addresses. * This hack causes 'process_hello' to ignore HELLOs without addresses.
* The correct implementation would continue with 'process_hello' until * The correct implementation would continue with 'process_hello' until
* the connection could be established... * the connection could be established...
*/ */
#define EMPTY_HACK GNUNET_YES #define EMPTY_HACK GNUNET_YES
/** /**
* How long do we wait after starting gnunet-service-arm * How long do we wait after starting gnunet-service-arm
skipping to change at line 193 skipping to change at line 189
char *dst; char *dst;
int bytes_read; int bytes_read;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %s FSM is in phase %u.\n", GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %s FSM is in phase %u.\n",
GNUNET_i2s (&d->id), d->phase); GNUNET_i2s (&d->id), d->phase);
d->task = GNUNET_SCHEDULER_NO_TASK; d->task = GNUNET_SCHEDULER_NO_TASK;
switch (d->phase) switch (d->phase)
{ {
case SP_COPYING: case SP_COPYING:
/* confirm copying complete */ /* confirm copying complete */
if (GNUNET_OK != GNUNET_OS_process_status (d->proc, &type, &code)) if (GNUNET_OK != GNUNET_OS_process_status (d->proc_arm_copying, &type, &code))
{ {
if (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == 0) if (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == 0)
{ {
cb = d->cb; cb = d->cb;
d->cb = NULL; d->cb = NULL;
if (NULL != cb) if (NULL != cb)
cb (d->cb_cls, NULL, d->cfg, d, cb (d->cb_cls, NULL, d->cfg, d,
_ _
("`scp' does not seem to terminate (timeout copying config).\ n")); ("`scp' does not seem to terminate (timeout copying config).\ n"));
return; return;
skipping to change at line 219 skipping to change at line 215
return; return;
} }
if ((type != GNUNET_OS_PROCESS_EXITED) || (code != 0)) if ((type != GNUNET_OS_PROCESS_EXITED) || (code != 0))
{ {
cb = d->cb; cb = d->cb;
d->cb = NULL; d->cb = NULL;
if (NULL != cb) if (NULL != cb)
cb (d->cb_cls, NULL, d->cfg, d, _("`scp' did not complete cleanly.\ n")); cb (d->cb_cls, NULL, d->cfg, d, _("`scp' did not complete cleanly.\ n"));
return; return;
} }
GNUNET_OS_process_close (d->proc); GNUNET_OS_process_destroy (d->proc_arm_copying);
d->proc_arm_copying = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Successfully copied configuration file.\n"); "Successfully copied configuration file.\n");
d->phase = SP_COPIED; d->phase = SP_COPIED;
/* fall-through */ /* fall-through */
case SP_COPIED: case SP_COPIED:
/* Start create hostkey process if we don't already know the peer ident ity! */ /* Start create hostkey process if we don't already know the peer ident ity! */
if (GNUNET_NO == d->have_hostkey) if (GNUNET_NO == d->have_hostkey)
{ {
GNUNET_assert (NULL == d->proc_arm_peerinfo);
d->pipe_stdout = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO, GNUNET_NO, G NUNET_YES); d->pipe_stdout = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO, GNUNET_NO, G NUNET_YES);
if (d->pipe_stdout == NULL) if (d->pipe_stdout == NULL)
{ {
cb = d->cb; cb = d->cb;
d->cb = NULL; d->cb = NULL;
if (NULL != cb) if (NULL != cb)
cb (d->cb_cls, NULL, d->cfg, d, cb (d->cb_cls, NULL, d->cfg, d,
(NULL == (NULL ==
d->hostname) ? d->hostname) ?
_("Failed to create pipe for `gnunet-peerinfo' process.\n") : _("Failed to create pipe for `gnunet-peerinfo' process.\n") :
_("Failed to create pipe for `ssh' process.\n")); _("Failed to create pipe for `ssh' process.\n"));
return; return;
} }
if (NULL == d->hostname) if (NULL == d->hostname)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting `%s', with command `%s %s %s %s'.\n", "Starting `%s', with command `%s %s %s %s'.\n",
"gnunet-peerinfo", "gnunet-peerinfo", "-c", d->cfgfile, "gnunet-peerinfo", "gnunet-peerinfo", "-c", d->cfgfile,
"-sq"); "-sq");
d->proc = d->proc_arm_peerinfo =
GNUNET_OS_start_process (GNUNET_YES, NULL, d->pipe_stdout, "gnun et-peerinfo", GNUNET_OS_start_process (GNUNET_YES, NULL, d->pipe_stdout, "gnun et-peerinfo",
"gnunet-peerinfo", "-c", d->cfgfile, " -sq", "gnunet-peerinfo", "-c", d->cfgfile, " -sq",
NULL); NULL);
GNUNET_DISK_pipe_close_end (d->pipe_stdout, GNUNET_DISK_PIPE_END_WR ITE); GNUNET_DISK_pipe_close_end (d->pipe_stdout, GNUNET_DISK_PIPE_END_WR ITE);
} }
else else
{ {
if (d->username != NULL) if (d->username != NULL)
GNUNET_asprintf (&dst, "%s@%s", d->username, d->hostname); GNUNET_asprintf (&dst, "%s@%s", d->username, d->hostname);
else else
dst = GNUNET_strdup (d->hostname); dst = GNUNET_strdup (d->hostname);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting `%s', with command `%s %s %s %s %s %s'.\n", "Starting `%s', with command `%s %s %s %s %s %s'.\n",
"gnunet-peerinfo", "ssh", dst, "gnunet-peerinfo", "-c", "gnunet-peerinfo", "ssh", dst, "gnunet-peerinfo", "-c",
d->cfgfile, "-sq"); d->cfgfile, "-sq");
if (d->ssh_port_str == NULL) if (d->ssh_port_str == NULL)
{ {
d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, d->pipe_stdou d->proc_arm_peerinfo = GNUNET_OS_start_process (GNUNET_NO, NULL,
t, "ssh", "ssh", d->pipe_stdout, "ssh", "ssh",
#if !DEBUG_TESTING
"-q", "-q",
#endif
dst, "gnunet-peerinfo", "-c", dst, "gnunet-peerinfo", "-c",
d->cfgfile, "-sq", NULL); d->cfgfile, "-sq", NULL);
} }
else else
{ {
d->proc = d->proc_arm_peerinfo =
GNUNET_OS_start_process (GNUNET_NO, NULL, d->pipe_stdout, "ssh ", "ssh", "-p", GNUNET_OS_start_process (GNUNET_NO, NULL, d->pipe_stdout, "ssh ", "ssh", "-p",
d->ssh_port_str, d->ssh_port_str,
#if !DEBUG_TESTING
"-q", "-q",
#endif
dst, "gnunet-peerinfo", "-c", d->cfg file, dst, "gnunet-peerinfo", "-c", d->cfg file,
"-sq", NULL); "-sq", NULL);
} }
GNUNET_DISK_pipe_close_end (d->pipe_stdout, GNUNET_DISK_PIPE_END_WR ITE); GNUNET_DISK_pipe_close_end (d->pipe_stdout, GNUNET_DISK_PIPE_END_WR ITE);
GNUNET_free (dst); GNUNET_free (dst);
} }
if (NULL == d->proc) if (NULL == d->proc_arm_peerinfo)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Could not start `%s' process to create hostkey.\n"), _("Could not start `%s' process to create hostkey.\n"),
(NULL == d->hostname) ? "gnunet-peerinfo" : "ssh"); (NULL == d->hostname) ? "gnunet-peerinfo" : "ssh");
cb = d->cb; cb = d->cb;
d->cb = NULL; d->cb = NULL;
if (NULL != cb) if (NULL != cb)
cb (d->cb_cls, NULL, d->cfg, d, cb (d->cb_cls, NULL, d->cfg, d,
(NULL == (NULL ==
d->hostname) ? _("Failed to start `gnunet-peerinfo' process. \n") d->hostname) ? _("Failed to start `gnunet-peerinfo' process. \n")
skipping to change at line 367 skipping to change at line 361
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_("Error reading from gnunet-peerinfo: %s\n"), _("Error reading from gnunet-peerinfo: %s\n"),
STRERROR (errno)); STRERROR (errno));
else else
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_("Malformed output from gnunet-peerinfo!\n")); _("Malformed output from gnunet-peerinfo!\n"));
cb = d->cb; cb = d->cb;
d->cb = NULL; d->cb = NULL;
GNUNET_DISK_pipe_close (d->pipe_stdout); GNUNET_DISK_pipe_close (d->pipe_stdout);
d->pipe_stdout = NULL; d->pipe_stdout = NULL;
(void) GNUNET_OS_process_kill (d->proc, SIGKILL); (void) GNUNET_OS_process_kill (d->proc_arm_peerinfo, SIGKILL);
GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (d->proc)); GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (d->proc_arm_peerin
GNUNET_OS_process_close (d->proc); fo));
d->proc = NULL; GNUNET_OS_process_destroy (d->proc_arm_peerinfo);
d->proc_arm_peerinfo = NULL;
if (NULL != cb) if (NULL != cb)
cb (d->cb_cls, NULL, d->cfg, d, _("Failed to get hostkey!\n")); cb (d->cb_cls, NULL, d->cfg, d, _("Failed to get hostkey!\n"));
return; return;
} }
d->shortname = GNUNET_strdup (GNUNET_i2s (&d->id)); d->shortname = GNUNET_strdup (GNUNET_i2s (&d->id));
GNUNET_DISK_pipe_close (d->pipe_stdout); GNUNET_DISK_pipe_close (d->pipe_stdout);
d->pipe_stdout = NULL; d->pipe_stdout = NULL;
(void) GNUNET_OS_process_kill (d->proc, SIGKILL); (void) GNUNET_OS_process_kill (d->proc_arm_peerinfo, SIGKILL);
GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (d->proc)); GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (d->proc_arm_peerinfo
GNUNET_OS_process_close (d->proc); ));
d->proc = NULL; GNUNET_OS_process_destroy (d->proc_arm_peerinfo);
d->proc_arm_peerinfo = NULL;
d->have_hostkey = GNUNET_YES; d->have_hostkey = GNUNET_YES;
if (d->hostkey_callback != NULL) if (d->hostkey_callback != NULL)
{ {
d->hostkey_callback (d->hostkey_cls, &d->id, d, NULL); d->hostkey_callback (d->hostkey_cls, &d->id, d, NULL);
d->hostkey_callback = NULL; d->hostkey_callback = NULL;
d->phase = SP_HOSTKEY_CREATED; d->phase = SP_HOSTKEY_CREATED;
} }
else else
{ {
d->phase = SP_TOPOLOGY_SETUP; d->phase = SP_TOPOLOGY_SETUP;
skipping to change at line 417 skipping to change at line 411
d->task = d->task =
GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fs m, GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fs m,
d); d);
break; break;
case SP_TOPOLOGY_SETUP: /* Indicates topology setup has completed! * / case SP_TOPOLOGY_SETUP: /* Indicates topology setup has completed! * /
/* start GNUnet on remote host */ /* start GNUnet on remote host */
if (NULL == d->hostname) if (NULL == d->hostname)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting `%s', with command `%s %s %s %s %s %s'.\n", "Starting `%s', with command `%s %s %s %s'.\n",
"gnunet-arm", "gnunet-arm", "-c", d->cfgfile, "-L", "DEBU "gnunet-arm", "gnunet-arm", "-c", d->cfgfile,
G",
"-s"); "-s");
d->proc = d->proc_arm_start =
GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-arm", "gn unet-arm", "-c", GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-arm", "gn unet-arm", "-c",
d->cfgfile, d->cfgfile,
"-L", "DEBUG",
"-s", "-q", "-T", "-s", "-q", "-T",
GNUNET_TIME_relative_to_string GNUNET_TIME_relative_to_string
(GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_get_remaining
(d->max_timeout)), NULL); (d->max_timeout)), NULL);
} }
else else
{ {
if (d->username != NULL) if (d->username != NULL)
GNUNET_asprintf (&dst, "%s@%s", d->username, d->hostname); GNUNET_asprintf (&dst, "%s@%s", d->username, d->hostname);
else else
dst = GNUNET_strdup (d->hostname); dst = GNUNET_strdup (d->hostname);
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Starting `%s', with command `%s %s %s %s %s %s %s %s'.\n ", "Starting `%s', with command `%s %s %s %s %s %s %s'.\n",
"gnunet-arm", "ssh", dst, "gnunet-arm", "-c", d->cfgfile, "gnunet-arm", "ssh", dst, "gnunet-arm", "-c", d->cfgfile,
"-L", "DEBUG", "-s", "-q"); "-s", "-q");
if (d->ssh_port_str == NULL) if (d->ssh_port_str == NULL)
{ {
d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "s d->proc_arm_start = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL,
sh", "ssh", "ssh",
#if !DEBUG_TESTING
"-q", "-q",
#endif
dst, "gnunet-arm", dst, "gnunet-arm",
#if DEBUG_TESTING
"-L", "DEBUG",
#endif
"-c", d->cfgfile, "-s", "-q", "- T", "-c", d->cfgfile, "-s", "-q", "- T",
GNUNET_TIME_relative_to_string GNUNET_TIME_relative_to_string
(GNUNET_TIME_absolute_get_remain ing (GNUNET_TIME_absolute_get_remain ing
(d->max_timeout)), NULL); (d->max_timeout)), NULL);
} }
else else
{ {
d->proc = d->proc_arm_start =
GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", "- p", GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", "- p",
d->ssh_port_str, d->ssh_port_str,
#if !DEBUG_TESTING
"-q", "-q",
#endif
dst, "gnunet-arm", dst, "gnunet-arm",
#if DEBUG_TESTING
"-L", "DEBUG",
#endif
"-c", d->cfgfile, "-s", "-q", "-T", "-c", d->cfgfile, "-s", "-q", "-T",
GNUNET_TIME_relative_to_string GNUNET_TIME_relative_to_string
(GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_get_remaining
(d->max_timeout)), NULL); (d->max_timeout)), NULL);
} }
GNUNET_free (dst); GNUNET_free (dst);
} }
if (NULL == d->proc) if (NULL == d->proc_arm_start)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Could not start `%s' process to start GNUnet.\n"), _("Could not start `%s' process to start GNUnet.\n"),
(NULL == d->hostname) ? "gnunet-arm" : "ssh"); (NULL == d->hostname) ? "gnunet-arm" : "ssh");
cb = d->cb; cb = d->cb;
d->cb = NULL; d->cb = NULL;
if (NULL != cb) if (NULL != cb)
cb (d->cb_cls, NULL, d->cfg, d, cb (d->cb_cls, NULL, d->cfg, d,
(NULL == (NULL ==
d->hostname) ? _("Failed to start `gnunet-arm' process.\n") : d->hostname) ? _("Failed to start `gnunet-arm' process.\n") :
_("Failed to start `ssh' process.\n")); _("Failed to start `ssh' process.\n"));
return; return;
} }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Started `%s', waiting for `%s' to be up.\n", "gnunet-arm", "Started `%s', waiting for `%s' to be up.\n", "gnunet-arm",
"gnunet-service-core"); "gnunet-service-core");
d->phase = SP_START_ARMING; d->phase = SP_START_ARMING;
d->task = d->task =
GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fs m, GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fs m,
d); d);
// FIXME: busy wait?
break; break;
case SP_START_ARMING: case SP_START_ARMING:
if (GNUNET_OK != GNUNET_OS_process_status (d->proc, &type, &code)) if (GNUNET_OK != GNUNET_OS_process_status (d->proc_arm_start, &type, &c ode))
{ {
if (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == 0) if (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == 0)
{ {
cb = d->cb; cb = d->cb;
d->cb = NULL; d->cb = NULL;
if (NULL != cb) if (NULL != cb)
cb (d->cb_cls, NULL, d->cfg, d, cb (d->cb_cls, NULL, d->cfg, d,
(NULL == (NULL ==
d->hostname) ? _("`gnunet-arm' does not seem to terminate.\n ") : d->hostname) ? _("`gnunet-arm' does not seem to terminate.\n ") :
_("`ssh' does not seem to terminate.\n")); _("`ssh' does not seem to terminate.\n"));
skipping to change at line 521 skipping to change at line 505
GNUNET_CONFIGURATION_destroy (d->cfg); GNUNET_CONFIGURATION_destroy (d->cfg);
d->cfg = NULL; d->cfg = NULL;
} }
if (d->cfgfile != NULL) if (d->cfgfile != NULL)
{ {
GNUNET_free (d->cfgfile); GNUNET_free (d->cfgfile);
d->cfgfile = NULL; d->cfgfile = NULL;
} }
GNUNET_free_non_null (d->hostname); GNUNET_free_non_null (d->hostname);
GNUNET_free_non_null (d->username); GNUNET_free_non_null (d->username);
GNUNET_free (d->proc); GNUNET_OS_process_destroy (d->proc_arm_start);
// GNUNET_free (d); // FIXME (could this leak) d->proc_arm_start = NULL;
d->username = NULL;
d->hostname = NULL; // Quick hack to avoid crashing (testing ne ed to be d->hostname = NULL; // Quick hack to avoid crashing (testing ne ed to be
d->cfg = NULL; // overhauled anyway, and the error managin g is d->cfg = NULL; // overhauled anyway, and the error managin g is
// GNUNET_free (d); // FIXME (could this leak)
// pretty broken anyway. // pretty broken anyway.
return; return;
} }
/* wait some more */ /* wait some more */
d->task = d->task =
GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_ fsm, GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_ fsm,
d); d);
// FIXME: busy wait?
return; return;
} }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully started `%s'.\n", GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully started `%s'.\n",
"gnunet-arm"); "gnunet-arm");
GNUNET_free (d->proc); GNUNET_OS_process_destroy (d->proc_arm_start);
d->proc_arm_start = NULL;
d->phase = SP_START_CORE; d->phase = SP_START_CORE;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Calling CORE_connect\n"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Calling CORE_connect\n");
/* Fall through */ /* Fall through */
case SP_START_CORE: case SP_START_CORE:
if (d->server != NULL) if (d->server != NULL)
GNUNET_CORE_disconnect (d->server); GNUNET_CORE_disconnect (d->server);
d->th = GNUNET_TRANSPORT_connect (d->cfg, &d->id, d, NULL, NULL, NULL); d->th = GNUNET_TRANSPORT_connect (d->cfg, &d->id, d, NULL, NULL, NULL);
if (d->th == NULL) if (d->th == NULL)
{ {
skipping to change at line 601 skipping to change at line 589
d->task = d->task =
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
(GNUNET_CONSTANTS_SERVICE_RETRY, 2), (GNUNET_CONSTANTS_SERVICE_RETRY, 2),
&start_fsm, d); &start_fsm, d);
break; break;
case SP_START_DONE: case SP_START_DONE:
GNUNET_break (0); GNUNET_break (0);
break; break;
case SP_SERVICE_START: case SP_SERVICE_START:
/* confirm gnunet-arm exited */ /* confirm gnunet-arm exited */
if (GNUNET_OK != GNUNET_OS_process_status (d->proc, &type, &code)) if (GNUNET_OK != GNUNET_OS_process_status (d->proc_arm_srv_start, &type , &code))
{ {
if (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == 0) if (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == 0)
{ {
cb = d->cb; cb = d->cb;
d->cb = NULL; d->cb = NULL;
if (NULL != cb) if (NULL != cb)
cb (d->cb_cls, NULL, d->cfg, d, cb (d->cb_cls, NULL, d->cfg, d,
(NULL == (NULL ==
d->hostname) ? _("`gnunet-arm' does not seem to terminate.\n ") : d->hostname) ? _("`gnunet-arm' does not seem to terminate.\n ") :
_("`ssh' does not seem to terminate.\n")); _("`ssh' does not seem to terminate.\n"));
skipping to change at line 641 skipping to change at line 629
: _("`ssh' does not seem to terminate.\n")); : _("`ssh' does not seem to terminate.\n"));
return; return;
} }
#endif #endif
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service startup complete!\n"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service startup complete!\n");
cb = d->cb; cb = d->cb;
d->cb = NULL; d->cb = NULL;
d->phase = SP_START_DONE; d->phase = SP_START_DONE;
if (NULL != cb) if (NULL != cb)
cb (d->cb_cls, &d->id, d->cfg, d, NULL); cb (d->cb_cls, &d->id, d->cfg, d, NULL);
GNUNET_OS_process_destroy (d->proc_arm_srv_start);
d->proc_arm_srv_start = NULL;
break; break;
case SP_SERVICE_SHUTDOWN_START: case SP_SERVICE_SHUTDOWN_START:
/* confirm copying complete */ /* confirm copying complete */
if (GNUNET_OK != GNUNET_OS_process_status (d->proc, &type, &code)) if (GNUNET_OK != GNUNET_OS_process_status (d->proc_arm_srv_stop, &type, &code))
{ {
if (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == 0) if (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == 0)
{ {
if (NULL != d->dead_cb) if (NULL != d->dead_cb)
d->dead_cb (d->dead_cb_cls, d->dead_cb (d->dead_cb_cls,
_ _
("either `gnunet-arm' or `ssh' does not seem to termi nate.\n")); ("either `gnunet-arm' or `ssh' does not seem to termi nate.\n"));
return; return;
} }
/* wait some more */ /* wait some more */
skipping to change at line 675 skipping to change at line 665
_ _
("shutdown (either `gnunet-arm' or `ssh') did not compl ete cleanly.\n")); ("shutdown (either `gnunet-arm' or `ssh') did not compl ete cleanly.\n"));
return; return;
} }
#endif #endif
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service shutdown complete.\n"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service shutdown complete.\n");
if (NULL != d->dead_cb) if (NULL != d->dead_cb)
d->dead_cb (d->dead_cb_cls, NULL); d->dead_cb (d->dead_cb_cls, NULL);
break; break;
case SP_SHUTDOWN_START: case SP_SHUTDOWN_START:
/* confirm copying complete */ /* confirm copying complete !??? */
if (GNUNET_OK != GNUNET_OS_process_status (d->proc, &type, &code)) if (GNUNET_OK != GNUNET_OS_process_status (d->proc_arm_stop, &type, &co
de))
{ {
if (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == 0) if (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == 0)
{ {
if (NULL != d->dead_cb) if (NULL != d->dead_cb)
d->dead_cb (d->dead_cb_cls, d->dead_cb (d->dead_cb_cls,
_ _
("either `gnunet-arm' or `ssh' does not seem to termi nate.\n")); ("either `gnunet-arm' or `ssh' does not seem to termi nate.\n"));
if (d->th != NULL) if (d->th != NULL)
{ {
GNUNET_TRANSPORT_get_hello_cancel (d->ghh); GNUNET_TRANSPORT_get_hello_cancel (d->ghh);
skipping to change at line 705 skipping to change at line 695
} }
if (d->cfgfile != NULL) if (d->cfgfile != NULL)
{ {
GNUNET_free (d->cfgfile); GNUNET_free (d->cfgfile);
d->cfgfile = NULL; d->cfgfile = NULL;
} }
GNUNET_free_non_null (d->hello); GNUNET_free_non_null (d->hello);
GNUNET_free_non_null (d->hostname); GNUNET_free_non_null (d->hostname);
GNUNET_free_non_null (d->username); GNUNET_free_non_null (d->username);
GNUNET_free_non_null (d->shortname); GNUNET_free_non_null (d->shortname);
GNUNET_free_non_null (d->proc); GNUNET_OS_process_destroy (d->proc_arm_stop);
d->proc = NULL; d->proc_arm_stop = NULL;
GNUNET_free (d); GNUNET_free (d);
return; return;
} }
/* wait some more */ /* wait some more */
d->task = d->task =
GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_ fsm, GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_ fsm,
d); d);
return; return;
} }
if ((type != GNUNET_OS_PROCESS_EXITED) || (code != 0)) if ((type != GNUNET_OS_PROCESS_EXITED) || (code != 0))
skipping to change at line 741 skipping to change at line 731
GNUNET_CORE_disconnect (d->server); GNUNET_CORE_disconnect (d->server);
d->server = NULL; d->server = NULL;
} }
GNUNET_CONFIGURATION_destroy (d->cfg); GNUNET_CONFIGURATION_destroy (d->cfg);
d->cfg = NULL; d->cfg = NULL;
GNUNET_free (d->cfgfile); GNUNET_free (d->cfgfile);
GNUNET_free_non_null (d->hello); GNUNET_free_non_null (d->hello);
GNUNET_free_non_null (d->hostname); GNUNET_free_non_null (d->hostname);
GNUNET_free_non_null (d->username); GNUNET_free_non_null (d->username);
GNUNET_free_non_null (d->shortname); GNUNET_free_non_null (d->shortname);
GNUNET_free_non_null (d->proc); GNUNET_OS_process_destroy (d->proc_arm_stop);
d->proc = NULL; d->proc_arm_stop = NULL;
GNUNET_free (d); GNUNET_free (d);
return; return;
} }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer shutdown complete.\n"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer shutdown complete.\n");
if (d->server != NULL) if (d->server != NULL)
{ {
GNUNET_CORE_disconnect (d->server); GNUNET_CORE_disconnect (d->server);
d->server = NULL; d->server = NULL;
} }
skipping to change at line 777 skipping to change at line 767
GNUNET_CONFIGURATION_destroy (d->cfg); GNUNET_CONFIGURATION_destroy (d->cfg);
d->cfg = NULL; d->cfg = NULL;
GNUNET_free (d->cfgfile); GNUNET_free (d->cfgfile);
GNUNET_free_non_null (d->hostname); GNUNET_free_non_null (d->hostname);
GNUNET_free_non_null (d->username); GNUNET_free_non_null (d->username);
} }
GNUNET_free_non_null (d->hello); GNUNET_free_non_null (d->hello);
d->hello = NULL; d->hello = NULL;
GNUNET_free_non_null (d->shortname); GNUNET_free_non_null (d->shortname);
GNUNET_free_non_null (d->proc); GNUNET_OS_process_destroy (d->proc_arm_stop);
d->proc = NULL; d->proc_arm_stop = NULL;
d->shortname = NULL; d->shortname = NULL;
if (d->churn == GNUNET_NO) if (d->churn == GNUNET_NO)
GNUNET_free (d); GNUNET_free (d);
break; break;
case SP_CONFIG_UPDATE: case SP_CONFIG_UPDATE:
/* confirm copying complete */ /* confirm copying complete */
if (GNUNET_OK != GNUNET_OS_process_status (d->proc, &type, &code)) if (GNUNET_OK != GNUNET_OS_process_status (d->proc_arm_copying, &type, &code))
{ {
if (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == 0) /* FIXME: config update should take timeout parameter! */ if (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == 0) /* FIXME: config update should take timeout parameter! */
{ {
cb = d->cb; cb = d->cb;
d->cb = NULL; d->cb = NULL;
if (NULL != cb) if (NULL != cb)
cb (d->cb_cls, NULL, d->cfg, d, cb (d->cb_cls, NULL, d->cfg, d,
_("`scp' does not seem to terminate.\n")); _("`scp' does not seem to terminate.\n"));
return; return;
} }
skipping to change at line 902 skipping to change at line 892
if (NULL != d->hostname) if (NULL != d->hostname)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting gnunet-arm with config `%s' on host `%s'.\n", "Starting gnunet-arm with config `%s' on host `%s'.\n",
d->cfgfile, d->hostname); d->cfgfile, d->hostname);
if (d->username != NULL) if (d->username != NULL)
GNUNET_asprintf (&arg, "%s@%s", d->username, d->hostname); GNUNET_asprintf (&arg, "%s@%s", d->username, d->hostname);
else else
arg = GNUNET_strdup (d->hostname); arg = GNUNET_strdup (d->hostname);
d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", d->proc_arm_srv_start = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL,
#if !DEBUG_TESTING "ssh", "ssh",
"-q", "-q",
#endif
arg, "gnunet-arm", arg, "gnunet-arm",
#if DEBUG_TESTING
"-L", "DEBUG",
#endif
"-c", d->cfgfile, "-i", service, "-q ", "-c", d->cfgfile, "-i", service, "-q ",
"-T", "-T",
GNUNET_TIME_relative_to_string (time out), GNUNET_TIME_relative_to_string (time out),
NULL); NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting gnunet-arm with command ssh %s gnunet-arm -c %s - i %s -q\n", "Starting gnunet-arm with command ssh %s gnunet-arm -c %s - i %s -q\n",
arg, "gnunet-arm", d->cfgfile, service); arg, "gnunet-arm", d->cfgfile, service);
GNUNET_free (arg); GNUNET_free (arg);
} }
else else
{ {
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting gnunet-arm with config `%s' locally.\n", d->cfgfi le); "Starting gnunet-arm with config `%s' locally.\n", d->cfgfi le);
d->proc = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-arm" d->proc_arm_srv_start = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL
, "gnunet-arm", , "gnunet-arm", "gnunet-arm",
#if DEBUG_TESTING
"-L", "DEBUG",
#endif
"-c", d->cfgfile, "-i", service, "-q ", "-c", d->cfgfile, "-i", service, "-q ",
"-T", "-T",
GNUNET_TIME_relative_to_string (time out), GNUNET_TIME_relative_to_string (time out),
NULL); NULL);
} }
d->max_timeout = GNUNET_TIME_relative_to_absolute (timeout); d->max_timeout = GNUNET_TIME_relative_to_absolute (timeout);
d->task = GNUNET_SCHEDULER_add_now (&start_fsm, d); d->task = GNUNET_SCHEDULER_add_now (&start_fsm, d);
} }
skipping to change at line 978 skipping to change at line 960
if (NULL != d->hostname) if (NULL != d->hostname)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting gnunet-arm with config `%s' on host `%s'.\n", "Starting gnunet-arm with config `%s' on host `%s'.\n",
d->cfgfile, d->hostname); d->cfgfile, d->hostname);
if (d->username != NULL) if (d->username != NULL)
GNUNET_asprintf (&arg, "%s@%s", d->username, d->hostname); GNUNET_asprintf (&arg, "%s@%s", d->username, d->hostname);
else else
arg = GNUNET_strdup (d->hostname); arg = GNUNET_strdup (d->hostname);
d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", d->proc_arm_srv_start = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL,
#if !DEBUG_TESTING "ssh", "ssh",
"-q", "-q",
#endif
arg, "gnunet-arm", arg, "gnunet-arm",
#if DEBUG_TESTING
"-L", "DEBUG",
#endif
"-c", d->cfgfile, "-i", service, "-q ", "-c", d->cfgfile, "-i", service, "-q ",
"-T", "-T",
GNUNET_TIME_relative_to_string (time out), GNUNET_TIME_relative_to_string (time out),
NULL); NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting gnunet-arm with command ssh %s gnunet-arm -c %s - i %s -q -T %s\n", "Starting gnunet-arm with command ssh %s gnunet-arm -c %s - i %s -q -T %s\n",
arg, "gnunet-arm", d->cfgfile, service, arg, "gnunet-arm", d->cfgfile, service,
GNUNET_TIME_relative_to_string (timeout)); GNUNET_TIME_relative_to_string (timeout));
GNUNET_free (arg); GNUNET_free (arg);
} }
else else
{ {
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting gnunet-arm with config `%s' locally.\n", d->cfgfi le); "Starting gnunet-arm with config `%s' locally.\n", d->cfgfi le);
d->proc = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-arm" d->proc_arm_srv_start = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL
, "gnunet-arm", , "gnunet-arm", "gnunet-arm",
#if DEBUG_TESTING
"-L", "DEBUG",
#endif
"-c", d->cfgfile, "-i", service, "-q ", "-c", d->cfgfile, "-i", service, "-q ",
"-T", "-T",
GNUNET_TIME_relative_to_string (time out), GNUNET_TIME_relative_to_string (time out),
NULL); NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting gnunet-arm with command %s -c %s -i %s -q -T %s\n ", "Starting gnunet-arm with command %s -c %s -i %s -q -T %s\n ",
"gnunet-arm", d->cfgfile, service, "gnunet-arm", d->cfgfile, service,
GNUNET_TIME_relative_to_string (timeout)); GNUNET_TIME_relative_to_string (timeout));
} }
skipping to change at line 1210 skipping to change at line 1184
*(++slash) = '\0'; *(++slash) = '\0';
ret->phase = SP_COPYING; ret->phase = SP_COPYING;
if (NULL != username) if (NULL != username)
GNUNET_asprintf (&arg, "%s@%s:%s", username, hostname, baseserviceh ome); GNUNET_asprintf (&arg, "%s@%s:%s", username, hostname, baseserviceh ome);
else else
GNUNET_asprintf (&arg, "%s:%s", hostname, baseservicehome); GNUNET_asprintf (&arg, "%s:%s", hostname, baseservicehome);
GNUNET_free (baseservicehome); GNUNET_free (baseservicehome);
if (ret->ssh_port_str == NULL) if (ret->ssh_port_str == NULL)
{ {
ret->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "scp", ret->proc_arm_copying = GNUNET_OS_start_process (GNUNET_NO, NULL, N
"scp", "-r", ULL, "scp", "scp", "-r",
#if !DEBUG_TESTING
"-q", "-q",
#endif
servicehome, arg, NULL); servicehome, arg, NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"copying directory with command scp -r %s %s\n", "copying directory with command scp -r %s %s\n",
servicehome, arg); servicehome, arg);
} }
else else
{ {
ret->proc = ret->proc_arm_copying =
GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "scp", "scp", "- r", "-P", GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "scp", "scp", "- r", "-P",
ret->ssh_port_str, ret->ssh_port_str,
#if !DEBUG_TESTING
"-q", "-q",
#endif
servicehome, arg, NULL); servicehome, arg, NULL);
} }
GNUNET_free (arg); GNUNET_free (arg);
if (NULL == ret->proc) if (NULL == ret->proc_arm_copying)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_ _
("Could not start `%s' process to copy configuration di rectory.\n"), ("Could not start `%s' process to copy configuration di rectory.\n"),
"scp"); "scp");
if (0 != UNLINK (ret->cfgfile)) if (0 != UNLINK (ret->cfgfile))
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink",
ret->cfgfile); ret->cfgfile);
GNUNET_CONFIGURATION_destroy (ret->cfg); GNUNET_CONFIGURATION_destroy (ret->cfg);
GNUNET_free_non_null (ret->hostname); GNUNET_free_non_null (ret->hostname);
skipping to change at line 1333 skipping to change at line 1303
if (NULL != d->hostname) if (NULL != d->hostname)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Stopping gnunet-arm with config `%s' on host `%s'.\n", "Stopping gnunet-arm with config `%s' on host `%s'.\n",
d->cfgfile, d->hostname); d->cfgfile, d->hostname);
if (d->username != NULL) if (d->username != NULL)
GNUNET_asprintf (&arg, "%s@%s", d->username, d->hostname); GNUNET_asprintf (&arg, "%s@%s", d->username, d->hostname);
else else
arg = GNUNET_strdup (d->hostname); arg = GNUNET_strdup (d->hostname);
d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", d->proc_arm_stop = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh
#if !DEBUG_TESTING ", "ssh",
"-q", "-q",
#endif
arg, "gnunet-arm", arg, "gnunet-arm",
#if DEBUG_TESTING
"-L", "DEBUG",
#endif
"-c", d->cfgfile, "-e", "-r", NULL); "-c", d->cfgfile, "-e", "-r", NULL);
/* Use -r to restart arm and all services */ /* Use -r to restart arm and all services */
GNUNET_free (arg); GNUNET_free (arg);
} }
else else
{ {
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Stopping gnunet-arm with config `%s' locally.\n", d->cfgfi le); "Stopping gnunet-arm with config `%s' locally.\n", d->cfgfi le);
d->proc = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-arm" d->proc_arm_stop = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gn
, "gnunet-arm", unet-arm", "gnunet-arm",
#if DEBUG_TESTING
"-L", "DEBUG",
#endif
"-c", d->cfgfile, "-e", "-r", NULL); "-c", d->cfgfile, "-e", "-r", NULL);
} }
GNUNET_free_non_null (del_arg); GNUNET_free_non_null (del_arg);
d->task = d->task =
GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, d); GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, d);
} }
/** /**
skipping to change at line 1413 skipping to change at line 1375
if (NULL != d->hostname) if (NULL != d->hostname)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Stopping gnunet-arm with config `%s' on host `%s'.\n", "Stopping gnunet-arm with config `%s' on host `%s'.\n",
d->cfgfile, d->hostname); d->cfgfile, d->hostname);
if (d->username != NULL) if (d->username != NULL)
GNUNET_asprintf (&arg, "%s@%s", d->username, d->hostname); GNUNET_asprintf (&arg, "%s@%s", d->username, d->hostname);
else else
arg = GNUNET_strdup (d->hostname); arg = GNUNET_strdup (d->hostname);
d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", d->proc_arm_srv_stop = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL,
#if !DEBUG_TESTING "ssh", "ssh",
"-q", "-q",
#endif
arg, "gnunet-arm", arg, "gnunet-arm",
#if DEBUG_TESTING
"-L", "DEBUG",
#endif
"-c", d->cfgfile, "-k", service, "-q ", "-c", d->cfgfile, "-k", service, "-q ",
"-T", "-T",
GNUNET_TIME_relative_to_string (time out), GNUNET_TIME_relative_to_string (time out),
NULL); NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Stopping gnunet-arm with command ssh %s gnunet-arm -c %s - k %s -q\n", "Stopping gnunet-arm with command ssh %s gnunet-arm -c %s - k %s -q\n",
arg, "gnunet-arm", d->cfgfile, service); arg, "gnunet-arm", d->cfgfile, service);
GNUNET_free (arg); GNUNET_free (arg);
} }
else else
{ {
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Stopping gnunet-arm with config `%s' locally.\n", d->cfgfi le); "Stopping gnunet-arm with config `%s' locally.\n", d->cfgfi le);
d->proc = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-arm" d->proc_arm_srv_stop = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL,
, "gnunet-arm", "gnunet-arm", "gnunet-arm",
#if DEBUG_TESTING
"-L", "DEBUG",
#endif
"-c", d->cfgfile, "-k", service, "-q ", "-c", d->cfgfile, "-k", service, "-q ",
"-T", "-T",
GNUNET_TIME_relative_to_string (time out), GNUNET_TIME_relative_to_string (time out),
NULL); NULL);
} }
d->max_timeout = GNUNET_TIME_relative_to_absolute (timeout); d->max_timeout = GNUNET_TIME_relative_to_absolute (timeout);
d->task = GNUNET_SCHEDULER_add_now (&start_fsm, d); d->task = GNUNET_SCHEDULER_add_now (&start_fsm, d);
} }
/** /**
* Forcefully terminate a process and clean up the child.
*
* @param proc handle to process to kill
*/
static void
kill_and_close_process (struct GNUNET_OS_Process *proc)
{
(void) GNUNET_OS_process_kill (proc, SIGKILL);
GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (proc));
GNUNET_OS_process_destroy (proc);
}
/**
* Stops a GNUnet daemon. * Stops a GNUnet daemon.
* *
* @param d the daemon that should be stopped * @param d the daemon that should be stopped
* @param timeout how long to wait for process for shutdown to complete * @param timeout how long to wait for process for shutdown to complete
* @param cb function called once the daemon was stopped * @param cb function called once the daemon was stopped
* @param cb_cls closure for cb * @param cb_cls closure for cb
* @param delete_files GNUNET_YES to remove files, GNUNET_NO * @param delete_files GNUNET_YES to remove files, GNUNET_NO
* to leave them * to leave them
* @param allow_restart GNUNET_YES to restart peer later (using this API) * @param allow_restart GNUNET_YES to restart peer later (using this API)
* GNUNET_NO to kill off and clean up for good * GNUNET_NO to kill off and clean up for good
skipping to change at line 1479 skipping to change at line 1446
d->dead_cb = cb; d->dead_cb = cb;
d->dead_cb_cls = cb_cls; d->dead_cb_cls = cb_cls;
if (NULL != d->cb) if (NULL != d->cb)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Setting d->dead on peer `%4s'\n "), GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Setting d->dead on peer `%4s'\n "),
GNUNET_i2s (&d->id)); GNUNET_i2s (&d->id));
d->dead = GNUNET_YES; d->dead = GNUNET_YES;
return; return;
} }
if (NULL != d->proc_arm_start)
if ((d->running == GNUNET_NO) && (d->churn == GNUNET_YES)) /* Peer has {
already been stopped in churn context! */ kill_and_close_process (d->proc_arm_start);
d->proc_arm_start = NULL;
}
if (NULL != d->proc_arm_srv_start)
{ {
/* Free what was left from churning! */ kill_and_close_process (d->proc_arm_srv_start);
d->proc_arm_srv_start = NULL;
}
if (NULL != d->proc_arm_srv_stop)
{
kill_and_close_process (d->proc_arm_srv_stop);
d->proc_arm_srv_stop = NULL;
}
if (NULL != d->proc_arm_copying)
{
kill_and_close_process (d->proc_arm_copying);
d->proc_arm_copying = NULL;
}
if (NULL != d->proc_arm_peerinfo)
{
kill_and_close_process (d->proc_arm_peerinfo);
d->proc_arm_peerinfo = NULL;
}
if ((d->running == GNUNET_NO) && (d->churn == GNUNET_YES))
{
/* Peer has already been stopped in churn context!
* Free what was left from churning! */
GNUNET_assert (d->cfg != NULL); GNUNET_assert (d->cfg != NULL);
GNUNET_CONFIGURATION_destroy (d->cfg); GNUNET_CONFIGURATION_destroy (d->cfg);
if (delete_files == GNUNET_YES) if (delete_files == GNUNET_YES)
{ {
if (0 != UNLINK (d->cfgfile)) if (0 != UNLINK (d->cfgfile))
{ {
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "unlink"); GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "unlink");
} }
} }
GNUNET_free (d->cfgfile); GNUNET_free (d->cfgfile);
GNUNET_free_non_null (d->hostname); GNUNET_free_non_null (d->hostname);
GNUNET_free_non_null (d->username); GNUNET_free_non_null (d->username);
if (NULL != d->dead_cb) if (NULL != d->dead_cb)
d->dead_cb (d->dead_cb_cls, NULL); d->dead_cb (d->dead_cb_cls, NULL);
/* FIXME: this should be an assert and the test below
should not be required, but testing is broken... */
GNUNET_break (NULL == d->proc_arm_stop);
if (NULL == d->proc_arm_stop)
GNUNET_free (d); GNUNET_free (d);
return; return;
} }
del_arg = NULL; del_arg = NULL;
if (delete_files == GNUNET_YES) if (delete_files == GNUNET_YES)
{ {
GNUNET_asprintf (&del_arg, "-d"); GNUNET_asprintf (&del_arg, "-d");
} }
skipping to change at line 1534 skipping to change at line 1530
if (allow_restart == GNUNET_YES) if (allow_restart == GNUNET_YES)
d->churn = GNUNET_YES; d->churn = GNUNET_YES;
if (d->th != NULL) if (d->th != NULL)
{ {
GNUNET_TRANSPORT_get_hello_cancel (d->ghh); GNUNET_TRANSPORT_get_hello_cancel (d->ghh);
d->ghh = NULL; d->ghh = NULL;
GNUNET_TRANSPORT_disconnect (d->th); GNUNET_TRANSPORT_disconnect (d->th);
d->th = NULL; d->th = NULL;
} }
/* Check if this is a local or remote process */ /* Check if this is a local or remote process */
if (NULL != d->hostname) if (NULL != d->hostname)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Stopping gnunet-arm with config `%s' on host `%s'.\n", "Stopping gnunet-arm with config `%s' on host `%s'.\n",
d->cfgfile, d->hostname); d->cfgfile, d->hostname);
if (d->username != NULL) if (d->username != NULL)
GNUNET_asprintf (&arg, "%s@%s", d->username, d->hostname); GNUNET_asprintf (&arg, "%s@%s", d->username, d->hostname);
else else
arg = GNUNET_strdup (d->hostname); arg = GNUNET_strdup (d->hostname);
d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", d->proc_arm_stop = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh
#if !DEBUG_TESTING ", "ssh",
"-q", "-q",
#endif
arg, "gnunet-arm", arg, "gnunet-arm",
#if DEBUG_TESTING
"-L", "DEBUG",
#endif
"-c", d->cfgfile, "-e", "-q", "-T", "-c", d->cfgfile, "-e", "-q", "-T",
GNUNET_TIME_relative_to_string (time out), GNUNET_TIME_relative_to_string (time out),
del_arg, NULL); del_arg, NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Stopping gnunet-arm with command ssh %s gnunet-arm -c %s - e -q %s\n", "Stopping gnunet-arm with command ssh %s gnunet-arm -c %s - e -q %s\n",
arg, "gnunet-arm", d->cfgfile, del_arg); arg, "gnunet-arm", d->cfgfile, del_arg);
/* Use -e to end arm, and -d to remove temp files */ /* Use -e to end arm, and -d to remove temp files */
GNUNET_free (arg); GNUNET_free (arg);
} }
else else
{ {
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Stopping gnunet-arm with config `%s' locally.\n", d->cfgfi le); "Stopping gnunet-arm with config `%s' locally.\n", d->cfgfi le);
d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "gnunet-arm", d->proc_arm_stop = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "gnu
"gnunet-arm", net-arm", "gnunet-arm",
#if DEBUG_TESTING
"-L", "DEBUG",
#endif
"-c", d->cfgfile, "-e", "-q", "-T", "-c", d->cfgfile, "-e", "-q", "-T",
GNUNET_TIME_relative_to_string (time out), GNUNET_TIME_relative_to_string (time out),
del_arg, NULL); del_arg, NULL);
GNUNET_assert (NULL != d->proc); GNUNET_assert (NULL != d->proc_arm_stop);
} }
GNUNET_free_non_null (del_arg); GNUNET_free_non_null (del_arg);
d->max_timeout = GNUNET_TIME_relative_to_absolute (timeout); d->max_timeout = GNUNET_TIME_relative_to_absolute (timeout);
if (GNUNET_SCHEDULER_NO_TASK != d->task) if (GNUNET_SCHEDULER_NO_TASK != d->task)
GNUNET_SCHEDULER_cancel(d->task); GNUNET_SCHEDULER_cancel(d->task);
d->task = GNUNET_SCHEDULER_add_now (&start_fsm, d); d->task = GNUNET_SCHEDULER_add_now (&start_fsm, d);
} }
/** /**
skipping to change at line 1631 skipping to change at line 1620
return; return;
} }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Copying updated configuration file to remote host `%s'.\n", "Copying updated configuration file to remote host `%s'.\n",
d->hostname); d->hostname);
d->phase = SP_CONFIG_UPDATE; d->phase = SP_CONFIG_UPDATE;
if (NULL != d->username) if (NULL != d->username)
GNUNET_asprintf (&arg, "%s@%s:%s", d->username, d->hostname, d->cfgfile ); GNUNET_asprintf (&arg, "%s@%s:%s", d->username, d->hostname, d->cfgfile );
else else
GNUNET_asprintf (&arg, "%s:%s", d->hostname, d->cfgfile); GNUNET_asprintf (&arg, "%s:%s", d->hostname, d->cfgfile);
d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "scp", "scp", d->proc_arm_copying = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "sc
#if !DEBUG_TESTING p", "scp",
"-q", "-q",
#endif
d->cfgfile, arg, NULL); d->cfgfile, arg, NULL);
GNUNET_free (arg); GNUNET_free (arg);
if (NULL == d->proc) if (NULL == d->proc_arm_copying)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Could not start `%s' process to copy configuration file. \n"), _("Could not start `%s' process to copy configuration file. \n"),
"scp"); "scp");
if (NULL != cb) if (NULL != cb)
cb (cb_cls, _("Failed to copy new configuration to remote machine.")) ; cb (cb_cls, _("Failed to copy new configuration to remote machine.")) ;
d->phase = SP_START_DONE; d->phase = SP_START_DONE;
return; return;
} }
d->update_cb = cb; d->update_cb = cb;
skipping to change at line 2162 skipping to change at line 2149
ctx->relative_timeout = ctx->relative_timeout =
GNUNET_TIME_relative_divide (timeout, max_connect_attempts); GNUNET_TIME_relative_divide (timeout, max_connect_attempts);
ctx->cb = cb; ctx->cb = cb;
ctx->cb_cls = cb_cls; ctx->cb_cls = cb_cls;
ctx->connect_attempts = max_connect_attempts; ctx->connect_attempts = max_connect_attempts;
ctx->connected = GNUNET_NO; ctx->connected = GNUNET_NO;
ctx->send_hello = send_hello; ctx->send_hello = send_hello;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asked to connect peer %s to peer %s \n", GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asked to connect peer %s to peer %s \n",
d1->shortname, d2->shortname); d1->shortname, d2->shortname);
/* Core is up! Iterate over all _known_ peers first to check if we are al ready connected to the peer! */ /* Core is up! Iterate over all _known_ peers first to check if we are al ready connected to the peer! */
GNUNET_assert (GNUNET_OK == GNUNET_assert (NULL !=
GNUNET_CORE_is_peer_connected (ctx->d1->cfg, &ctx->d2->id, GNUNET_CORE_is_peer_connected (ctx->d1->cfg, &ctx->d2->id,
&core_initial_iteration, ct x)); &core_initial_iteration, ct x));
return ctx; return ctx;
} }
/** /**
* Cancel an attempt to connect two daemons. * Cancel an attempt to connect two daemons.
* *
* @param cc connect context * @param cc connect context
*/ */
 End of changes. 76 change blocks. 
132 lines changed or deleted 126 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/