testing_group.c   testing_group.c 
skipping to change at line 33 skipping to change at line 33
* @brief convenience API for writing testcases for GNUnet * @brief convenience API for writing testcases for GNUnet
* @author Nathan Evans * @author Nathan Evans
* @author Christian Grothoff * @author Christian Grothoff
*/ */
#include "platform.h" #include "platform.h"
#include "gnunet_constants.h" #include "gnunet_constants.h"
#include "gnunet_arm_service.h" #include "gnunet_arm_service.h"
#include "gnunet_testing_lib.h" #include "gnunet_testing_lib.h"
#include "gnunet_core_service.h" #include "gnunet_core_service.h"
#define VERBOSE_TESTING GNUNET_NO
#define VERBOSE_TOPOLOGY GNUNET_NO
#define DEBUG_CHURN GNUNET_EXTRA_LOGGING
#define USE_START_HELPER GNUNET_YES #define USE_START_HELPER GNUNET_YES
#define OLD 1 #define OLD 1
/* Before connecting peers, send all of the HELLOs */ /* Before connecting peers, send all of the HELLOs */
#define USE_SEND_HELLOS GNUNET_NO #define USE_SEND_HELLOS GNUNET_NO
#define TOPOLOGY_HACK GNUNET_YES #define TOPOLOGY_HACK GNUNET_YES
/** /**
skipping to change at line 1359 skipping to change at line 1353
unsigned int ival; unsigned int ival;
char cval[12]; char cval[12];
char uval[128]; char uval[128];
char *single_variable; char *single_variable;
char *per_host_variable; char *per_host_variable;
unsigned long long num_per_host; unsigned long long num_per_host;
GNUNET_asprintf (&single_variable, "single_%s_per_host", section); GNUNET_asprintf (&single_variable, "single_%s_per_host", section);
GNUNET_asprintf (&per_host_variable, "num_%s_per_host", section); GNUNET_asprintf (&per_host_variable, "num_%s_per_host", section);
if ((0 == strcmp (option, "PORT")) && (1 == sscanf (value, "%u", &ival))) if ((0 == strcmp (option, "PORT")) && (1 == SSCANF (value, "%u", &ival)))
{ {
if ((ival != 0) && if ((ival != 0) &&
(GNUNET_YES != (GNUNET_YES !=
GNUNET_CONFIGURATION_get_value_yesno (ctx->orig, "testing", GNUNET_CONFIGURATION_get_value_yesno (ctx->orig, "testing",
single_variable))) single_variable)))
{ {
GNUNET_snprintf (cval, sizeof (cval), "%u", ctx->nport++); GNUNET_snprintf (cval, sizeof (cval), "%u", ctx->nport++);
value = cval; value = cval;
} }
else if ((ival != 0) && else if ((ival != 0) &&
skipping to change at line 1512 skipping to change at line 1506
GNUNET_CONFIGURATION_set_value_string (uc.ret, "statistics", "ACCEPT_FR OM", GNUNET_CONFIGURATION_set_value_string (uc.ret, "statistics", "ACCEPT_FR OM",
allowed_hosts); allowed_hosts);
GNUNET_CONFIGURATION_set_value_string (uc.ret, "core", "UNIXPATH", ""); GNUNET_CONFIGURATION_set_value_string (uc.ret, "core", "UNIXPATH", "");
GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport", "UNIXPATH", ""); GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport", "UNIXPATH", "");
GNUNET_CONFIGURATION_set_value_string (uc.ret, "dht", "UNIXPATH", ""); GNUNET_CONFIGURATION_set_value_string (uc.ret, "dht", "UNIXPATH", "");
GNUNET_CONFIGURATION_set_value_string (uc.ret, "statistics", "UNIXPATH" , GNUNET_CONFIGURATION_set_value_string (uc.ret, "statistics", "UNIXPATH" ,
""); "");
GNUNET_CONFIGURATION_set_value_string (uc.ret, "nse", "UNIXPATH", ""); GNUNET_CONFIGURATION_set_value_string (uc.ret, "nse", "UNIXPATH", "");
GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport-tcp", GNUNET_CONFIGURATION_set_value_string (uc.ret, "nat",
"USE_LOCALADDR", "YES");
GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport-udp",
"USE_LOCALADDR", "YES"); "USE_LOCALADDR", "YES");
GNUNET_free_non_null (control_host); GNUNET_free_non_null (control_host);
GNUNET_free (allowed_hosts); GNUNET_free (allowed_hosts);
} }
/* arm needs to know to allow connections from the host on which it is ru nning, /* arm needs to know to allow connections from the host on which it is ru nning,
* otherwise gnunet-arm is unable to connect to it in some instances */ * otherwise gnunet-arm is unable to connect to it in some instances */
if (hostname != NULL) if (hostname != NULL)
{ {
GNUNET_asprintf (&allowed_hosts, "%s; 127.0.0.1;", hostname); GNUNET_asprintf (&allowed_hosts, "%s; 127.0.0.1;", hostname);
skipping to change at line 1542 skipping to change at line 1534
GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport-tcp", GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport-tcp",
"USE_LOCALADDR", "YES"); "USE_LOCALADDR", "YES");
GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport-udp", GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport-udp",
"USE_LOCALADDR", "YES"); "USE_LOCALADDR", "YES");
GNUNET_CONFIGURATION_set_value_string (uc.ret, "arm", "ACCEPT_FROM", GNUNET_CONFIGURATION_set_value_string (uc.ret, "arm", "ACCEPT_FROM",
allowed_hosts); allowed_hosts);
GNUNET_free (allowed_hosts); GNUNET_free (allowed_hosts);
} }
else else
{ {
GNUNET_CONFIGURATION_set_value_string (uc.ret, "nat",
GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport-tcp",
"USE_LOCALADDR", "YES");
GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport-udp",
"USE_LOCALADDR", "YES"); "USE_LOCALADDR", "YES");
GNUNET_CONFIGURATION_set_value_string (uc.ret, "nat", "BINDTO", GNUNET_CONFIGURATION_set_value_string (uc.ret, "nat", "BINDTO",
"127.0.0.1"); "127.0.0.1");
GNUNET_CONFIGURATION_set_value_string (uc.ret, "nat", "INTERNAL_ADDRESS ", GNUNET_CONFIGURATION_set_value_string (uc.ret, "nat", "INTERNAL_ADDRESS ",
"127.0.0.1"); "127.0.0.1");
GNUNET_CONFIGURATION_set_value_string (uc.ret, "nat", "EXTERNAL_ADDRESS ", GNUNET_CONFIGURATION_set_value_string (uc.ret, "nat", "EXTERNAL_ADDRESS ",
"127.0.0.1"); "127.0.0.1");
GNUNET_CONFIGURATION_set_value_string (uc.ret, "nat", "disablev6", GNUNET_CONFIGURATION_set_value_string (uc.ret, "nat", "disablev6",
"YES"); "YES");
} }
skipping to change at line 1837 skipping to change at line 1826
{ {
previous_total_connections = total_connections; previous_total_connections = total_connections;
for (i = 0; i < outer_count; i++) for (i = 0; i < outer_count; i++)
{ {
probability = probability =
pg->peers[i].num_connections / (double) previous_total_connection s; pg->peers[i].num_connections / (double) previous_total_connection s;
random = random =
((double) ((double)
GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
UINT64_MAX)) / ((double) UINT64_MAX); UINT64_MAX)) / ((double) UINT64_MAX);
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Considering connecting peer %d to peer %d\n", outer_coun t, "Considering connecting peer %d to peer %d\n", outer_coun t,
i); i);
#endif
if (random < probability) if (random < probability)
{ {
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d \n", GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d \n",
outer_count, i); outer_count, i);
#endif
total_connections += proc (pg, outer_count, i, list, GNUNET_YES); total_connections += proc (pg, outer_count, i, list, GNUNET_YES);
} }
} }
} }
return total_connections; return total_connections;
} }
/** /**
* Create a topology given a peer group (set of running peers) * Create a topology given a peer group (set of running peers)
skipping to change at line 1906 skipping to change at line 1891
int max; int max;
int min; int min;
unsigned int useAnd; unsigned int useAnd;
int connect_attempts; int connect_attempts;
logNModifier = 0.5; /* FIXME: default value? */ logNModifier = 0.5; /* FIXME: default value? */
if (GNUNET_OK == if (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAG E", GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAG E",
&p_string)) &p_string))
{ {
if (sscanf (p_string, "%lf", &logNModifier) != 1) if (SSCANF (p_string, "%lf", &logNModifier) != 1)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_ _
("Invalid value `%s' for option `%s' in section `%s': exp ected float\n"), ("Invalid value `%s' for option `%s' in section `%s': exp ected float\n"),
p_string, "LOGNMODIFIER", "TESTING"); p_string, "LOGNMODIFIER", "TESTING");
GNUNET_free (p_string); GNUNET_free (p_string);
} }
probability = 0.5; /* FIXME: default percentage? */ probability = 0.5; /* FIXME: default percentage? */
if (GNUNET_OK == if (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PROBABILI TY", GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PROBABILI TY",
&p_string)) &p_string))
{ {
if (sscanf (p_string, "%lf", &probability) != 1) if (SSCANF (p_string, "%lf", &probability) != 1)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_ _
("Invalid value `%s' for option `%s' in section `%s': exp ected float\n"), ("Invalid value `%s' for option `%s' in section `%s': exp ected float\n"),
p_string, "PERCENTAGE", "TESTING"); p_string, "PERCENTAGE", "TESTING");
GNUNET_free (p_string); GNUNET_free (p_string);
} }
natLog = log (pg->total); natLog = log (pg->total);
connsPerPeer = ceil (natLog * logNModifier); connsPerPeer = ceil (natLog * logNModifier);
if (connsPerPeer % 2 == 1) if (connsPerPeer % 2 == 1)
connsPerPeer += 1; connsPerPeer += 1;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Target is %d connections per peer ."), GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Target is %d connections per peer." ,
connsPerPeer); connsPerPeer);
smallWorldConnections = 0; smallWorldConnections = 0;
connect_attempts = 0; connect_attempts = 0;
for (i = 0; i < pg->total; i++) for (i = 0; i < pg->total; i++)
{ {
useAnd = 0; useAnd = 0;
max = i + connsPerPeer / 2; max = i + connsPerPeer / 2;
min = i - connsPerPeer / 2; min = i - connsPerPeer / 2;
skipping to change at line 2019 skipping to change at line 2004
unsigned int cutoff; unsigned int cutoff;
int connect_attempts; int connect_attempts;
double nat_percentage; double nat_percentage;
char *p_string; char *p_string;
nat_percentage = 0.6; /* FIXME: default percentage? */ nat_percentage = 0.6; /* FIXME: default percentage? */
if (GNUNET_OK == if (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAG E", GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAG E",
&p_string)) &p_string))
{ {
if (sscanf (p_string, "%lf", &nat_percentage) != 1) if (SSCANF (p_string, "%lf", &nat_percentage) != 1)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_ _
("Invalid value `%s' for option `%s' in section `%s': exp ected float\n"), ("Invalid value `%s' for option `%s' in section `%s': exp ected float\n"),
p_string, "PERCENTAGE", "TESTING"); p_string, "PERCENTAGE", "TESTING");
GNUNET_free (p_string); GNUNET_free (p_string);
} }
cutoff = (unsigned int) (nat_percentage * pg->total); cutoff = (unsigned int) (nat_percentage * pg->total);
connect_attempts = 0; connect_attempts = 0;
for (outer_count = 0; outer_count < pg->total - 1; outer_count++) for (outer_count = 0; outer_count < pg->total - 1; outer_count++)
{ {
for (inner_count = outer_count + 1; inner_count < pg->total; inner_coun t++) for (inner_count = outer_count + 1; inner_count < pg->total; inner_coun t++)
{ {
if ((outer_count > cutoff) || (inner_count > cutoff)) if ((outer_count > cutoff) || (inner_count > cutoff))
{ {
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d \n", GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d \n",
outer_count, inner_count); outer_count, inner_count);
#endif
connect_attempts += connect_attempts +=
proc (pg, outer_count, inner_count, list, GNUNET_YES); proc (pg, outer_count, inner_count, list, GNUNET_YES);
} }
} }
} }
return connect_attempts; return connect_attempts;
} }
#if TOPOLOGY_HACK #if TOPOLOGY_HACK
/** /**
skipping to change at line 2078 skipping to change at line 2061
double nat_percentage; double nat_percentage;
char *p_string; char *p_string;
unsigned int count; unsigned int count;
struct ProgressMeter *conn_meter; struct ProgressMeter *conn_meter;
nat_percentage = 0.6; /* FIXME: default percentage? */ nat_percentage = 0.6; /* FIXME: default percentage? */
if (GNUNET_OK == if (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAG E", GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAG E",
&p_string)) &p_string))
{ {
if (sscanf (p_string, "%lf", &nat_percentage) != 1) if (SSCANF (p_string, "%lf", &nat_percentage) != 1)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_ _
("Invalid value `%s' for option `%s' in section `%s': exp ected float\n"), ("Invalid value `%s' for option `%s' in section `%s': exp ected float\n"),
p_string, "PERCENTAGE", "TESTING"); p_string, "PERCENTAGE", "TESTING");
GNUNET_free (p_string); GNUNET_free (p_string);
} }
cutoff = (unsigned int) (nat_percentage * pg->total); cutoff = (unsigned int) (nat_percentage * pg->total);
count = 0; count = 0;
for (outer_count = 0; outer_count < pg->total - 1; outer_count++) for (outer_count = 0; outer_count < pg->total - 1; outer_count++)
skipping to change at line 2106 skipping to change at line 2089
} }
} }
conn_meter = create_meter (count, "NAT COPY", GNUNET_YES); conn_meter = create_meter (count, "NAT COPY", GNUNET_YES);
connect_attempts = 0; connect_attempts = 0;
for (outer_count = 0; outer_count < pg->total - 1; outer_count++) for (outer_count = 0; outer_count < pg->total - 1; outer_count++)
{ {
for (inner_count = outer_count + 1; inner_count < pg->total; inner_coun t++) for (inner_count = outer_count + 1; inner_count < pg->total; inner_coun t++)
{ {
if ((outer_count > cutoff) || (inner_count > cutoff)) if ((outer_count > cutoff) || (inner_count > cutoff))
{ {
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d \n", GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d \n",
outer_count, inner_count); outer_count, inner_count);
#endif
connect_attempts += connect_attempts +=
proc (pg, outer_count, inner_count, list, GNUNET_YES); proc (pg, outer_count, inner_count, list, GNUNET_YES);
add_connections (pg, outer_count, inner_count, ALLOWED, GNUNET_NO); add_connections (pg, outer_count, inner_count, ALLOWED, GNUNET_NO);
update_meter (conn_meter); update_meter (conn_meter);
} }
} }
} }
free_meter (conn_meter); free_meter (conn_meter);
return connect_attempts; return connect_attempts;
skipping to change at line 2167 skipping to change at line 2148
square = floor (sqrt (pg->total)); square = floor (sqrt (pg->total));
rows = square; rows = square;
cols = square; cols = square;
percentage = 0.5; /* FIXME: default percentage? */ percentage = 0.5; /* FIXME: default percentage? */
if (GNUNET_OK == if (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAG E", GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAG E",
&p_string)) &p_string))
{ {
if (sscanf (p_string, "%lf", &percentage) != 1) if (SSCANF (p_string, "%lf", &percentage) != 1)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_ _
("Invalid value `%s' for option `%s' in section `%s': exp ected float\n"), ("Invalid value `%s' for option `%s' in section `%s': exp ected float\n"),
p_string, "PERCENTAGE", "TESTING"); p_string, "PERCENTAGE", "TESTING");
GNUNET_free (p_string); GNUNET_free (p_string);
} }
if (percentage < 0.0) if (percentage < 0.0)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_ _
("Invalid value `%s' for option `%s' in section `%s': got % f, needed value greater than 0\n"), ("Invalid value `%s' for option `%s' in section `%s': got % f, needed value greater than 0\n"),
"PERCENTAGE", "TESTING", percentage); "PERCENTAGE", "TESTING", percentage);
percentage = 0.5; percentage = 0.5;
} }
probability = 0.5; /* FIXME: default percentage? */ probability = 0.5; /* FIXME: default percentage? */
if (GNUNET_OK == if (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PROBABILI TY", GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PROBABILI TY",
&p_string)) &p_string))
{ {
if (sscanf (p_string, "%lf", &probability) != 1) if (SSCANF (p_string, "%lf", &probability) != 1)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_ _
("Invalid value `%s' for option `%s' in section `%s': exp ected float\n"), ("Invalid value `%s' for option `%s' in section `%s': exp ected float\n"),
p_string, "PROBABILITY", "TESTING"); p_string, "PROBABILITY", "TESTING");
GNUNET_free (p_string); GNUNET_free (p_string);
} }
if (square * square != pg->total) if (square * square != pg->total)
{ {
while (rows * cols < pg->total) while (rows * cols < pg->total)
{ {
if (toggle % 2 == 0) if (toggle % 2 == 0)
rows++; rows++;
else else
cols++; cols++;
toggle++; toggle++;
} }
} }
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Connecting nodes in 2d torus topology: %u rows %u columns\ n"), "Connecting nodes in 2d torus topology: %u rows %u columns\n" ,
rows, cols); rows, cols);
#endif
connect_attempts = 0; connect_attempts = 0;
/* Rows and columns are all sorted out, now iterate over all nodes and co nnect each /* Rows and columns are all sorted out, now iterate over all nodes and co nnect each
* to the node to its right and above. Once this is over, we'll have our torus! * to the node to its right and above. Once this is over, we'll have our torus!
* Special case for the last node (if the rows and columns are not equal) , connect * Special case for the last node (if the rows and columns are not equal) , connect
* to the first in the row to maintain topology. * to the first in the row to maintain topology.
*/ */
for (i = 0; i < pg->total; i++) for (i = 0; i < pg->total; i++)
{ {
/* First connect to the node to the right */ /* First connect to the node to the right */
if (((i + 1) % cols != 0) && (i + 1 != pg->total)) if (((i + 1) % cols != 0) && (i + 1 != pg->total))
skipping to change at line 2243 skipping to change at line 2221
if (nodeToConnect >= pg->total) if (nodeToConnect >= pg->total)
nodeToConnect -= cols; nodeToConnect -= cols;
} }
else else
nodeToConnect = i - cols; nodeToConnect = i - cols;
if (nodeToConnect < pg->total) if (nodeToConnect < pg->total)
connect_attempts += proc (pg, i, nodeToConnect, list, GNUNET_YES); connect_attempts += proc (pg, i, nodeToConnect, list, GNUNET_YES);
} }
natLog = log (pg->total); natLog = log (pg->total);
#if VERBOSE_TESTING > 2
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("natural log of %d is %d, will run %d iterations\n"), pg->t otal, "natural log of %d is %d, will run %d iterations\n", pg->tota l,
natLog, (int) (natLog * percentage)); natLog, (int) (natLog * percentage));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Total connections added thus far: %u!\n"), connect_attempt "Total connections added thus far: %u!\n", connect_attempts);
s);
#endif
smallWorldConnections = 0; smallWorldConnections = 0;
small_world_it = (unsigned int) (natLog * percentage); small_world_it = (unsigned int) (natLog * percentage);
if (small_world_it < 1) if (small_world_it < 1)
small_world_it = 1; small_world_it = 1;
GNUNET_assert (small_world_it > 0 && small_world_it < (unsigned int) -1); GNUNET_assert (small_world_it > 0 && small_world_it < (unsigned int) -1);
for (i = 0; i < small_world_it; i++) for (i = 0; i < small_world_it; i++)
{ {
for (j = 0; j < pg->total; j++) for (j = 0; j < pg->total; j++)
{ {
/* Determine the row and column of node at position j on the 2d torus */ /* Determine the row and column of node at position j on the 2d torus */
skipping to change at line 2287 skipping to change at line 2263
UINT64_MAX)) / ((double) UINT64_MA X); UINT64_MAX)) / ((double) UINT64_MA X);
/* If random < probability, then connect the two nodes */ /* If random < probability, then connect the two nodes */
if (random < probability) if (random < probability)
smallWorldConnections += proc (pg, j, k, list, GNUNET_YES); smallWorldConnections += proc (pg, j, k, list, GNUNET_YES);
} }
} }
} }
} }
connect_attempts += smallWorldConnections; connect_attempts += smallWorldConnections;
#if VERBOSE_TESTING > 2
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Total connections added for small world: %d!\n"), "Total connections added for small world: %d!\n",
smallWorldConnections); smallWorldConnections);
#endif
return connect_attempts; return connect_attempts;
} }
/** /**
* Create a topology given a peer group (set of running peers) * Create a topology given a peer group (set of running peers)
* and a connection processor. * and a connection processor.
* *
* @param pg the peergroup to create the topology on * @param pg the peergroup to create the topology on
* @param proc the connection processor to call to actually set * @param proc the connection processor to call to actually set
* up connections between two peers * up connections between two peers
skipping to change at line 2324 skipping to change at line 2298
unsigned int inner_count; unsigned int inner_count;
int connect_attempts; int connect_attempts;
double probability; double probability;
char *p_string; char *p_string;
probability = 0.5; /* FIXME: default percentage? */ probability = 0.5; /* FIXME: default percentage? */
if (GNUNET_OK == if (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PROBABILI TY", GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PROBABILI TY",
&p_string)) &p_string))
{ {
if (sscanf (p_string, "%lf", &probability) != 1) if (SSCANF (p_string, "%lf", &probability) != 1)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_ _
("Invalid value `%s' for option `%s' in section `%s': exp ected float\n"), ("Invalid value `%s' for option `%s' in section `%s': exp ected float\n"),
p_string, "PROBABILITY", "TESTING"); p_string, "PROBABILITY", "TESTING");
GNUNET_free (p_string); GNUNET_free (p_string);
} }
connect_attempts = 0; connect_attempts = 0;
for (outer_count = 0; outer_count < pg->total - 1; outer_count++) for (outer_count = 0; outer_count < pg->total - 1; outer_count++)
{ {
for (inner_count = outer_count + 1; inner_count < pg->total; inner_coun t++) for (inner_count = outer_count + 1; inner_count < pg->total; inner_coun t++)
{ {
temp_rand = temp_rand =
((double) ((double)
GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
UINT64_MAX)) / ((double) UINT64_MAX); UINT64_MAX)) / ((double) UINT64_MAX);
#if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "rand is %f probability is %f\n"
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("rand is %f probability is %f\ ,
n"),
temp_rand, probability); temp_rand, probability);
#endif
if (temp_rand < probability) if (temp_rand < probability)
{ {
connect_attempts += connect_attempts +=
proc (pg, outer_count, inner_count, list, GNUNET_YES); proc (pg, outer_count, inner_count, list, GNUNET_YES);
} }
} }
} }
return connect_attempts; return connect_attempts;
} }
skipping to change at line 2399 skipping to change at line 2371
while (rows * cols < pg->total) while (rows * cols < pg->total)
{ {
if (toggle % 2 == 0) if (toggle % 2 == 0)
rows++; rows++;
else else
cols++; cols++;
toggle++; toggle++;
} }
} }
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Connecting nodes in 2d torus topology: %u rows %u columns\ n"), "Connecting nodes in 2d torus topology: %u rows %u columns\n" ,
rows, cols); rows, cols);
#endif
/* Rows and columns are all sorted out, now iterate over all nodes and co nnect each /* Rows and columns are all sorted out, now iterate over all nodes and co nnect each
* to the node to its right and above. Once this is over, we'll have our torus! * to the node to its right and above. Once this is over, we'll have our torus!
* Special case for the last node (if the rows and columns are not equal) , connect * Special case for the last node (if the rows and columns are not equal) , connect
* to the first in the row to maintain topology. * to the first in the row to maintain topology.
*/ */
for (i = 0; i < pg->total; i++) for (i = 0; i < pg->total; i++)
{ {
/* First connect to the node to the right */ /* First connect to the node to the right */
if (((i + 1) % cols != 0) && (i + 1 != pg->total)) if (((i + 1) % cols != 0) && (i + 1 != pg->total))
nodeToConnect = i + 1; nodeToConnect = i + 1;
else if (i + 1 == pg->total) else if (i + 1 == pg->total)
nodeToConnect = rows * cols - cols; nodeToConnect = rows * cols - cols;
else else
nodeToConnect = i - cols + 1; nodeToConnect = i - cols + 1;
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n", i, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n", i,
nodeToConnect); nodeToConnect);
#endif
connect_attempts += proc (pg, i, nodeToConnect, list, GNUNET_YES); connect_attempts += proc (pg, i, nodeToConnect, list, GNUNET_YES);
/* Second connect to the node immediately above */ /* Second connect to the node immediately above */
if (i < cols) if (i < cols)
{ {
nodeToConnect = (rows * cols) - cols + i; nodeToConnect = (rows * cols) - cols + i;
if (nodeToConnect >= pg->total) if (nodeToConnect >= pg->total)
nodeToConnect -= cols; nodeToConnect -= cols;
} }
else else
nodeToConnect = i - cols; nodeToConnect = i - cols;
if (nodeToConnect < pg->total) if (nodeToConnect < pg->total)
{ {
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n ", i, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n ", i,
nodeToConnect); nodeToConnect);
#endif
connect_attempts += proc (pg, i, nodeToConnect, list, GNUNET_YES); connect_attempts += proc (pg, i, nodeToConnect, list, GNUNET_YES);
} }
} }
return connect_attempts; return connect_attempts;
} }
/** /**
* Create a topology given a peer group (set of running peers) * Create a topology given a peer group (set of running peers)
skipping to change at line 2481 skipping to change at line 2447
connect_attempts = 0; connect_attempts = 0;
conn_meter = conn_meter =
create_meter ((((pg->total * pg->total) + pg->total) / 2) - pg->total , create_meter ((((pg->total * pg->total) + pg->total) / 2) - pg->total ,
"Create Clique ", GNUNET_NO); "Create Clique ", GNUNET_NO);
for (outer_count = 0; outer_count < pg->total - 1; outer_count++) for (outer_count = 0; outer_count < pg->total - 1; outer_count++)
{ {
for (inner_count = outer_count + 1; inner_count < pg->total; inner_coun t++) for (inner_count = outer_count + 1; inner_count < pg->total; inner_coun t++)
{ {
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n ", GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n ",
outer_count, inner_count); outer_count, inner_count);
#endif
connect_attempts += proc (pg, outer_count, inner_count, list, check); connect_attempts += proc (pg, outer_count, inner_count, list, check);
update_meter (conn_meter); update_meter (conn_meter);
} }
} }
reset_meter (conn_meter); reset_meter (conn_meter);
free_meter (conn_meter); free_meter (conn_meter);
return connect_attempts; return connect_attempts;
} }
#if !OLD #if !OLD
skipping to change at line 2592 skipping to change at line 2556
create_line (struct GNUNET_TESTING_PeerGroup *pg, create_line (struct GNUNET_TESTING_PeerGroup *pg,
GNUNET_TESTING_ConnectionProcessor proc, enum PeerLists list) GNUNET_TESTING_ConnectionProcessor proc, enum PeerLists list)
{ {
unsigned int count; unsigned int count;
unsigned int connect_attempts; unsigned int connect_attempts;
connect_attempts = 0; connect_attempts = 0;
/* Connect each peer to the next highest numbered peer */ /* Connect each peer to the next highest numbered peer */
for (count = 0; count < pg->total - 1; count++) for (count = 0; count < pg->total - 1; count++)
{ {
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n", GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n",
count, count + 1); count, count + 1);
#endif
connect_attempts += proc (pg, count, count + 1, list, GNUNET_YES); connect_attempts += proc (pg, count, count + 1, list, GNUNET_YES);
} }
return connect_attempts; return connect_attempts;
} }
/** /**
* Create a topology given a peer group (set of running peers) * Create a topology given a peer group (set of running peers)
* and a connection processor. * and a connection processor.
* *
skipping to change at line 2677 skipping to change at line 2639
case NUM_PEERS: case NUM_PEERS:
errno = 0; errno = 0;
total_peers = strtoul (&buf[count], NULL, 10); total_peers = strtoul (&buf[count], NULL, 10);
if (errno != 0) if (errno != 0)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Failed to read number of peers from topology file!\n") ; "Failed to read number of peers from topology file!\n") ;
GNUNET_free (data); GNUNET_free (data);
return connect_attempts; return connect_attempts;
} }
#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found %u total peers in topolog y\n", GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found %u total peers in topolog y\n",
total_peers); total_peers);
#endif
GNUNET_assert (total_peers == pg->total); GNUNET_assert (total_peers == pg->total);
curr_state = PEER_INDEX; curr_state = PEER_INDEX;
while ((buf[count] != '\n') && (count < frstat.st_size - 1)) while ((buf[count] != '\n') && (count < frstat.st_size - 1))
count++; count++;
count++; count++;
break; break;
case PEER_INDEX: case PEER_INDEX:
errno = 0; errno = 0;
first_peer_index = strtoul (&buf[count], NULL, 10); first_peer_index = strtoul (&buf[count], NULL, 10);
if (errno != 0) if (errno != 0)
skipping to change at line 2771 skipping to change at line 2731
GNUNET_TESTING_ConnectionProcessor proc, enum PeerLists list) GNUNET_TESTING_ConnectionProcessor proc, enum PeerLists list)
{ {
unsigned int count; unsigned int count;
int connect_attempts; int connect_attempts;
connect_attempts = 0; connect_attempts = 0;
/* Connect each peer to the next highest numbered peer */ /* Connect each peer to the next highest numbered peer */
for (count = 0; count < pg->total - 1; count++) for (count = 0; count < pg->total - 1; count++)
{ {
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n", GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n",
count, count + 1); count, count + 1);
#endif
connect_attempts += proc (pg, count, count + 1, list, GNUNET_YES); connect_attempts += proc (pg, count, count + 1, list, GNUNET_YES);
} }
/* Connect the last peer to the first peer */ /* Connect the last peer to the first peer */
connect_attempts += proc (pg, pg->total - 1, 0, list, GNUNET_YES); connect_attempts += proc (pg, pg->total - 1, 0, list, GNUNET_YES);
return connect_attempts; return connect_attempts;
} }
#if !OLD #if !OLD
skipping to change at line 2929 skipping to change at line 2887
"SERVICEHOME", "PATHS"); "SERVICEHOME", "PATHS");
if (UNLINK (mytemp) != 0) if (UNLINK (mytemp) != 0)
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", myte mp); GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", myte mp);
GNUNET_free (mytemp); GNUNET_free (mytemp);
break; break;
} }
if (pg->peers[pg_iter].daemon->hostname == NULL) /* Local, just copy the file */ if (pg->peers[pg_iter].daemon->hostname == NULL) /* Local, just copy the file */
{ {
GNUNET_asprintf (&arg, "%s/friends", temp_service_path); GNUNET_asprintf (&arg, "%s/friends", temp_service_path);
procarr[pg_iter] =
GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "mv", "mv", mytemp,
arg, NULL);
GNUNET_assert (procarr[pg_iter] != NULL);
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Copying file with command cp %s %s\n", mytemp, arg); "Copying file with RENAME(%s,%s)\n", mytemp, arg);
#endif RENAME (mytemp, arg);
ret = GNUNET_OS_process_wait (procarr[pg_iter]); /* FIXME: schedule procarr[pg_iter] = NULL;
this, throttle! */
GNUNET_OS_process_close (procarr[pg_iter]);
GNUNET_free (arg); GNUNET_free (arg);
} }
else /* Remote, scp the file to the correct plac e */ else /* Remote, scp the file to the correct plac e */
{ {
if (NULL != pg->peers[pg_iter].daemon->username) if (NULL != pg->peers[pg_iter].daemon->username)
GNUNET_asprintf (&arg, "%s@%s:%s/friends", GNUNET_asprintf (&arg, "%s@%s:%s/friends",
pg->peers[pg_iter].daemon->username, pg->peers[pg_iter].daemon->username,
pg->peers[pg_iter].daemon->hostname, pg->peers[pg_iter].daemon->hostname,
temp_service_path); temp_service_path);
else else
GNUNET_asprintf (&arg, "%s:%s/friends", GNUNET_asprintf (&arg, "%s:%s/friends",
pg->peers[pg_iter].daemon->hostname, pg->peers[pg_iter].daemon->hostname,
temp_service_path); temp_service_path);
procarr[pg_iter] = procarr[pg_iter] =
GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "scp", "scp", mytemp , arg, NULL); GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "scp", "scp", mytemp , arg, NULL);
GNUNET_assert (procarr[pg_iter] != NULL); GNUNET_assert (procarr[pg_iter] != NULL);
ret = GNUNET_OS_process_wait (procarr[pg_iter]); /* FIXME: schedule this, throttle! */ ret = GNUNET_OS_process_wait (procarr[pg_iter]); /* FIXME: schedule this, throttle! */
GNUNET_OS_process_close (procarr[pg_iter]); GNUNET_OS_process_destroy (procarr[pg_iter]);
if (ret != GNUNET_OK) if (ret != GNUNET_OK)
{ {
/* FIXME: free contents of 'procarr' array */ /* FIXME: free contents of 'procarr' array */
GNUNET_free (procarr); GNUNET_free (procarr);
GNUNET_free (temp_service_path); GNUNET_free (temp_service_path);
GNUNET_free (mytemp); GNUNET_free (mytemp);
GNUNET_free (arg); GNUNET_free (arg);
return ret; return ret;
} }
procarr[pg_iter] = NULL; procarr[pg_iter] = NULL;
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Copying file with command scp %s %s\n", mytemp, arg); "Copying file with command scp %s %s\n", mytemp, arg);
#endif
GNUNET_free (arg); GNUNET_free (arg);
} }
GNUNET_free (temp_service_path); GNUNET_free (temp_service_path);
GNUNET_free (mytemp); GNUNET_free (mytemp);
} }
#if NOT_STUPID #if NOT_STUPID
count = 0; count = 0;
ret = GNUNET_SYSERR; ret = GNUNET_SYSERR;
while ((count < max_wait) && (ret != GNUNET_OK)) while ((count < max_wait) && (ret != GNUNET_OK))
{ {
ret = GNUNET_OK; ret = GNUNET_OK;
for (pg_iter = 0; pg_iter < pg->total; pg_iter++) for (pg_iter = 0; pg_iter < pg->total; pg_iter++)
{ {
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking copy status of file %d \n", GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking copy status of file %d \n",
pg_iter); pg_iter);
#endif
if (procarr[pg_iter] != NULL) /* Check for already completed! */ if (procarr[pg_iter] != NULL) /* Check for already completed! */
{ {
if (GNUNET_OS_process_status (procarr[pg_iter], &type, &return_code ) != if (GNUNET_OS_process_status (procarr[pg_iter], &type, &return_code ) !=
GNUNET_OK) GNUNET_OK)
{ {
ret = GNUNET_SYSERR; ret = GNUNET_SYSERR;
} }
else if ((type != GNUNET_OS_PROCESS_EXITED) || (return_code != 0)) else if ((type != GNUNET_OS_PROCESS_EXITED) || (return_code != 0))
{ {
ret = GNUNET_SYSERR; ret = GNUNET_SYSERR;
} }
else else
{ {
GNUNET_OS_process_close (procarr[pg_iter]); GNUNET_OS_process_destroy (procarr[pg_iter]);
procarr[pg_iter] = NULL; procarr[pg_iter] = NULL;
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "File %d copied\n", pg_iter) ; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "File %d copied\n", pg_iter) ;
#endif
} }
} }
} }
count++; count++;
if (ret == GNUNET_SYSERR) if (ret == GNUNET_SYSERR)
{ {
/* FIXME: why sleep here? -CG */ /* FIXME: why sleep here? -CG */
sleep (1); sleep (1);
} }
} }
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Finished copying all friend files!\n")); "Finished copying all friend files!\n");
#endif
#endif #endif
GNUNET_free (procarr); GNUNET_free (procarr);
return ret; return ret;
} }
/* /*
* Create the blacklist files based on the PeerConnection's * Create the blacklist files based on the PeerConnection's
* of each peer in the peer group, and copy the files * of each peer in the peer group, and copy the files
* to the appropriate place. * to the appropriate place.
* *
skipping to change at line 3128 skipping to change at line 3073
"SERVICEHOME", "PATHS"); "SERVICEHOME", "PATHS");
if (UNLINK (mytemp) != 0) if (UNLINK (mytemp) != 0)
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", myte mp); GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", myte mp);
GNUNET_free (mytemp); GNUNET_free (mytemp);
break; break;
} }
if (pg->peers[pg_iter].daemon->hostname == NULL) /* Local, just copy the file */ if (pg->peers[pg_iter].daemon->hostname == NULL) /* Local, just copy the file */
{ {
GNUNET_asprintf (&arg, "%s/blacklist", temp_service_path); GNUNET_asprintf (&arg, "%s/blacklist", temp_service_path);
procarr[pg_iter] = RENAME (mytemp, arg);
GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "mv", "mv", mytemp, procarr[pg_iter] = NULL;
arg, NULL);
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Copying file with command cp %s %s\n"), mytemp, arg); "Copying file with RENAME (%s,%s)\n", mytemp, arg);
#endif
GNUNET_free (arg); GNUNET_free (arg);
} }
else /* Remote, scp the file to the correct plac e */ else /* Remote, scp the file to the correct plac e */
{ {
if (NULL != pg->peers[pg_iter].daemon->username) if (NULL != pg->peers[pg_iter].daemon->username)
GNUNET_asprintf (&arg, "%s@%s:%s/blacklist", GNUNET_asprintf (&arg, "%s@%s:%s/blacklist",
pg->peers[pg_iter].daemon->username, pg->peers[pg_iter].daemon->username,
pg->peers[pg_iter].daemon->hostname, pg->peers[pg_iter].daemon->hostname,
temp_service_path); temp_service_path);
else else
GNUNET_asprintf (&arg, "%s:%s/blacklist", GNUNET_asprintf (&arg, "%s:%s/blacklist",
pg->peers[pg_iter].daemon->hostname, pg->peers[pg_iter].daemon->hostname,
temp_service_path); temp_service_path);
procarr[pg_iter] = procarr[pg_iter] =
GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "scp", "scp", mytemp , arg, NULL); GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "scp", "scp", mytemp , arg, NULL);
GNUNET_assert (procarr[pg_iter] != NULL); GNUNET_assert (procarr[pg_iter] != NULL);
GNUNET_OS_process_wait (procarr[pg_iter]); /* FIXME: add sched uled blacklist file copy that parallelizes file copying! */ GNUNET_OS_process_wait (procarr[pg_iter]); /* FIXME: add sched uled blacklist file copy that parallelizes file copying! */
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Copying file with command scp %s %s\n"), mytemp, arg); "Copying file with command scp %s %s\n", mytemp, arg);
#endif
GNUNET_free (arg); GNUNET_free (arg);
} }
GNUNET_free (temp_service_path); GNUNET_free (temp_service_path);
GNUNET_free (mytemp); GNUNET_free (mytemp);
} }
count = 0; count = 0;
ret = GNUNET_SYSERR; ret = GNUNET_SYSERR;
while ((count < max_wait) && (ret != GNUNET_OK)) while ((count < max_wait) && (ret != GNUNET_OK))
{ {
ret = GNUNET_OK; ret = GNUNET_OK;
for (pg_iter = 0; pg_iter < pg->total; pg_iter++) for (pg_iter = 0; pg_iter < pg->total; pg_iter++)
{ {
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Checking copy status of file %d\n"), pg_iter); "Checking copy status of file %d\n", pg_iter);
#endif
if (procarr[pg_iter] != NULL) /* Check for already completed! */ if (procarr[pg_iter] != NULL) /* Check for already completed! */
{ {
if (GNUNET_OS_process_status (procarr[pg_iter], &type, &return_code ) != if (GNUNET_OS_process_status (procarr[pg_iter], &type, &return_code ) !=
GNUNET_OK) GNUNET_OK)
{ {
ret = GNUNET_SYSERR; ret = GNUNET_SYSERR;
} }
else if ((type != GNUNET_OS_PROCESS_EXITED) || (return_code != 0)) else if ((type != GNUNET_OS_PROCESS_EXITED) || (return_code != 0))
{ {
ret = GNUNET_SYSERR; ret = GNUNET_SYSERR;
} }
else else
{ {
GNUNET_OS_process_close (procarr[pg_iter]); GNUNET_OS_process_destroy (procarr[pg_iter]);
procarr[pg_iter] = NULL; procarr[pg_iter] = NULL;
#if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "File %d copied\n", pg_iter)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("File %d copied\n"), pg_it ;
er);
#endif
} }
} }
} }
count++; count++;
if (ret == GNUNET_SYSERR) if (ret == GNUNET_SYSERR)
{ {
/* FIXME: why sleep here? -CG */ /* FIXME: why sleep here? -CG */
sleep (1); sleep (1);
} }
} }
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Finished copying all blacklist files!\n")); "Finished copying all blacklist files!\n");
#endif
GNUNET_free (procarr); GNUNET_free (procarr);
return ret; return ret;
} }
/* Forward Declaration */ /* Forward Declaration */
static void static void
schedule_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) ; schedule_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) ;
/** /**
* Choose a random peer's next connection to create, and * Choose a random peer's next connection to create, and
skipping to change at line 3403 skipping to change at line 3337
core_connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer, core_connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_ATS_Information *atsi) const struct GNUNET_ATS_Information *atsi)
{ {
struct SendHelloContext *send_hello_context = cls; struct SendHelloContext *send_hello_context = cls;
struct PeerConnection *connection; struct PeerConnection *connection;
struct GNUNET_TESTING_PeerGroup *pg = send_hello_context->pg; struct GNUNET_TESTING_PeerGroup *pg = send_hello_context->pg;
#if BAD #if BAD
struct PeerData *other_peer; struct PeerData *other_peer;
#endif #endif
#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected peer %s to peer %s\n", GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected peer %s to peer %s\n",
ctx->d1->shortname, GNUNET_i2s (peer)); ctx->d1->shortname, GNUNET_i2s (peer));
#endif
if (0 == if (0 ==
memcmp (&send_hello_context->peer->daemon->id, peer, memcmp (&send_hello_context->peer->daemon->id, peer,
sizeof (struct GNUNET_PeerIdentity))) sizeof (struct GNUNET_PeerIdentity)))
return; return;
connection = send_hello_context->peer->connect_peers_head; connection = send_hello_context->peer->connect_peers_head;
#if BAD #if BAD
other_peer = NULL; other_peer = NULL;
#endif #endif
skipping to change at line 3525 skipping to change at line 3456
struct SendHelloContext *send_hello_context = cls; struct SendHelloContext *send_hello_context = cls;
//unsigned int pg_iter; //unsigned int pg_iter;
if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
{ {
GNUNET_free (send_hello_context); GNUNET_free (send_hello_context);
return; return;
} }
send_hello_context->pg->remaining_hellos--; send_hello_context->pg->remaining_hellos--;
#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent HELLO, have %d remaining!\n", GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent HELLO, have %d remaining!\n",
send_hello_context->pg->remaining_hellos); send_hello_context->pg->remaining_hellos);
#endif
if (send_hello_context->peer_pos == NULL) /* All HELLOs (for this pee r!) have been transmitted! */ if (send_hello_context->peer_pos == NULL) /* All HELLOs (for this pee r!) have been transmitted! */
{ {
#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"All hellos for this peer sent, disconnecting transport!\n" ); "All hellos for this peer sent, disconnecting transport!\n" );
#endif
GNUNET_assert (send_hello_context->peer->daemon->th != NULL); GNUNET_assert (send_hello_context->peer->daemon->th != NULL);
GNUNET_TRANSPORT_disconnect (send_hello_context->peer->daemon->th); GNUNET_TRANSPORT_disconnect (send_hello_context->peer->daemon->th);
send_hello_context->peer->daemon->th = NULL; send_hello_context->peer->daemon->th = NULL;
GNUNET_assert (send_hello_context->peer->daemon->server == NULL); GNUNET_assert (send_hello_context->peer->daemon->server == NULL);
send_hello_context->peer->daemon->server = send_hello_context->peer->daemon->server =
GNUNET_CORE_connect (send_hello_context->peer->cfg, 1, GNUNET_CORE_connect (send_hello_context->peer->cfg, 1,
send_hello_context, &core_init, send_hello_context, &core_init,
&core_connect_notify, NULL, NULL, NULL, GNUNET _NO, &core_connect_notify, NULL, NULL, NULL, GNUNET _NO,
NULL, GNUNET_NO, no_handlers); NULL, GNUNET_NO, no_handlers);
skipping to change at line 3582 skipping to change at line 3509
GNUNET_free (send_hello_context); GNUNET_free (send_hello_context);
return; return;
} }
GNUNET_assert (send_hello_context->peer_pos != NULL); /* All of the HELLO sends to be scheduled have been scheduled! */ GNUNET_assert (send_hello_context->peer_pos != NULL); /* All of the HELLO sends to be scheduled have been scheduled! */
if (((send_hello_context->peer->daemon->th == NULL) && if (((send_hello_context->peer->daemon->th == NULL) &&
(pg->outstanding_connects > pg->max_outstanding_connections)) || (pg->outstanding_connects > pg->max_outstanding_connections)) ||
(pg->stop_connects == GNUNET_YES)) (pg->stop_connects == GNUNET_YES))
{ {
#if VERBOSE_TESTING > 2
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_ "Delaying connect, we have too many outstanding connections
("Delaying connect, we have too many outstanding connection !\n");
s!\n"));
#endif
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_MILLISECONDS, 100), (GNUNET_TIME_UNIT_MILLISECONDS, 100),
&schedule_send_hellos, send_hello_context ); &schedule_send_hellos, send_hello_context );
} }
else else
{ {
#if VERBOSE_TESTING > 2
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Creating connection, outstanding_connections is %d\n"), "Creating connection, outstanding_connections is %d\n",
outstanding_connects); outstanding_connects);
#endif
if (send_hello_context->peer->daemon->th == NULL) if (send_hello_context->peer->daemon->th == NULL)
{ {
pg->outstanding_connects++; /* Actual TRANSPORT, CORE connectio ns! */ pg->outstanding_connects++; /* Actual TRANSPORT, CORE connectio ns! */
send_hello_context->peer->daemon->th = send_hello_context->peer->daemon->th =
GNUNET_TRANSPORT_connect (send_hello_context->peer->cfg, NULL, GNUNET_TRANSPORT_connect (send_hello_context->peer->cfg, NULL,
send_hello_context, NULL, NULL, NULL); send_hello_context, NULL, NULL, NULL);
} }
#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Offering HELLO of peer %s to peer %s\n"), "Offering HELLO of peer %s to peer %s\n",
send_hello_context->peer->daemon->shortname, send_hello_context->peer->daemon->shortname,
pg->peers[send_hello_context->peer_pos->index]. pg->peers[send_hello_context->peer_pos->index].
daemon->shortname); daemon->shortname);
#endif
GNUNET_TRANSPORT_offer_hello (send_hello_context->peer->daemon->th, GNUNET_TRANSPORT_offer_hello (send_hello_context->peer->daemon->th,
(const struct GNUNET_MessageHeader *) (const struct GNUNET_MessageHeader *)
pg->peers[send_hello_context->peer_pos-> pg->peers[send_hello_context->peer_pos->
index].daemon->hello, index].daemon->hello,
&hello_sent_callback, send_hello_context) ; &hello_sent_callback, send_hello_context) ;
send_hello_context->peer_pos = send_hello_context->peer_pos->next; send_hello_context->peer_pos = send_hello_context->peer_pos->next;
GNUNET_assert (send_hello_context->peer->daemon->th != NULL); GNUNET_assert (send_hello_context->peer->daemon->th != NULL);
} }
} }
#endif #endif
skipping to change at line 3719 skipping to change at line 3639
struct ConnectContext *connect_context = cls; struct ConnectContext *connect_context = cls;
struct GNUNET_TESTING_PeerGroup *pg = connect_context->ct_ctx->pg; struct GNUNET_TESTING_PeerGroup *pg = connect_context->ct_ctx->pg;
connect_context->task = GNUNET_SCHEDULER_NO_TASK; connect_context->task = GNUNET_SCHEDULER_NO_TASK;
if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
return; return;
if ((pg->outstanding_connects > pg->max_outstanding_connections) || if ((pg->outstanding_connects > pg->max_outstanding_connections) ||
(pg->stop_connects == GNUNET_YES)) (pg->stop_connects == GNUNET_YES))
{ {
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_ "Delaying connect, we have too many outstanding connections
("Delaying connect, we have too many outstanding connection !\n");
s!\n"));
#endif
connect_context->task = connect_context->task =
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_MILLISECONDS, 100), (GNUNET_TIME_UNIT_MILLISECONDS, 100),
&schedule_connect, connect_context); &schedule_connect, connect_context);
return; return;
} }
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_ "Creating connection, outstanding_connections is %d (max %d)\
("Creating connection, outstanding_connections is %d (max %d) n",
\n"),
pg->outstanding_connects, pg->max_outstanding_connections); pg->outstanding_connects, pg->max_outstanding_connections);
#endif
pg->outstanding_connects++; pg->outstanding_connects++;
pg->total_connects_scheduled++; pg->total_connects_scheduled++;
GNUNET_assert (NULL == connect_context->cc); GNUNET_assert (NULL == connect_context->cc);
connect_context->cc = connect_context->cc =
GNUNET_TESTING_daemons_connect (pg-> GNUNET_TESTING_daemons_connect (pg->
peers[connect_context-> peers[connect_context->
first_index].daemon, first_index].daemon,
pg->peers[connect_context-> pg->peers[connect_context->
second_index].daemon, second_index].daemon,
connect_context->ct_ctx->connect_time out, connect_context->ct_ctx->connect_time out,
skipping to change at line 3987 skipping to change at line 3901
pg->peers[i].allowed_peers = GNUNET_CONTAINER_multihashmap_create (100) ; pg->peers[i].allowed_peers = GNUNET_CONTAINER_multihashmap_create (100) ;
pg->peers[i].connect_peers = GNUNET_CONTAINER_multihashmap_create (100) ; pg->peers[i].connect_peers = GNUNET_CONTAINER_multihashmap_create (100) ;
pg->peers[i].blacklisted_peers = GNUNET_CONTAINER_multihashmap_create ( 100); pg->peers[i].blacklisted_peers = GNUNET_CONTAINER_multihashmap_create ( 100);
pg->peers[i].pg = pg; pg->peers[i].pg = pg;
} }
#endif #endif
switch (topology) switch (topology)
{ {
case GNUNET_TESTING_TOPOLOGY_CLIQUE: case GNUNET_TESTING_TOPOLOGY_CLIQUE:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Creating clique topology\n")); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating clique topology\n");
num_connections = create_clique (pg, &add_connections, ALLOWED, GNUNET_ NO); num_connections = create_clique (pg, &add_connections, ALLOWED, GNUNET_ NO);
break; break;
case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING: case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Creating small world (ring) topology\n")); "Creating small world (ring) topology\n");
num_connections = create_small_world_ring (pg, &add_connections, ALLOWE D); num_connections = create_small_world_ring (pg, &add_connections, ALLOWE D);
break; break;
case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD: case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Creating small world (2d-torus) topology\n")); "Creating small world (2d-torus) topology\n");
num_connections = create_small_world (pg, &add_connections, ALLOWED); num_connections = create_small_world (pg, &add_connections, ALLOWED);
break; break;
case GNUNET_TESTING_TOPOLOGY_RING: case GNUNET_TESTING_TOPOLOGY_RING:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Creating ring topology\n")); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating ring topology\n");
num_connections = create_ring (pg, &add_connections, ALLOWED); num_connections = create_ring (pg, &add_connections, ALLOWED);
break; break;
case GNUNET_TESTING_TOPOLOGY_2D_TORUS: case GNUNET_TESTING_TOPOLOGY_2D_TORUS:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Creating 2d torus topology\n")) ; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating 2d torus topology\n");
num_connections = create_2d_torus (pg, &add_connections, ALLOWED); num_connections = create_2d_torus (pg, &add_connections, ALLOWED);
break; break;
case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI: case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Creating Erdos-Renyi topology\n ")); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating Erdos-Renyi topology\n") ;
num_connections = create_erdos_renyi (pg, &add_connections, ALLOWED); num_connections = create_erdos_renyi (pg, &add_connections, ALLOWED);
break; break;
case GNUNET_TESTING_TOPOLOGY_INTERNAT: case GNUNET_TESTING_TOPOLOGY_INTERNAT:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Creating InterNAT topology\n")) ; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating InterNAT topology\n");
num_connections = create_nated_internet (pg, &add_connections, ALLOWED) ; num_connections = create_nated_internet (pg, &add_connections, ALLOWED) ;
break; break;
case GNUNET_TESTING_TOPOLOGY_SCALE_FREE: case GNUNET_TESTING_TOPOLOGY_SCALE_FREE:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Creating Scale Free topology\n" )); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating Scale Free topology\n");
num_connections = create_scale_free (pg, &add_connections, ALLOWED); num_connections = create_scale_free (pg, &add_connections, ALLOWED);
break; break;
case GNUNET_TESTING_TOPOLOGY_LINE: case GNUNET_TESTING_TOPOLOGY_LINE:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Creating straight line topology\n")); "Creating straight line topology\n");
num_connections = create_line (pg, &add_connections, ALLOWED); num_connections = create_line (pg, &add_connections, ALLOWED);
break; break;
case GNUNET_TESTING_TOPOLOGY_FROM_FILE: case GNUNET_TESTING_TOPOLOGY_FROM_FILE:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Creating topology from file!\n" )); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating topology from file!\n");
if (GNUNET_OK == if (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_string (pg->cfg, "testing", GNUNET_CONFIGURATION_get_value_string (pg->cfg, "testing",
"topology_file", &filename)) "topology_file", &filename))
num_connections = num_connections =
create_from_file (pg, filename, &add_connections, ALLOWED); create_from_file (pg, filename, &add_connections, ALLOWED);
else else
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Missing configuration option TESTING:TOPOLOGY_FILE for c reating topology from file!\n"); "Missing configuration option TESTING:TOPOLOGY_FILE for c reating topology from file!\n");
num_connections = 0; num_connections = 0;
skipping to change at line 4057 skipping to change at line 3971
break; break;
} }
if (GNUNET_YES == if (GNUNET_YES ==
GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "TESTING", "F2F")) GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "TESTING", "F2F"))
{ {
ret = create_and_copy_friend_files (pg); ret = create_and_copy_friend_files (pg);
if (ret != GNUNET_OK) if (ret != GNUNET_OK)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Failed during friend file copying!\n")); "Failed during friend file copying!\n");
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
else else
{ {
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Friend files created/copied successfully!\n")); "Friend files created/copied successfully!\n");
} }
} }
/* Use the create clique method to initially set all connections as black listed. */ /* Use the create clique method to initially set all connections as black listed. */
if ((restrict_topology != GNUNET_TESTING_TOPOLOGY_NONE) && if ((restrict_topology != GNUNET_TESTING_TOPOLOGY_NONE) &&
(restrict_topology != GNUNET_TESTING_TOPOLOGY_FROM_FILE)) (restrict_topology != GNUNET_TESTING_TOPOLOGY_FROM_FILE))
create_clique (pg, &add_connections, BLACKLIST, GNUNET_NO); create_clique (pg, &add_connections, BLACKLIST, GNUNET_NO);
else else
return num_connections; return num_connections;
unblacklisted_connections = 0; unblacklisted_connections = 0;
/* Un-blacklist connections as per the topology specified */ /* Un-blacklist connections as per the topology specified */
switch (restrict_topology) switch (restrict_topology)
{ {
case GNUNET_TESTING_TOPOLOGY_CLIQUE: case GNUNET_TESTING_TOPOLOGY_CLIQUE:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Blacklisting all but clique topology\n")); "Blacklisting all but clique topology\n");
unblacklisted_connections = unblacklisted_connections =
create_clique (pg, &remove_connections, BLACKLIST, GNUNET_NO); create_clique (pg, &remove_connections, BLACKLIST, GNUNET_NO);
break; break;
case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING: case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Blacklisting all but small world (ring) topology\n")); "Blacklisting all but small world (ring) topology\n");
unblacklisted_connections = unblacklisted_connections =
create_small_world_ring (pg, &remove_connections, BLACKLIST); create_small_world_ring (pg, &remove_connections, BLACKLIST);
break; break;
case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD: case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Blacklisting all but small world (2d-torus) topology\n") ); "Blacklisting all but small world (2d-torus) topology\n");
unblacklisted_connections = unblacklisted_connections =
create_small_world (pg, &remove_connections, BLACKLIST); create_small_world (pg, &remove_connections, BLACKLIST);
break; break;
case GNUNET_TESTING_TOPOLOGY_RING: case GNUNET_TESTING_TOPOLOGY_RING:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Blacklisting all but ring topology\n")); "Blacklisting all but ring topology\n");
unblacklisted_connections = unblacklisted_connections =
create_ring (pg, &remove_connections, BLACKLIST); create_ring (pg, &remove_connections, BLACKLIST);
break; break;
case GNUNET_TESTING_TOPOLOGY_2D_TORUS: case GNUNET_TESTING_TOPOLOGY_2D_TORUS:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Blacklisting all but 2d torus topology\n")); "Blacklisting all but 2d torus topology\n");
unblacklisted_connections = unblacklisted_connections =
create_2d_torus (pg, &remove_connections, BLACKLIST); create_2d_torus (pg, &remove_connections, BLACKLIST);
break; break;
case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI: case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Blacklisting all but Erdos-Renyi topology\n")); "Blacklisting all but Erdos-Renyi topology\n");
unblacklisted_connections = unblacklisted_connections =
create_erdos_renyi (pg, &remove_connections, BLACKLIST); create_erdos_renyi (pg, &remove_connections, BLACKLIST);
break; break;
case GNUNET_TESTING_TOPOLOGY_INTERNAT: case GNUNET_TESTING_TOPOLOGY_INTERNAT:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Blacklisting all but InterNAT topology\n")); "Blacklisting all but InterNAT topology\n");
#if TOPOLOGY_HACK #if TOPOLOGY_HACK
for (off = 0; off < pg->total; off++) for (off = 0; off < pg->total; off++)
{ {
conn_iter = pg->peers[off].allowed_peers_head; conn_iter = pg->peers[off].allowed_peers_head;
while (conn_iter != NULL) while (conn_iter != NULL)
{ {
temp_conn = conn_iter->next; temp_conn = conn_iter->next;
GNUNET_free (conn_iter); GNUNET_free (conn_iter);
conn_iter = temp_conn; conn_iter = temp_conn;
skipping to change at line 4151 skipping to change at line 4065
unblacklisted_connections = unblacklisted_connections =
create_nated_internet_copy (pg, &remove_connections, BLACKLIST); create_nated_internet_copy (pg, &remove_connections, BLACKLIST);
#else #else
unblacklisted_connections = unblacklisted_connections =
create_nated_internet (pg, &remove_connections, BLACKLIST); create_nated_internet (pg, &remove_connections, BLACKLIST);
#endif #endif
break; break;
case GNUNET_TESTING_TOPOLOGY_SCALE_FREE: case GNUNET_TESTING_TOPOLOGY_SCALE_FREE:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Blacklisting all but Scale Free topology\n")); "Blacklisting all but Scale Free topology\n");
unblacklisted_connections = unblacklisted_connections =
create_scale_free (pg, &remove_connections, BLACKLIST); create_scale_free (pg, &remove_connections, BLACKLIST);
break; break;
case GNUNET_TESTING_TOPOLOGY_LINE: case GNUNET_TESTING_TOPOLOGY_LINE:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Blacklisting all but straight line topology\n")); "Blacklisting all but straight line topology\n");
unblacklisted_connections = unblacklisted_connections =
create_line (pg, &remove_connections, BLACKLIST); create_line (pg, &remove_connections, BLACKLIST);
default: default:
break; break;
} }
if ((unblacklisted_connections > 0) && (restrict_transports != NULL)) if ((unblacklisted_connections > 0) && (restrict_transports != NULL))
{ {
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating blacklist with `%s'\n", GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating blacklist with `%s'\n",
restrict_transports); restrict_transports);
ret = create_and_copy_blacklist_files (pg, restrict_transports); ret = create_and_copy_blacklist_files (pg, restrict_transports);
if (ret != GNUNET_OK) if (ret != GNUNET_OK)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Failed during blacklist file copying!\n")); "Failed during blacklist file copying!\n");
return 0; return 0;
} }
else else
{ {
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Blacklist files created/copied successfully!\n")); "Blacklist files created/copied successfully!\n");
} }
} }
return num_connections; return num_connections;
} }
#if !OLD #if !OLD
/** /**
* Iterator for choosing random peers to connect. * Iterator for choosing random peers to connect.
* *
* @param cls closure, a RandomContext * @param cls closure, a RandomContext
skipping to change at line 4880 skipping to change at line 4794
{ {
struct CoreContext *core_context = cls; struct CoreContext *core_context = cls;
struct TopologyIterateContext *topology_context = struct TopologyIterateContext *topology_context =
(struct TopologyIterateContext *) core_context->iter_context; (struct TopologyIterateContext *) core_context->iter_context;
if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
return; return;
if (topology_context->connected > if (topology_context->connected >
topology_context->pg->max_outstanding_connections) topology_context->pg->max_outstanding_connections)
{ {
#if VERBOSE_TESTING > 2
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_ "Delaying connect, we have too many outstanding connections
("Delaying connect, we have too many outstanding connection !\n");
s!\n"));
#endif
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_MILLISECONDS, 100), (GNUNET_TIME_UNIT_MILLISECONDS, 100),
&schedule_get_topology, core_context); &schedule_get_topology, core_context);
} }
else else
{ {
#if VERBOSE_TESTING > 2
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Creating connection, outstanding_connections is %d\n"),
outstanding_connects);
#endif
topology_context->connected++; topology_context->connected++;
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_CORE_iterate_peers (core_context->daemon->cfg, GNUNET_CORE_iterate_peers (core_context->daemon->cfg,
&internal_topology_callback, core_contex t)) &internal_topology_callback, core_contex t))
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Topology iteration failed.\n" ); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Topology iteration failed.\n" );
internal_topology_callback (core_context, NULL, NULL, 0); internal_topology_callback (core_context, NULL, NULL, 0);
} }
} }
skipping to change at line 4976 skipping to change at line 4882
{ {
struct StatsCoreContext *core_context = cls; struct StatsCoreContext *core_context = cls;
struct StatsIterateContext *stats_context = struct StatsIterateContext *stats_context =
(struct StatsIterateContext *) core_context->iter_context; (struct StatsIterateContext *) core_context->iter_context;
return stats_context->proc (stats_context->cls, &core_context->daemon->id , return stats_context->proc (stats_context->cls, &core_context->daemon->id ,
subsystem, name, value, is_persistent); subsystem, name, value, is_persistent);
} }
/** /**
* We don't need the statistics handle anymore, destroy it.
*
* @param cls Closure (the statistics handle to destroy)
* @param tc Task Context
*/
static void
internal_destroy_statistics (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct GNUNET_STATISTICS_Handle *h = cls;
GNUNET_STATISTICS_destroy (h, GNUNET_NO);
}
/**
* Internal continuation call for statistics iteration. * Internal continuation call for statistics iteration.
* *
* @param cls closure, the CoreContext for this iteration * @param cls closure, the CoreContext for this iteration
* @param success whether or not the statistics iterations * @param success whether or not the statistics iterations
* was canceled or not (we don't care) * was canceled or not (we don't care)
*/ */
static void static void
internal_stats_cont (void *cls, int success) internal_stats_cont (void *cls, int success)
{ {
struct StatsCoreContext *core_context = cls; struct StatsCoreContext *core_context = cls;
skipping to change at line 4999 skipping to change at line 4920
stats_context->connected--; stats_context->connected--;
stats_context->completed++; stats_context->completed++;
if (stats_context->completed == stats_context->total) if (stats_context->completed == stats_context->total)
{ {
stats_context->cont (stats_context->cls, GNUNET_YES); stats_context->cont (stats_context->cls, GNUNET_YES);
GNUNET_free (stats_context); GNUNET_free (stats_context);
} }
if (core_context->stats_handle != NULL) if (core_context->stats_handle != NULL)
GNUNET_STATISTICS_destroy (core_context->stats_handle, GNUNET_NO); /* Cannot destroy handle inside the continuation */
GNUNET_SCHEDULER_add_now (&internal_destroy_statistics,
core_context->stats_handle);
GNUNET_free (core_context); GNUNET_free (core_context);
} }
/** /**
* Check running topology iteration tasks, if below max start a new one, ot herwise * Check running topology iteration tasks, if below max start a new one, ot herwise
* schedule for some time in the future. * schedule for some time in the future.
*/ */
static void static void
schedule_get_statistics (void *cls, schedule_get_statistics (void *cls,
skipping to change at line 5021 skipping to change at line 4944
{ {
struct StatsCoreContext *core_context = cls; struct StatsCoreContext *core_context = cls;
struct StatsIterateContext *stats_context = struct StatsIterateContext *stats_context =
(struct StatsIterateContext *) core_context->iter_context; (struct StatsIterateContext *) core_context->iter_context;
if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
return; return;
if (stats_context->connected > stats_context->pg->max_outstanding_connect ions) if (stats_context->connected > stats_context->pg->max_outstanding_connect ions)
{ {
#if VERBOSE_TESTING > 2
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_ "Delaying connect, we have too many outstanding connections
("Delaying connect, we have too many outstanding connection !\n");
s!\n"));
#endif
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_MILLISECONDS, 100), (GNUNET_TIME_UNIT_MILLISECONDS, 100),
&schedule_get_statistics, core_context); &schedule_get_statistics, core_context);
} }
else else
{ {
#if VERBOSE_TESTING > 2
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Creating connection, outstanding_connections is %d\n"),
outstanding_connects);
#endif
stats_context->connected++; stats_context->connected++;
core_context->stats_handle = core_context->stats_handle =
GNUNET_STATISTICS_create ("testing", core_context->daemon->cfg); GNUNET_STATISTICS_create ("testing", core_context->daemon->cfg);
if (core_context->stats_handle == NULL) if (core_context->stats_handle == NULL)
{ {
internal_stats_cont (core_context, GNUNET_NO); internal_stats_cont (core_context, GNUNET_NO);
return; return;
} }
core_context->stats_get_handle = core_context->stats_get_handle =
GNUNET_STATISTICS_get (core_context->stats_handle, NULL, NULL, GNUNET_STATISTICS_get (core_context->stats_handle, NULL, NULL,
GNUNET_TIME_relative_get_forever (), GNUNET_TIME_UNIT_FOREVER_REL,
&internal_stats_cont, &internal_stats_callba ck, &internal_stats_cont, &internal_stats_callba ck,
core_context); core_context);
if (core_context->stats_get_handle == NULL) if (core_context->stats_get_handle == NULL)
internal_stats_cont (core_context, GNUNET_NO); internal_stats_cont (core_context, GNUNET_NO);
} }
} }
struct DuplicateStats struct DuplicateStats
{ {
skipping to change at line 5260 skipping to change at line 5174
enum GNUNET_TESTING_TopologyOption options , enum GNUNET_TESTING_TopologyOption options ,
double option_modifier, double option_modifier,
struct GNUNET_TIME_Relative connect_timeou t, struct GNUNET_TIME_Relative connect_timeou t,
unsigned int connect_attempts, unsigned int connect_attempts,
GNUNET_TESTING_NotifyCompletion GNUNET_TESTING_NotifyCompletion
notify_callback, void *notify_cls) notify_callback, void *notify_cls)
{ {
switch (topology) switch (topology)
{ {
case GNUNET_TESTING_TOPOLOGY_CLIQUE: case GNUNET_TESTING_TOPOLOGY_CLIQUE:
#if VERBOSE_TOPOLOGY
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Creating clique CONNECT topology\n")); "Creating clique CONNECT topology\n");
#endif
create_clique (pg, &add_connections, CONNECT, GNUNET_NO); create_clique (pg, &add_connections, CONNECT, GNUNET_NO);
break; break;
case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING: case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING:
#if VERBOSE_TOPOLOGY
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Creating small world (ring) CONNECT topology\n")); "Creating small world (ring) CONNECT topology\n");
#endif
create_small_world_ring (pg, &add_connections, CONNECT); create_small_world_ring (pg, &add_connections, CONNECT);
break; break;
case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD: case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD:
#if VERBOSE_TOPOLOGY
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Creating small world (2d-torus) CONNECT topology\n")); "Creating small world (2d-torus) CONNECT topology\n");
#endif
create_small_world (pg, &add_connections, CONNECT); create_small_world (pg, &add_connections, CONNECT);
break; break;
case GNUNET_TESTING_TOPOLOGY_RING: case GNUNET_TESTING_TOPOLOGY_RING:
#if VERBOSE_TOPOLOGY GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating ring CONNECT topology\n"
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Creating ring CONNECT topology\ );
n"));
#endif
create_ring (pg, &add_connections, CONNECT); create_ring (pg, &add_connections, CONNECT);
break; break;
case GNUNET_TESTING_TOPOLOGY_2D_TORUS: case GNUNET_TESTING_TOPOLOGY_2D_TORUS:
#if VERBOSE_TOPOLOGY
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Creating 2d torus CONNECT topology\n")); "Creating 2d torus CONNECT topology\n");
#endif
create_2d_torus (pg, &add_connections, CONNECT); create_2d_torus (pg, &add_connections, CONNECT);
break; break;
case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI: case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI:
#if VERBOSE_TOPOLOGY
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Creating Erdos-Renyi CONNECT topology\n")); "Creating Erdos-Renyi CONNECT topology\n");
#endif
create_erdos_renyi (pg, &add_connections, CONNECT); create_erdos_renyi (pg, &add_connections, CONNECT);
break; break;
case GNUNET_TESTING_TOPOLOGY_INTERNAT: case GNUNET_TESTING_TOPOLOGY_INTERNAT:
#if VERBOSE_TOPOLOGY
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Creating InterNAT CONNECT topology\n")); "Creating InterNAT CONNECT topology\n");
#endif
create_nated_internet (pg, &add_connections, CONNECT); create_nated_internet (pg, &add_connections, CONNECT);
break; break;
case GNUNET_TESTING_TOPOLOGY_SCALE_FREE: case GNUNET_TESTING_TOPOLOGY_SCALE_FREE:
#if VERBOSE_TOPOLOGY
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Creating Scale Free CONNECT topology\n")); "Creating Scale Free CONNECT topology\n");
#endif
create_scale_free (pg, &add_connections, CONNECT); create_scale_free (pg, &add_connections, CONNECT);
break; break;
case GNUNET_TESTING_TOPOLOGY_LINE: case GNUNET_TESTING_TOPOLOGY_LINE:
#if VERBOSE_TOPOLOGY
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Creating straight line CONNECT topology\n")); "Creating straight line CONNECT topology\n");
#endif
create_line (pg, &add_connections, CONNECT); create_line (pg, &add_connections, CONNECT);
break; break;
case GNUNET_TESTING_TOPOLOGY_NONE: case GNUNET_TESTING_TOPOLOGY_NONE:
#if VERBOSE_TOPOLOGY GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating no CONNECT topology\n");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Creating no CONNECT topology\n"
));
#endif
copy_allowed_topology (pg); copy_allowed_topology (pg);
break; break;
default: default:
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_("Unknown topology specification, can't connect peers!\n") ); _("Unknown topology specification, can't connect peers!\n") );
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
switch (options) switch (options)
{ {
case GNUNET_TESTING_TOPOLOGY_OPTION_RANDOM: case GNUNET_TESTING_TOPOLOGY_OPTION_RANDOM:
#if VERBOSE_TOPOLOGY
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_ "Connecting random subset (%'.2f percent) of possible peers
("Connecting random subset (%'.2f percent) of possible peer \n",
s\n"),
100 * option_modifier); 100 * option_modifier);
#endif
choose_random_connections (pg, option_modifier); choose_random_connections (pg, option_modifier);
break; break;
case GNUNET_TESTING_TOPOLOGY_OPTION_MINIMUM: case GNUNET_TESTING_TOPOLOGY_OPTION_MINIMUM:
#if VERBOSE_TOPOLOGY
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Connecting a minimum of %u peers each (if possible)\n"), "Connecting a minimum of %u peers each (if possible)\n",
(unsigned int) option_modifier); (unsigned int) option_modifier);
#endif
choose_minimum (pg, (unsigned int) option_modifier); choose_minimum (pg, (unsigned int) option_modifier);
break; break;
case GNUNET_TESTING_TOPOLOGY_OPTION_DFS: case GNUNET_TESTING_TOPOLOGY_OPTION_DFS:
#if VERBOSE_TOPOLOGY
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_ "Using DFS to connect a minimum of %u peers each (if possib
("Using DFS to connect a minimum of %u peers each (if possi le)\n",
ble)\n"),
(unsigned int) option_modifier); (unsigned int) option_modifier);
#endif
#if FIXME #if FIXME
perform_dfs (pg, (int) option_modifier); perform_dfs (pg, (int) option_modifier);
#endif #endif
break; break;
case GNUNET_TESTING_TOPOLOGY_OPTION_ADD_CLOSEST: case GNUNET_TESTING_TOPOLOGY_OPTION_ADD_CLOSEST:
#if VERBOSE_TOPOLOGY GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Finding additional %u closest peers each (if possible)\n",
_("Finding additional %u closest peers each (if possible)\n
"),
(unsigned int) option_modifier); (unsigned int) option_modifier);
#endif
#if FIXME #if FIXME
add_closest (pg, (unsigned int) option_modifier, &add_connections, CONN ECT); add_closest (pg, (unsigned int) option_modifier, &add_connections, CONN ECT);
#endif #endif
break; break;
case GNUNET_TESTING_TOPOLOGY_OPTION_NONE: case GNUNET_TESTING_TOPOLOGY_OPTION_NONE:
break; break;
case GNUNET_TESTING_TOPOLOGY_OPTION_ALL: case GNUNET_TESTING_TOPOLOGY_OPTION_ALL:
break; break;
default: default:
break; break;
skipping to change at line 5420 skipping to change at line 5304
* @param pg the peergroup that the host belongs to * @param pg the peergroup that the host belongs to
* *
*/ */
static void static void
increment_outstanding_at_host (const char *hostname, increment_outstanding_at_host (const char *hostname,
struct GNUNET_TESTING_PeerGroup *pg) struct GNUNET_TESTING_PeerGroup *pg)
{ {
struct OutstandingSSH *pos; struct OutstandingSSH *pos;
pos = pg->ssh_head; pos = pg->ssh_head;
while ((pos != NULL) && (strcmp (pos->hostname, hostname) != 0)) while ((NULL != pos) && (strcmp (pos->hostname, hostname) != 0))
pos = pos->next; pos = pos->next;
GNUNET_assert (pos != NULL); GNUNET_assert (NULL != pos);
pos->outstanding++; pos->outstanding++;
} }
/** /**
* Decrement the number of SSH connections to a host by one. * Decrement the number of SSH connections to a host by one.
* *
* @param hostname the hostname to lookup in the list * @param hostname the hostname to lookup in the list
* @param pg the peergroup that the host belongs to * @param pg the peergroup that the host belongs to
* *
*/ */
skipping to change at line 5781 skipping to change at line 5665
else else
cb (helper->pg->peers[i].daemon->cb_cls, cb (helper->pg->peers[i].daemon->cb_cls,
&helper->pg->peers[i].daemon->id, &helper->pg->peers[i].daemon->id,
helper->pg->peers[i].daemon->cfg, helper->pg->peers[i].daemon , helper->pg->peers[i].daemon->cfg, helper->pg->peers[i].daemon ,
NULL); NULL);
} }
} }
} }
GNUNET_OS_process_close (helper->proc); GNUNET_OS_process_destroy (helper->proc);
} }
static void static void
start_peer_helper (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc ) start_peer_helper (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc )
{ {
struct PeerStartHelperContext *helper = cls; struct PeerStartHelperContext *helper = cls;
char *baseservicehome; char *baseservicehome;
char *tempdir; char *tempdir;
char *arg; char *arg;
skipping to change at line 5809 skipping to change at line 5693
GNUNET_asprintf (&arg, "%s@%s", helper->host->username, GNUNET_asprintf (&arg, "%s@%s", helper->host->username,
helper->host->hostname); helper->host->hostname);
else else
GNUNET_asprintf (&arg, "%s", helper->host->hostname); GNUNET_asprintf (&arg, "%s", helper->host->hostname);
/* FIXME: Doesn't support ssh_port option! */ /* FIXME: Doesn't support ssh_port option! */
helper->proc = helper->proc =
GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", arg, GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", arg,
"peerStartHelper.pl", tempdir, NULL); "peerStartHelper.pl", tempdir, NULL);
GNUNET_assert (helper->proc != NULL); GNUNET_assert (helper->proc != NULL);
#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "starting peers with cmd ssh %s %s % s\n", GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "starting peers with cmd ssh %s %s % s\n",
arg, "peerStartHelper.pl", tempdir); arg, "peerStartHelper.pl", tempdir);
#endif
GNUNET_SCHEDULER_add_now (&check_peers_started, helper); GNUNET_SCHEDULER_add_now (&check_peers_started, helper);
GNUNET_free (tempdir); GNUNET_free (tempdir);
GNUNET_free (baseservicehome); GNUNET_free (baseservicehome);
GNUNET_free (arg); GNUNET_free (arg);
} }
#endif #endif
/** /**
* Function which continues a peer group starting up * Function which continues a peer group starting up
* after successfully generating hostkeys for each peer. * after successfully generating hostkeys for each peer.
skipping to change at line 6032 skipping to change at line 5914
if (NULL != pg->hosts[i].username) if (NULL != pg->hosts[i].username)
GNUNET_asprintf (&arg, "%s@%s", pg->hosts[i].username, GNUNET_asprintf (&arg, "%s@%s", pg->hosts[i].username,
pg->hosts[i].hostname); pg->hosts[i].hostname);
else else
GNUNET_asprintf (&arg, "%s", pg->hosts[i].hostname); GNUNET_asprintf (&arg, "%s", pg->hosts[i].hostname);
if (pg->hosts[i].sshport != 0) if (pg->hosts[i].sshport != 0)
{ {
GNUNET_asprintf (&ssh_port_str, "%d", pg->hosts[i].sshport); GNUNET_asprintf (&ssh_port_str, "%d", pg->hosts[i].sshport);
proc = proc =
GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", "-P", ssh_port_str, GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", "-P", ssh_port_str,
#if !DEBUG_TESTING
"-q", "-q",
#endif
arg, "mkdir -p", tmpdir, NULL); arg, "mkdir -p", tmpdir, NULL);
} }
else else
proc = proc =
GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", arg, " mkdir -p", GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", arg, " mkdir -p",
tmpdir, NULL); tmpdir, NULL);
GNUNET_assert (proc != NULL); GNUNET_assert (proc != NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Creating remote dir with command ssh %s %s %s\n", arg, "Creating remote dir with command ssh %s %s %s\n", arg,
" mkdir -p ", tmpdir); " mkdir -p ", tmpdir);
GNUNET_free (tmpdir); GNUNET_free (tmpdir);
GNUNET_free (arg); GNUNET_free (arg);
GNUNET_OS_process_wait (proc); GNUNET_OS_process_wait (proc);
GNUNET_OS_process_close (proc); GNUNET_OS_process_destroy (proc);
} }
GNUNET_free (baseservicehome); GNUNET_free (baseservicehome);
baseservicehome = NULL; baseservicehome = NULL;
if (GNUNET_YES == if (GNUNET_YES ==
GNUNET_CONFIGURATION_get_value_string (cfg, "TESTING", "HOSTKEYSFILE" , GNUNET_CONFIGURATION_get_value_string (cfg, "TESTING", "HOSTKEYSFILE" ,
&hostkeys_file)) &hostkeys_file))
{ {
if (GNUNET_YES != GNUNET_DISK_file_test (hostkeys_file)) if (GNUNET_YES != GNUNET_DISK_file_test (hostkeys_file))
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
skipping to change at line 6081 skipping to change at line 5961
{ {
GNUNET_free (pg->hosts[i].hostname); GNUNET_free (pg->hosts[i].hostname);
GNUNET_free_non_null (pg->hosts[i].username); GNUNET_free_non_null (pg->hosts[i].username);
} }
GNUNET_free (pg->peers); GNUNET_free (pg->peers);
GNUNET_free (pg->hosts); GNUNET_free (pg->hosts);
GNUNET_free (pg); GNUNET_free (pg);
return NULL; return NULL;
} }
if (GNUNET_YES != GNUNET_DISK_file_size (hostkeys_file, &fs, GNUNET_Y ES)) if (GNUNET_OK != GNUNET_DISK_file_size (hostkeys_file, &fs, GNUNET_YE S, GNUNET_YES))
fs = 0; fs = 0;
#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Found file size %llu for hostkeys\n", fs); "Found file size %llu for hostkeys\n", fs);
#endif
if (0 != (fs % HOSTKEYFILESIZE)) if (0 != (fs % HOSTKEYFILESIZE))
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"File size %llu seems incorrect for hostkeys...\n", fs) ; "File size %llu seems incorrect for hostkeys...\n", fs) ;
} }
else else
{ {
total_hostkeys = fs / HOSTKEYFILESIZE; total_hostkeys = fs / HOSTKEYFILESIZE;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Will read %llu hostkeys from file\n", total_hostkeys); "Will read %llu hostkeys from file\n", total_hostkeys);
skipping to change at line 6229 skipping to change at line 6107
{ {
hostname = NULL; hostname = NULL;
username = NULL; username = NULL;
sshport = 0; sshport = 0;
} }
if (GNUNET_YES == if (GNUNET_YES ==
GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "SERVICEHOME ", GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "SERVICEHOME ",
&baseservicehome)) &baseservicehome))
{ {
#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "baseservice home is %s\n", GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "baseservice home is %s\n",
baseservicehome); baseservicehome);
#endif
if (hostname != NULL) if (hostname != NULL)
GNUNET_asprintf (&newservicehome, "%s/%s/", baseservicehome, GNUNET_asprintf (&newservicehome, "%s/%s/", baseservicehome,
hostname); hostname);
else else
GNUNET_asprintf (&newservicehome, "%s/", baseservicehome); GNUNET_asprintf (&newservicehome, "%s/", baseservicehome);
GNUNET_free (baseservicehome); GNUNET_free (baseservicehome);
baseservicehome = NULL; baseservicehome = NULL;
} }
else else
{ {
skipping to change at line 6264 skipping to change at line 6140
GNUNET_asprintf (&arg, "%s@%s:%s", username, pg->hosts[off].hostnam e, GNUNET_asprintf (&arg, "%s@%s:%s", username, pg->hosts[off].hostnam e,
newservicehome); newservicehome);
else else
GNUNET_asprintf (&arg, "%s:%s", pg->hosts[off].hostname, GNUNET_asprintf (&arg, "%s:%s", pg->hosts[off].hostname,
newservicehome); newservicehome);
/* FIXME: Doesn't support ssh_port option! */ /* FIXME: Doesn't support ssh_port option! */
proc = proc =
GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "rsync", "rsync", "- r", GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "rsync", "rsync", "- r",
newservicehome, arg, NULL); newservicehome, arg, NULL);
#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"copying directory with command rsync -r %s %s\n", "copying directory with command rsync -r %s %s\n",
newservicehome, arg); newservicehome, arg);
#endif
GNUNET_free (newservicehome); GNUNET_free (newservicehome);
GNUNET_free (arg); GNUNET_free (arg);
if (NULL == proc) if (NULL == proc)
{ {
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");
GNUNET_assert (0); GNUNET_assert (0);
} }
GNUNET_OS_process_wait (proc); GNUNET_OS_process_wait (proc);
GNUNET_OS_process_close (proc); GNUNET_OS_process_destroy (proc);
} }
/* Now all the configuration files and hostkeys are copied to the remot e host. Call the hostkey callback for each peer! */ /* Now all the configuration files and hostkeys are copied to the remot e host. Call the hostkey callback for each peer! */
GNUNET_SCHEDULER_add_now (&call_hostkey_callbacks, pg); GNUNET_SCHEDULER_add_now (&call_hostkey_callbacks, pg);
} }
#endif #endif
return pg; return pg;
} }
/* /*
* Get a daemon by number, so callers don't have to do nasty * Get a daemon by number, so callers don't have to do nasty
skipping to change at line 6683 skipping to change at line 6557
{ {
shutdown_ctx = GNUNET_malloc (sizeof (struct ShutdownContext)); shutdown_ctx = GNUNET_malloc (sizeof (struct ShutdownContext));
shutdown_ctx->cb = &churn_stop_callback; shutdown_ctx->cb = &churn_stop_callback;
shutdown_ctx->cb_cls = churn_ctx; shutdown_ctx->cb_cls = churn_ctx;
shutdown_ctx->total_peers = voff; shutdown_ctx->total_peers = voff;
shutdown_ctx->timeout = timeout; shutdown_ctx->timeout = timeout;
} }
for (i = 0; i < voff; i++) for (i = 0; i < voff; i++)
{ {
#if DEBUG_CHURN
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peer %d!\n", GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peer %d!\n",
running_arr[running_permute[i]]); running_arr[running_permute[i]]);
#endif
GNUNET_assert (running_arr != NULL); GNUNET_assert (running_arr != NULL);
peer_shutdown_ctx = GNUNET_malloc (sizeof (struct PeerShutdownContext)) ; peer_shutdown_ctx = GNUNET_malloc (sizeof (struct PeerShutdownContext)) ;
peer_shutdown_ctx->daemon = peer_shutdown_ctx->daemon =
pg->peers[running_arr[running_permute[i]]].daemon; pg->peers[running_arr[running_permute[i]]].daemon;
peer_shutdown_ctx->shutdown_ctx = shutdown_ctx; peer_shutdown_ctx->shutdown_ctx = shutdown_ctx;
GNUNET_SCHEDULER_add_now (&schedule_churn_shutdown_task, peer_shutdown_ ctx); GNUNET_SCHEDULER_add_now (&schedule_churn_shutdown_task, peer_shutdown_ ctx);
} }
GNUNET_assert (stopped >= von); GNUNET_assert (stopped >= von);
if (von > 0) if (von > 0)
{ {
churn_startup_ctx = GNUNET_malloc (sizeof (struct ChurnRestartContext)) ; churn_startup_ctx = GNUNET_malloc (sizeof (struct ChurnRestartContext)) ;
churn_startup_ctx->churn_ctx = churn_ctx; churn_startup_ctx->churn_ctx = churn_ctx;
churn_startup_ctx->timeout = timeout; churn_startup_ctx->timeout = timeout;
churn_startup_ctx->pg = pg; churn_startup_ctx->pg = pg;
} }
for (i = 0; i < von; i++) for (i = 0; i < von; i++)
{ {
#if DEBUG_CHURN
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting up peer %d!\n", GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting up peer %d!\n",
stopped_arr[stopped_permute[i]]); stopped_arr[stopped_permute[i]]);
#endif
GNUNET_assert (stopped_arr != NULL); GNUNET_assert (stopped_arr != NULL);
peer_restart_ctx = GNUNET_malloc (sizeof (struct PeerRestartContext)); peer_restart_ctx = GNUNET_malloc (sizeof (struct PeerRestartContext));
peer_restart_ctx->churn_restart_ctx = churn_startup_ctx; peer_restart_ctx->churn_restart_ctx = churn_startup_ctx;
peer_restart_ctx->daemon = peer_restart_ctx->daemon =
pg->peers[stopped_arr[stopped_permute[i]]].daemon; pg->peers[stopped_arr[stopped_permute[i]]].daemon;
GNUNET_SCHEDULER_add_now (&schedule_churn_restart, peer_restart_ctx); GNUNET_SCHEDULER_add_now (&schedule_churn_restart, peer_restart_ctx);
} }
GNUNET_free_non_null (running_arr); GNUNET_free_non_null (running_arr);
GNUNET_free_non_null (stopped_arr); GNUNET_free_non_null (stopped_arr);
skipping to change at line 6757 skipping to change at line 6627
start_ctx = GNUNET_malloc (sizeof (struct ServiceStartContext)); start_ctx = GNUNET_malloc (sizeof (struct ServiceStartContext));
start_ctx->pg = pg; start_ctx->pg = pg;
start_ctx->remaining = pg->total; start_ctx->remaining = pg->total;
start_ctx->cb = cb; start_ctx->cb = cb;
start_ctx->cb_cls = cb_cls; start_ctx->cb_cls = cb_cls;
start_ctx->service = GNUNET_strdup (service); start_ctx->service = GNUNET_strdup (service);
start_ctx->timeout = timeout; start_ctx->timeout = timeout;
for (i = 0; i < pg->total; i++) for (i = 0; i < pg->total; i++)
{ {
#if DEBUG_START
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting up service %s on peer %d
!\n",
service, stopped_arr[stopped_permute[i]]);
#endif
peer_start_ctx = GNUNET_malloc (sizeof (struct PeerServiceStartContext) ); peer_start_ctx = GNUNET_malloc (sizeof (struct PeerServiceStartContext) );
peer_start_ctx->start_ctx = start_ctx; peer_start_ctx->start_ctx = start_ctx;
peer_start_ctx->daemon = pg->peers[i].daemon; peer_start_ctx->daemon = pg->peers[i].daemon;
GNUNET_SCHEDULER_add_now (&schedule_service_start, peer_start_ctx); GNUNET_SCHEDULER_add_now (&schedule_service_start, peer_start_ctx);
} }
} }
/** /**
* Restart all peers in the given group. * Restart all peers in the given group.
* *
skipping to change at line 6880 skipping to change at line 6746
if (peer_shutdown_ctx->daemon->hostname != NULL) if (peer_shutdown_ctx->daemon->hostname != NULL)
decrement_outstanding_at_host (peer_shutdown_ctx->daemon->hostname, decrement_outstanding_at_host (peer_shutdown_ctx->daemon->hostname,
shutdown_ctx->pg); shutdown_ctx->pg);
if (emsg == NULL) if (emsg == NULL)
{ {
shutdown_ctx->peers_down++; shutdown_ctx->peers_down++;
} }
else else
{ {
#if VERBOSE_TESTING
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "internal_shutdown_callback", GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "internal_shutdown_callback",
"Failed to stop a peer: %s\n", emsg); "Failed to stop a peer: %s\n", emsg);
#endif
shutdown_ctx->peers_failed++; shutdown_ctx->peers_failed++;
} }
if ((shutdown_ctx->cb != NULL) && if ((shutdown_ctx->cb != NULL) &&
(shutdown_ctx->peers_down + shutdown_ctx->peers_failed == (shutdown_ctx->peers_down + shutdown_ctx->peers_failed ==
shutdown_ctx->total_peers)) shutdown_ctx->total_peers))
{ {
if (shutdown_ctx->peers_failed > 0) if (shutdown_ctx->peers_failed > 0)
shutdown_ctx->cb (shutdown_ctx->cb_cls, shutdown_ctx->cb (shutdown_ctx->cb_cls,
"Not all peers successfully shut down!"); "Not all peers successfully shut down!");
skipping to change at line 6935 skipping to change at line 6799
* too many ssh connections at once, but is generally nicer * too many ssh connections at once, but is generally nicer
* to any system as well (graduated task starts, as opposed * to any system as well (graduated task starts, as opposed
* to calling gnunet-arm N times all at once). * to calling gnunet-arm N times all at once).
*/ */
static void static void
schedule_shutdown_task (void *cls, schedule_shutdown_task (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc) const struct GNUNET_SCHEDULER_TaskContext *tc)
{ {
struct PeerShutdownContext *peer_shutdown_ctx = cls; struct PeerShutdownContext *peer_shutdown_ctx = cls;
struct ShutdownContext *shutdown_ctx; struct ShutdownContext *shutdown_ctx;
struct GNUNET_TESTING_Daemon *d;
GNUNET_assert (peer_shutdown_ctx != NULL); GNUNET_assert (peer_shutdown_ctx != NULL);
d = peer_shutdown_ctx->daemon;
shutdown_ctx = peer_shutdown_ctx->shutdown_ctx; shutdown_ctx = peer_shutdown_ctx->shutdown_ctx;
GNUNET_assert (shutdown_ctx != NULL); GNUNET_assert (shutdown_ctx != NULL);
if ((shutdown_ctx->outstanding < shutdown_ctx->pg->max_concurrent_ssh) || if ((shutdown_ctx->outstanding < shutdown_ctx->pg->max_concurrent_ssh) ||
((peer_shutdown_ctx->daemon->hostname != NULL) && ((d->hostname != NULL) &&
(count_outstanding_at_host (count_outstanding_at_host
(peer_shutdown_ctx->daemon->hostname, (d->hostname,
shutdown_ctx->pg) < shutdown_ctx->pg->max_concurrent_ssh))) shutdown_ctx->pg) < shutdown_ctx->pg->max_concurrent_ssh)))
{ {
if (peer_shutdown_ctx->daemon->hostname != NULL) if (d->hostname != NULL)
increment_outstanding_at_host (peer_shutdown_ctx->daemon->hostname, increment_outstanding_at_host (d->hostname,
shutdown_ctx->pg); shutdown_ctx->pg);
shutdown_ctx->outstanding++; shutdown_ctx->outstanding++;
GNUNET_TESTING_daemon_stop (peer_shutdown_ctx->daemon, GNUNET_TESTING_daemon_stop (d,
shutdown_ctx->timeout, shutdown_ctx->timeout,
&internal_shutdown_callback, peer_shutdown_ ctx, &internal_shutdown_callback, peer_shutdown_ ctx,
shutdown_ctx->delete_files, GNUNET_NO); shutdown_ctx->delete_files, GNUNET_NO);
} }
else else
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_MILLISECONDS, 100), (GNUNET_TIME_UNIT_MILLISECONDS, 100),
&schedule_shutdown_task, peer_shutdown_ct x); &schedule_shutdown_task, peer_shutdown_ct x);
} }
skipping to change at line 7030 skipping to change at line 6896
buf = data; buf = data;
count = 0; count = 0;
while (count < frstat.st_size - 1) while (count < frstat.st_size - 1)
{ {
count++; count++;
if (((data[count] == '\n')) && (buf != &data[count])) if (((data[count] == '\n')) && (buf != &data[count]))
{ {
data[count] = '\0'; data[count] = '\0';
temphost = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Host)); temphost = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Host));
ret = ret =
sscanf (buf, "%a[a-zA-Z0-9_]@%a[a-zA-Z0-9.]:%hd", SSCANF (buf, "%a[a-zA-Z0-9_]@%a[a-zA-Z0-9.]:%hd",
&temphost->username, &temphost->hostname, &temphost->po rt); &temphost->username, &temphost->hostname, &temphost->po rt);
if (3 == ret) if (3 == ret)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Successfully read host %s, port %d and user %s from file\n", "Successfully read host %s, port %d and user %s from file\n",
temphost->hostname, temphost->port, temphost->usernam e); temphost->hostname, temphost->port, temphost->usernam e);
} }
else else
{ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
 End of changes. 178 change blocks. 
260 lines changed or deleted 119 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/