* @brief convenience API for writing testcases for GNUnet
* @author Nathan Evans
* @author Christian Grothoff
- *
*/
#include "platform.h"
#include "gnunet_constants.h"
* Prototype of a function called whenever two peers would be connected
* in a certain topology.
*/
-typedef unsigned int
- (*GNUNET_TESTING_ConnectionProcessor) (struct GNUNET_TESTING_PeerGroup * pg,
- unsigned int first,
- unsigned int second,
- enum PeerLists list,
- unsigned int check);
+typedef unsigned int (*GNUNET_TESTING_ConnectionProcessor) (struct
+ GNUNET_TESTING_PeerGroup
+ * pg,
+ unsigned int first,
+ unsigned int second,
+ enum PeerLists list,
+ unsigned int check);
/**
* Context for handling churning a peer group
void *notify_cls;
};
+struct ConnectContext;
+
/**
* Handle to a group of GNUnet peers.
*/
*/
const struct GNUNET_CONFIGURATION_Handle *cfg;
+ struct ConnectContext *cc_head;
+
+ struct ConnectContext *cc_tail;
+
/**
* Function to call on each started daemon.
*/
struct ConnectContext
{
+
+ struct ConnectContext *next;
+
+ struct ConnectContext *prev;
+
/**
* Index of peer to connect second to.
*/
*/
uint32_t second_index;
+ /**
+ * Task associated with the attempt to connect.
+ */
+ GNUNET_SCHEDULER_TaskIdentifier task;
+
+ /**
+ * Context in 'testing.c', to cancel connection attempt.
+ */
+ struct GNUNET_TESTING_ConnectContext *cc;
+
/**
* Higher level topology connection context.
*/
fprintf (stdout, "%sProgress: [0%%", meter->startup_string);
}
else
- fprintf (stdout, "%d%%", (int) (((float) meter->completed
- / meter->total) * 100));
+ fprintf (stdout, "%d%%",
+ (int) (((float) meter->completed / meter->total) * 100));
}
else if (meter->completed % meter->dotnum == 0)
fprintf (stdout, ".");
if ((0 == strcmp (option, "PORT")) && (1 == sscanf (value, "%u", &ival)))
{
- if ((ival != 0) && (GNUNET_YES
- != GNUNET_CONFIGURATION_get_value_yesno (ctx->orig,
- "testing",
- single_variable)))
+ if ((ival != 0) &&
+ (GNUNET_YES !=
+ GNUNET_CONFIGURATION_get_value_yesno (ctx->orig, "testing",
+ single_variable)))
{
GNUNET_snprintf (cval, sizeof (cval), "%u", ctx->nport++);
value = cval;
}
- else if ((ival != 0) && (GNUNET_YES
- == GNUNET_CONFIGURATION_get_value_yesno (ctx->orig,
- "testing",
- single_variable))
- && GNUNET_CONFIGURATION_get_value_number (ctx->orig, "testing",
- per_host_variable,
- &num_per_host))
+ else if ((ival != 0) &&
+ (GNUNET_YES ==
+ GNUNET_CONFIGURATION_get_value_yesno (ctx->orig, "testing",
+ single_variable)) &&
+ GNUNET_CONFIGURATION_get_value_number (ctx->orig, "testing",
+ per_host_variable,
+ &num_per_host))
{
- GNUNET_snprintf (cval, sizeof (cval), "%u", ival + ctx->fdnum
- % num_per_host);
+ GNUNET_snprintf (cval, sizeof (cval), "%u",
+ ival + ctx->fdnum % num_per_host);
value = cval;
}
if (0 == strcmp (option, "UNIXPATH"))
{
- if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_yesno (ctx->orig,
- "testing",
- single_variable))
+ if (GNUNET_YES !=
+ GNUNET_CONFIGURATION_get_value_yesno (ctx->orig, "testing",
+ single_variable))
{
- GNUNET_snprintf (uval, sizeof (uval), "/tmp/test-service-%s-%u",
- section, ctx->upnum++);
+ GNUNET_snprintf (uval, sizeof (uval), "/tmp/test-service-%s-%u", section,
+ ctx->upnum++);
value = uval;
}
- else if ((GNUNET_YES
- == GNUNET_CONFIGURATION_get_value_number (ctx->orig, "testing",
- per_host_variable,
- &num_per_host))
- && (num_per_host > 0))
+ else if ((GNUNET_YES ==
+ GNUNET_CONFIGURATION_get_value_number (ctx->orig, "testing",
+ per_host_variable,
+ &num_per_host)) &&
+ (num_per_host > 0))
{
- GNUNET_snprintf (uval, sizeof (uval), "/tmp/test-service-%s-%u",
- section, ctx->fdnum % num_per_host);
+ GNUNET_snprintf (uval, sizeof (uval), "/tmp/test-service-%s-%u", section,
+ ctx->fdnum % num_per_host);
value = uval;
}
}
return NULL;
}
- if ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "testing",
- "skew_variance",
- &skew_variance))
- && (skew_variance > 0))
+ if ((GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "skew_variance",
+ &skew_variance)) &&
+ (skew_variance > 0))
{
skew_offset =
GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
skew_offset);
}
- if (GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "control_host",
- &control_host) == GNUNET_OK)
+ if (GNUNET_CONFIGURATION_get_value_string
+ (cfg, "testing", "control_host", &control_host) == GNUNET_OK)
{
if (hostname != NULL)
GNUNET_asprintf (&allowed_hosts, "%s; 127.0.0.1; %s;", control_host,
GNUNET_CONFIGURATION_set_value_string (uc.ret, "nse", "ACCEPT_FROM",
allowed_hosts);
- GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport",
- "ACCEPT_FROM", allowed_hosts);
+ GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport", "ACCEPT_FROM",
+ allowed_hosts);
GNUNET_CONFIGURATION_set_value_string (uc.ret, "dht", "ACCEPT_FROM",
allowed_hosts);
- GNUNET_CONFIGURATION_set_value_string (uc.ret, "statistics",
- "ACCEPT_FROM", allowed_hosts);
+ GNUNET_CONFIGURATION_set_value_string (uc.ret, "statistics", "ACCEPT_FROM",
+ allowed_hosts);
GNUNET_CONFIGURATION_set_value_string (uc.ret, "core", "UNIXPATH", "");
GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport", "UNIXPATH", "");
previous_total_connections = total_connections;
for (i = 0; i < outer_count; i++)
{
- probability = pg->peers[i].num_connections
- / (double) previous_total_connections;
- random
- = ((double) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
- UINT64_MAX))
- / ((double) UINT64_MAX);
+ probability =
+ pg->peers[i].num_connections / (double) previous_total_connections;
+ random =
+ ((double)
+ GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
+ UINT64_MAX)) / ((double) UINT64_MAX);
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Considering connecting peer %d to peer %d\n",
- outer_count, i);
+ "Considering connecting peer %d to peer %d\n", outer_count,
+ i);
#endif
if (random < probability)
{
#if VERBOSE_TESTING
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Connecting peer %d to peer %d\n", outer_count, i);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n",
+ outer_count, i);
#endif
total_connections += proc (pg, outer_count, i, list, GNUNET_YES);
}
int connect_attempts;
logNModifier = 0.5; /* FIXME: default value? */
- if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING",
- "PERCENTAGE",
- &p_string))
+ if (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAGE",
+ &p_string))
{
if (sscanf (p_string, "%lf", &logNModifier) != 1)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
GNUNET_free (p_string);
}
probability = 0.5; /* FIXME: default percentage? */
- if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING",
- "PROBABILITY",
- &p_string))
+ if (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PROBABILITY",
+ &p_string))
{
if (sscanf (p_string, "%lf", &probability) != 1)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
for (j = 0; j < connsPerPeer / 2; j++)
{
- random
- = ((double) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
- UINT64_MAX)
- / ((double) UINT64_MAX));
+ random =
+ ((double)
+ GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
+ UINT64_MAX) / ((double) UINT64_MAX));
if (random < probability)
{
/* Connect to uniformly selected random peer */
- randomPeer
- = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, pg->total);
- while ((((randomPeer < max) && (randomPeer > min)) && (useAnd
- == 0)) ||
+ randomPeer =
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, pg->total);
+ while ((((randomPeer < max) && (randomPeer > min)) && (useAnd == 0)) ||
(((randomPeer > min) || (randomPeer < max)) && (useAnd == 1)))
{
- randomPeer
- = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
- pg->total);
+ randomPeer =
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, pg->total);
}
smallWorldConnections += proc (pg, i, randomPeer, list, GNUNET_YES);
}
char *p_string;
nat_percentage = 0.6; /* FIXME: default percentage? */
- if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING",
- "PERCENTAGE",
- &p_string))
+ if (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAGE",
+ &p_string))
{
if (sscanf (p_string, "%lf", &nat_percentage) != 1)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
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);
#endif
- connect_attempts += proc (pg, outer_count, inner_count, list,
- GNUNET_YES);
+ connect_attempts +=
+ proc (pg, outer_count, inner_count, list, GNUNET_YES);
}
}
}
struct ProgressMeter *conn_meter;
nat_percentage = 0.6; /* FIXME: default percentage? */
- if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING",
- "PERCENTAGE",
- &p_string))
+ if (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAGE",
+ &p_string))
{
if (sscanf (p_string, "%lf", &nat_percentage) != 1)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
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);
#endif
- connect_attempts += proc (pg, outer_count, inner_count, list,
- GNUNET_YES);
+ connect_attempts +=
+ proc (pg, outer_count, inner_count, list, GNUNET_YES);
add_connections (pg, outer_count, inner_count, ALLOWED, GNUNET_NO);
update_meter (conn_meter);
}
cols = square;
percentage = 0.5; /* FIXME: default percentage? */
- if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING",
- "PERCENTAGE",
- &p_string))
+ if (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAGE",
+ &p_string))
{
if (sscanf (p_string, "%lf", &percentage) != 1)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
percentage = 0.5;
}
probability = 0.5; /* FIXME: default percentage? */
- if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING",
- "PROBABILITY",
- &p_string))
+ if (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PROBABILITY",
+ &p_string))
{
if (sscanf (p_string, "%lf", &probability) != 1)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
}
#if VERBOSE_TESTING
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);
#endif
natLog = log (pg->total);
#if VERBOSE_TESTING > 2
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- _("natural log of %d is %d, will run %d iterations\n"),
- pg->total, natLog, (int) (natLog * percentage));
+ _("natural log of %d is %d, will run %d iterations\n"), pg->total,
+ natLog, (int) (natLog * percentage));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Total connections added thus far: %u!\n"), connect_attempts);
#endif
/* Calculate probability as 1 over the square of the distance */
probability = 1.0 / (distance * distance);
/* Choose a random value between 0 and 1 */
- random
- = ((double) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
- UINT64_MAX))
- / ((double) UINT64_MAX);
+ random =
+ ((double)
+ GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
+ UINT64_MAX)) / ((double) UINT64_MAX);
/* If random < probability, then connect the two nodes */
if (random < probability)
smallWorldConnections += proc (pg, j, k, list, GNUNET_YES);
char *p_string;
probability = 0.5; /* FIXME: default percentage? */
- if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING",
- "PROBABILITY",
- &p_string))
+ if (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PROBABILITY",
+ &p_string))
{
if (sscanf (p_string, "%lf", &probability) != 1)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
{
for (inner_count = outer_count + 1; inner_count < pg->total; inner_count++)
{
- temp_rand
- = ((double) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
- UINT64_MAX))
- / ((double) UINT64_MAX);
+ temp_rand =
+ ((double)
+ GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
+ UINT64_MAX)) / ((double) UINT64_MAX);
#if VERBOSE_TESTING
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- _("rand is %f probability is %f\n"), temp_rand, probability);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("rand is %f probability is %f\n"),
+ temp_rand, probability);
#endif
if (temp_rand < probability)
{
- connect_attempts += proc (pg, outer_count, inner_count, list,
- GNUNET_YES);
+ connect_attempts +=
+ proc (pg, outer_count, inner_count, list, GNUNET_YES);
}
}
}
}
#if VERBOSE_TESTING
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);
#endif
/* Rows and columns are all sorted out, now iterate over all nodes and connect each
else
nodeToConnect = i - cols + 1;
#if VERBOSE_TESTING
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Connecting peer %d to peer %d\n", i, nodeToConnect);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n", i,
+ nodeToConnect);
#endif
connect_attempts += proc (pg, i, nodeToConnect, list, GNUNET_YES);
if (nodeToConnect < pg->total)
{
#if VERBOSE_TESTING
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Connecting peer %d to peer %d\n", i, nodeToConnect);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n", i,
+ nodeToConnect);
#endif
connect_attempts += proc (pg, i, nodeToConnect, list, GNUNET_YES);
}
connect_attempts = 0;
- conn_meter = create_meter ((((pg->total * pg->total) + pg->total) / 2)
- - pg->total, "Create Clique ", GNUNET_NO);
+ conn_meter =
+ create_meter ((((pg->total * pg->total) + pg->total) / 2) - pg->total,
+ "Create Clique ", GNUNET_NO);
for (outer_count = 0; outer_count < pg->total - 1; outer_count++)
{
for (inner_count = outer_count + 1; inner_count < pg->total; inner_count++)
{
#if VERBOSE_TESTING
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Connecting peer %d to peer %d\n", outer_count, inner_count);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n",
+ outer_count, inner_count);
#endif
connect_attempts += proc (pg, outer_count, inner_count, list, check);
update_meter (conn_meter);
for (count = 0; count < pg->total - 1; count++)
{
#if VERBOSE_TESTING
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Connecting peer %d to peer %d\n", count, count + 1);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n",
+ count, count + 1);
#endif
connect_attempts += proc (pg, count, count + 1, list, GNUNET_YES);
}
return connect_attempts;
}
/* Assume file is written with first peer 1, but array index is 0 */
- connect_attempts += proc (pg, first_peer_index - 1, second_peer_index
- - 1, list, GNUNET_YES);
- while ((buf[count] != '\n') && (buf[count] != ',') && (count
- <
- frstat.st_size -
- 1))
+ connect_attempts +=
+ proc (pg, first_peer_index - 1, second_peer_index - 1, list,
+ GNUNET_YES);
+ while ((buf[count] != '\n') && (buf[count] != ',') &&
+ (count < frstat.st_size - 1))
count++;
if (buf[count] == '\n')
{
for (count = 0; count < pg->total - 1; count++)
{
#if VERBOSE_TESTING
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Connecting peer %d to peer %d\n", count, count + 1);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n",
+ count, count + 1);
#endif
connect_attempts += proc (pg, count, count + 1, list, GNUNET_YES);
}
#endif
fclose (temp_friend_handle);
- if (GNUNET_OK
- !=
+ if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (pg->peers[pg_iter].daemon->cfg,
"PATHS", "SERVICEHOME",
&temp_service_path))
if (pg->peers[pg_iter].daemon->hostname == NULL) /* Local, just copy the file */
{
GNUNET_asprintf (&arg, "%s/friends", temp_service_path);
- procarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "mv", "mv",
- mytemp, arg, NULL);
+ procarr[pg_iter] =
+ GNUNET_OS_start_process (NULL, NULL, "mv", "mv", mytemp, arg, NULL);
GNUNET_assert (procarr[pg_iter] != NULL);
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
GNUNET_asprintf (&arg, "%s:%s/friends",
pg->peers[pg_iter].daemon->hostname,
temp_service_path);
- procarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "scp", "scp",
- mytemp, arg, NULL);
+ procarr[pg_iter] =
+ GNUNET_OS_start_process (NULL, NULL, "scp", "scp", mytemp, arg, NULL);
GNUNET_assert (procarr[pg_iter] != NULL);
ret = GNUNET_OS_process_wait (procarr[pg_iter]); /* FIXME: schedule this, throttle! */
GNUNET_OS_process_close (procarr[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", pg_iter);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking copy status of file %d\n",
+ pg_iter);
#endif
if (procarr[pg_iter] != NULL) /* Check for already completed! */
{
- if (GNUNET_OS_process_status
- (procarr[pg_iter], &type, &return_code) != GNUNET_OK)
+ if (GNUNET_OS_process_status (procarr[pg_iter], &type, &return_code) !=
+ GNUNET_OK)
{
ret = GNUNET_SYSERR;
}
}
#else
blacklist_ctx.transport = pos;
- (void) GNUNET_CONTAINER_multihashmap_iterate (pg->peers
+ (void) GNUNET_CONTAINER_multihashmap_iterate (pg->
+ peers
[pg_iter].blacklisted_peers,
&blacklist_file_iterator,
&blacklist_ctx);
GNUNET_free (temp_transports);
fclose (temp_file_handle);
- if (GNUNET_OK
- !=
+ if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (pg->peers[pg_iter].daemon->cfg,
"PATHS", "SERVICEHOME",
&temp_service_path))
if (pg->peers[pg_iter].daemon->hostname == NULL) /* Local, just copy the file */
{
GNUNET_asprintf (&arg, "%s/blacklist", temp_service_path);
- procarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "mv", "mv",
- mytemp, arg, NULL);
+ procarr[pg_iter] =
+ GNUNET_OS_start_process (NULL, NULL, "mv", "mv", mytemp, arg, NULL);
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Copying file with command cp %s %s\n"), mytemp, arg);
GNUNET_asprintf (&arg, "%s:%s/blacklist",
pg->peers[pg_iter].daemon->hostname,
temp_service_path);
- procarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "scp", "scp",
- mytemp, arg, NULL);
+ procarr[pg_iter] =
+ GNUNET_OS_start_process (NULL, NULL, "scp", "scp", mytemp, arg, NULL);
GNUNET_assert (procarr[pg_iter] != NULL);
GNUNET_OS_process_wait (procarr[pg_iter]); /* FIXME: add scheduled blacklist file copy that parallelizes file copying! */
#endif
if (procarr[pg_iter] != NULL) /* Check for already completed! */
{
- if (GNUNET_OS_process_status (procarr[pg_iter], &type,
- &return_code) != GNUNET_OK)
+ if (GNUNET_OS_process_status (procarr[pg_iter], &type, &return_code) !=
+ GNUNET_OK)
{
ret = GNUNET_SYSERR;
}
* Choose a random peer's next connection to create, and
* call schedule_connect to set up the connect task.
*
- * @param ct_ctx the overall connection context
+ * @param pg the peer group to connect
*/
static void
preschedule_connect (struct GNUNET_TESTING_PeerGroup *pg)
if (ct_ctx->remaining_connections == 0)
return;
- random_peer
- = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, pg->total);
+ random_peer =
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, pg->total);
while (pg->peers[random_peer].connect_peers_head == NULL)
- random_peer = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
- pg->total);
+ random_peer =
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, pg->total);
connection_iter = pg->peers[random_peer].connect_peers_head;
connect_context = GNUNET_malloc (sizeof (struct ConnectContext));
connect_context->first_index = random_peer;
connect_context->second_index = connection_iter->index;
connect_context->ct_ctx = ct_ctx;
- GNUNET_SCHEDULER_add_now (&schedule_connect, connect_context);
+ connect_context->task =
+ GNUNET_SCHEDULER_add_now (&schedule_connect, connect_context);
+ GNUNET_CONTAINER_DLL_insert (pg->cc_head, pg->cc_tail, connect_context);
GNUNET_CONTAINER_DLL_remove (pg->peers[random_peer].connect_peers_head,
pg->peers[random_peer].connect_peers_tail,
connection_iter);
#if USE_SEND_HELLOS
/* Forward declaration */
-static void schedule_send_hellos (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext
- *tc);
+static void
+schedule_send_hellos (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
/**
* Close connections and free the hello context.
* doesn't take too long!
*/
static void
-core_connect_notify (void *cls,
- const struct GNUNET_PeerIdentity *peer,
+core_connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_TRANSPORT_ATS_Information *atsi)
{
struct SendHelloContext *send_hello_context = cls;
struct PeerData *other_peer;
#endif
#if DEBUG_TESTING
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Connected peer %s to peer %s\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Connected peer %s to peer %s\n",
ctx->d1->shortname, GNUNET_i2s (peer));
#endif
* @param publicKey the public key of the peer
*/
void
-core_init (void *cls,
- struct GNUNET_CORE_Handle *server,
+core_init (void *cls, struct GNUNET_CORE_Handle *server,
const struct GNUNET_PeerIdentity *my_identity,
const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
{
GNUNET_assert (send_hello_context->peer->daemon->th != NULL);
GNUNET_TRANSPORT_disconnect (send_hello_context->peer->daemon->th);
send_hello_context->peer->daemon->th = NULL;
-
- /*if (send_hello_context->pg->remaining_hellos == 0)
- * {
- * for (pg_iter = 0; pg_iter < send_hello_context->pg->max_outstanding_connections; pg_iter++)
- * {
- * preschedule_connect(&send_hello_context->pg->ct_ctx);
- * }
- * }
- */
GNUNET_assert (send_hello_context->peer->daemon->server == NULL);
send_hello_context->peer->daemon->server =
GNUNET_CORE_connect (send_hello_context->peer->cfg, 1,
if (send_hello_context->peer->daemon->th == NULL)
{
pg->outstanding_connects++; /* Actual TRANSPORT, CORE connections! */
- send_hello_context->peer->daemon->th
- = GNUNET_TRANSPORT_connect (send_hello_context->peer->cfg, NULL,
- send_hello_context, NULL, NULL, NULL);
+ send_hello_context->peer->daemon->th =
+ GNUNET_TRANSPORT_connect (send_hello_context->peer->cfg, NULL,
+ send_hello_context, NULL, NULL, NULL);
}
#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
struct GNUNET_TESTING_PeerGroup *pg = ct_ctx->pg;
struct PeerConnection *connection;
+ GNUNET_assert (NULL != connect_ctx->cc);
+ connect_ctx->cc = NULL;
GNUNET_assert (0 < pg->outstanding_connects);
pg->outstanding_connects--;
-
+ GNUNET_CONTAINER_DLL_remove (pg->cc_head, pg->cc_tail, connect_ctx);
/*
* Check whether the inverse connection has been scheduled yet,
* if not, we can remove it from the other peers list and avoid
other_peer = NULL;
#endif
- while ((connection != NULL) && (0
- != memcmp (first,
- &pg->peers[connection->
- index].daemon->id,
- sizeof (struct
- GNUNET_PeerIdentity))))
- {
+ while ((connection != NULL) &&
+ (0 !=
+ memcmp (first, &pg->peers[connection->index].daemon->id,
+ sizeof (struct GNUNET_PeerIdentity))))
connection = connection->next;
- }
if (connection != NULL) /* Can safely remove! */
{
GNUNET_assert (0 < ct_ctx->remaining_connections);
ct_ctx->remaining_connections--;
if (pg->notify_connection != NULL) /* Notify of reverse connection */
- pg->notify_connection (pg->notify_connection_cls, second, first,
- distance, second_cfg, first_cfg, second_daemon,
- first_daemon, emsg);
+ pg->notify_connection (pg->notify_connection_cls, second, first, distance,
+ second_cfg, first_cfg, second_daemon, first_daemon,
+ emsg);
GNUNET_CONTAINER_DLL_remove (pg->
peers[connect_ctx->
pg->notify_connection (pg->notify_connection_cls, first, second, distance,
first_cfg, second_cfg, first_daemon, second_daemon,
emsg);
-
GNUNET_free (connect_ctx);
}
struct ConnectContext *connect_context = cls;
struct GNUNET_TESTING_PeerGroup *pg = connect_context->ct_ctx->pg;
+ connect_context->task = GNUNET_SCHEDULER_NO_TASK;
if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
return;
- if ((pg->outstanding_connects > pg->max_outstanding_connections)
- || (pg->stop_connects == GNUNET_YES))
+ if ((pg->outstanding_connects > pg->max_outstanding_connections) ||
+ (pg->stop_connects == GNUNET_YES))
{
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_
("Delaying connect, we have too many outstanding connections!\n"));
#endif
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
- (GNUNET_TIME_UNIT_MILLISECONDS, 100),
- &schedule_connect, connect_context);
+ connect_context->task =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
+ (GNUNET_TIME_UNIT_MILLISECONDS, 100),
+ &schedule_connect, connect_context);
+ return;
}
- else
- {
#if VERBOSE_TESTING
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _
- ("Creating connection, outstanding_connections is %d (max %d)\n"),
- pg->outstanding_connects, pg->max_outstanding_connections);
-#endif
- pg->outstanding_connects++;
- pg->total_connects_scheduled++;
- GNUNET_TESTING_daemons_connect (pg->
- peers[connect_context->first_index].daemon,
- pg->peers[connect_context->
- second_index].daemon,
- connect_context->ct_ctx->connect_timeout,
- connect_context->ct_ctx->connect_attempts,
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _
+ ("Creating connection, outstanding_connections is %d (max %d)\n"),
+ pg->outstanding_connects, pg->max_outstanding_connections);
+#endif
+ pg->outstanding_connects++;
+ pg->total_connects_scheduled++;
+ GNUNET_assert (NULL == connect_context->cc);
+ connect_context->cc =
+ GNUNET_TESTING_daemons_connect (pg->
+ peers[connect_context->
+ first_index].daemon,
+ pg->peers[connect_context->
+ second_index].daemon,
+ connect_context->ct_ctx->connect_timeout,
+ connect_context->ct_ctx->connect_attempts,
#if USE_SEND_HELLOS
- GNUNET_NO,
+ GNUNET_NO,
#else
- GNUNET_YES,
+ GNUNET_YES,
#endif
- &internal_connect_notify, connect_context); /* FIXME: free connect context! */
- }
+ &internal_connect_notify,
+ connect_context);
+
}
#if !OLD
connect_context->first = first->daemon;
connect_context->second = second;
connect_context->ct_ctx = ct_ctx;
- GNUNET_SCHEDULER_add_now (&schedule_connect, connect_context);
-
+ connect_context->task =
+ GNUNET_SCHEDULER_add_now (&schedule_connect, connect_context);
+ GNUNET_CONTAINER_DLL_insert (ct_ctx->pg->cc_head, ct_ctx->pg->cc_tail,
+ connect_context);
return GNUNET_YES;
}
#endif
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Creating topology from file!\n"));
#endif
- if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "testing",
- "topology_file",
- &filename))
- num_connections = create_from_file (pg, filename, &add_connections,
- ALLOWED);
+ if (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_string (pg->cfg, "testing",
+ "topology_file", &filename))
+ num_connections =
+ create_from_file (pg, filename, &add_connections, ALLOWED);
else
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
break;
}
- if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "TESTING",
- "F2F"))
+ if (GNUNET_YES ==
+ GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "TESTING", "F2F"))
{
ret = create_and_copy_friend_files (pg);
if (ret != GNUNET_OK)
}
/* Use the create clique method to initially set all connections as blacklisted. */
- if ((restrict_topology != GNUNET_TESTING_TOPOLOGY_NONE) && (restrict_topology
- !=
- GNUNET_TESTING_TOPOLOGY_FROM_FILE))
+ if ((restrict_topology != GNUNET_TESTING_TOPOLOGY_NONE) &&
+ (restrict_topology != GNUNET_TESTING_TOPOLOGY_FROM_FILE))
create_clique (pg, &add_connections, BLACKLIST, GNUNET_NO);
else
return num_connections;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Blacklisting all but clique topology\n"));
#endif
- unblacklisted_connections = create_clique (pg, &remove_connections,
- BLACKLIST, GNUNET_NO);
+ unblacklisted_connections =
+ create_clique (pg, &remove_connections, BLACKLIST, GNUNET_NO);
break;
case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING:
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Blacklisting all but small world (ring) topology\n"));
#endif
- unblacklisted_connections = create_small_world_ring (pg,
- &remove_connections,
- BLACKLIST);
+ unblacklisted_connections =
+ create_small_world_ring (pg, &remove_connections, BLACKLIST);
break;
case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD:
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Blacklisting all but small world (2d-torus) topology\n"));
#endif
- unblacklisted_connections = create_small_world (pg, &remove_connections,
- BLACKLIST);
+ unblacklisted_connections =
+ create_small_world (pg, &remove_connections, BLACKLIST);
break;
case GNUNET_TESTING_TOPOLOGY_RING:
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Blacklisting all but ring topology\n"));
#endif
- unblacklisted_connections
- = create_ring (pg, &remove_connections, BLACKLIST);
+ unblacklisted_connections =
+ create_ring (pg, &remove_connections, BLACKLIST);
break;
case GNUNET_TESTING_TOPOLOGY_2D_TORUS:
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Blacklisting all but 2d torus topology\n"));
#endif
- unblacklisted_connections = create_2d_torus (pg, &remove_connections,
- BLACKLIST);
+ unblacklisted_connections =
+ create_2d_torus (pg, &remove_connections, BLACKLIST);
break;
case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI:
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Blacklisting all but Erdos-Renyi topology\n"));
#endif
- unblacklisted_connections = create_erdos_renyi (pg, &remove_connections,
- BLACKLIST);
+ unblacklisted_connections =
+ create_erdos_renyi (pg, &remove_connections, BLACKLIST);
break;
case GNUNET_TESTING_TOPOLOGY_INTERNAT:
#if VERBOSE_TESTING
pg->peers[off].connect_peers_head = NULL;
pg->peers[off].connect_peers_tail = NULL;
}
- unblacklisted_connections
- = create_nated_internet_copy (pg, &remove_connections, BLACKLIST);
+ unblacklisted_connections =
+ create_nated_internet_copy (pg, &remove_connections, BLACKLIST);
#else
unblacklisted_connections =
create_nated_internet (pg, &remove_connections, BLACKLIST);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Blacklisting all but Scale Free topology\n"));
#endif
- unblacklisted_connections = create_scale_free (pg, &remove_connections,
- BLACKLIST);
+ unblacklisted_connections =
+ create_scale_free (pg, &remove_connections, BLACKLIST);
break;
case GNUNET_TESTING_TOPOLOGY_LINE:
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Blacklisting all but straight line topology\n"));
#endif
- unblacklisted_connections
- = create_line (pg, &remove_connections, BLACKLIST);
+ unblacklisted_connections =
+ create_line (pg, &remove_connections, BLACKLIST);
default:
break;
}
hash_from_uid (random_ctx->first_uid, &first_hash);
GNUNET_assert (random_ctx->pg->total > second_pos);
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove (random_ctx->pg->peers
+ GNUNET_CONTAINER_multihashmap_remove (random_ctx->
+ pg->peers
[second_pos].connect_peers,
&first_hash,
random_ctx->
if (min_ctx->pg_array[i] == min_ctx->current)
{
GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_multihashmap_put
- (min_ctx->first->connect_peers_working_set, key,
- value,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+ GNUNET_CONTAINER_multihashmap_put (min_ctx->
+ first->connect_peers_working_set,
+ key, value,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
uid_from_hash (key, &second_pos);
hash_from_uid (min_ctx->first_uid, &first_hash);
GNUNET_assert (min_ctx->pg->total > second_pos);
GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_multihashmap_put (min_ctx->pg->peers
+ GNUNET_CONTAINER_multihashmap_put (min_ctx->
+ pg->peers
[second_pos].connect_peers_working_set,
&first_hash,
min_ctx->first->
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
/* Now we have added this particular connection, remove it from the second peer's map so it's not double counted */
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove
- (min_ctx->pg->peers[second_pos].connect_peers,
- &first_hash, min_ctx->first->daemon));
+ GNUNET_CONTAINER_multihashmap_remove (min_ctx->
+ pg->peers
+ [second_pos].connect_peers,
+ &first_hash,
+ min_ctx->
+ first->daemon));
}
}
min_ctx->current++;
uid_from_hash (key, &dfs_ctx->second_uid);
hash_from_uid (dfs_ctx->first_uid, &first_hash);
GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_multihashmap_put (dfs_ctx->pg->peers
- [dfs_ctx->
- second_uid].connect_peers_working_set,
+ GNUNET_CONTAINER_multihashmap_put (dfs_ctx->
+ pg->peers[dfs_ctx->
+ second_uid].connect_peers_working_set,
&first_hash,
dfs_ctx->first->daemon,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
conn_iter = pg->peers[pg_iter].connect_peers_head;
while (conn_iter != NULL)
{
- random_number
- = ((double) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
- UINT64_MAX))
- / ((double) UINT64_MAX);
+ random_number =
+ ((double)
+ GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
+ UINT64_MAX)) / ((double) UINT64_MAX);
if (random_number < percentage)
{
add_connections (pg, pg_iter, conn_iter->index, WORKING_SET,
random_ctx.first = &pg->peers[pg_iter];
random_ctx.percentage = percentage;
random_ctx.pg = pg;
- pg->peers[pg_iter].connect_peers_working_set
- = GNUNET_CONTAINER_multihashmap_create (pg->total);
+ pg->peers[pg_iter].connect_peers_working_set =
+ GNUNET_CONTAINER_multihashmap_create (pg->total);
GNUNET_CONTAINER_multihashmap_iterate (pg->peers[pg_iter].connect_peers,
&random_connect_iterator,
&random_ctx);
/* Now remove the old connections */
GNUNET_CONTAINER_multihashmap_destroy (pg->peers[pg_iter].connect_peers);
/* And replace with the random set */
- pg->peers[pg_iter].connect_peers
- = pg->peers[pg_iter].connect_peers_working_set;
+ pg->peers[pg_iter].connect_peers =
+ pg->peers[pg_iter].connect_peers_working_set;
#endif
}
conn_iter = pg->peers[pg_iter].connect_peers_head;
while (pg->peers[pg_iter].connect_peers_head != NULL)
remove_connections (pg, pg_iter,
- pg->peers[pg_iter].connect_peers_head->index,
- CONNECT, GNUNET_YES);
+ pg->peers[pg_iter].connect_peers_head->index, CONNECT,
+ GNUNET_YES);
- pg->peers[pg_iter].connect_peers_head
- = pg->peers[pg_iter].connect_peers_working_set_head;
- pg->peers[pg_iter].connect_peers_tail
- = pg->peers[pg_iter].connect_peers_working_set_tail;
+ pg->peers[pg_iter].connect_peers_head =
+ pg->peers[pg_iter].connect_peers_working_set_head;
+ pg->peers[pg_iter].connect_peers_tail =
+ pg->peers[pg_iter].connect_peers_working_set_tail;
pg->peers[pg_iter].connect_peers_working_set_head = NULL;
pg->peers[pg_iter].connect_peers_working_set_tail = NULL;
}
}
#else
count +=
- GNUNET_CONTAINER_multihashmap_size (pg->peers
+ GNUNET_CONTAINER_multihashmap_size (pg->
+ peers
[pg_iter].connect_peers_working_set);
#endif
}
temp_list_size = count_connections (pg->peers[pg_iter].connect_peers_head);
if (temp_list_size == 0)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Peer %d has 0 connections!?!?\n", pg_iter);
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Peer %d has 0 connections!?!?\n",
+ pg_iter);
break;
}
for (i = 0; i < num; i++)
{
- random = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
- temp_list_size);
+ random =
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, temp_list_size);
conn_iter = pg->peers[pg_iter].connect_peers_head;
for (count = 0; count < random; count++)
conn_iter = conn_iter->next;
/*remove_connections(pg, pg_iter, pg->peers[pg_iter].connect_peers_head->index, CONNECT, GNUNET_YES); */
}
- pg->peers[pg_iter].connect_peers_head
- = pg->peers[pg_iter].connect_peers_working_set_head;
- pg->peers[pg_iter].connect_peers_tail
- = pg->peers[pg_iter].connect_peers_working_set_tail;
+ pg->peers[pg_iter].connect_peers_head =
+ pg->peers[pg_iter].connect_peers_working_set_head;
+ pg->peers[pg_iter].connect_peers_tail =
+ pg->peers[pg_iter].connect_peers_working_set_tail;
pg->peers[pg_iter].connect_peers_working_set_head = NULL;
pg->peers[pg_iter].connect_peers_working_set_tail = NULL;
}
(GNUNET_CRYPTO_hash_matching_bits
(&daemon->id.hashPubKey,
&closest_ctx->curr_peer->daemon->id.hashPubKey) >
- closest_ctx->closest_dist))
- && (GNUNET_YES !=
- GNUNET_CONTAINER_multihashmap_contains (closest_ctx->
- curr_peer->connect_peers,
- key)))
+ closest_ctx->closest_dist)) &&
+ (GNUNET_YES !=
+ GNUNET_CONTAINER_multihashmap_contains (closest_ctx->
+ curr_peer->connect_peers, key)))
{
closest_ctx->closest_dist =
GNUNET_CRYPTO_hash_matching_bits (&daemon->id.hashPubKey,
#if OLD
starting_peer = 0;
dfs_count = 0;
- while ((count_workingset_connections (pg) < num * pg->total)
- && (count_allowed_connections (pg) > 0))
+ while ((count_workingset_connections (pg) < num * pg->total) &&
+ (count_allowed_connections (pg) > 0))
{
if (dfs_count % pg->total == 0) /* Restart the DFS at some weakly connected peer */
{
least_connections = -1; /* Set to very high number */
for (pg_iter = 0; pg_iter < pg->total; pg_iter++)
{
- temp_count
- =
+ temp_count =
count_connections (pg->
peers[pg_iter].connect_peers_working_set_head);
if (temp_count < least_connections)
}
}
- temp_count
- = count_connections (pg->peers[starting_peer].connect_peers_head);
+ temp_count =
+ count_connections (pg->peers[starting_peer].connect_peers_head);
if (temp_count == 0)
continue; /* FIXME: infinite loop? */
- random_connection = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
- temp_count);
+ random_connection =
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, temp_count);
temp_count = 0;
peer_iter = pg->peers[starting_peer].connect_peers_head;
while (temp_count < random_connection)
starting_peer = 0;
dfs_count = 0;
- while ((count_workingset_connections (pg) < num * pg->total)
- && (count_allowed_connections (pg) > 0))
+ while ((count_workingset_connections (pg) < num * pg->total) &&
+ (count_allowed_connections (pg) > 0))
{
if (dfs_count % pg->total == 0) /* Restart the DFS at some weakly connected peer */
{
{
starting_peer = pg_iter;
least_connections =
- GNUNET_CONTAINER_multihashmap_size (pg->peers
+ GNUNET_CONTAINER_multihashmap_size (pg->
+ peers
[pg_iter].connect_peers_working_set);
}
}
/* Choose a random peer from the chosen peers set of connections to add */
dfs_ctx.chosen =
GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
- GNUNET_CONTAINER_multihashmap_size
- (pg->peers[starting_peer].connect_peers));
+ GNUNET_CONTAINER_multihashmap_size (pg->peers
+ [starting_peer].connect_peers));
dfs_ctx.first_uid = starting_peer;
dfs_ctx.first = &pg->peers[starting_peer];
dfs_ctx.pg = pg;
dfs_ctx.current = 0;
- GNUNET_CONTAINER_multihashmap_iterate (pg->peers
- [starting_peer].connect_peers,
+ GNUNET_CONTAINER_multihashmap_iterate (pg->
+ peers[starting_peer].connect_peers,
&dfs_connect_iterator, &dfs_ctx);
/* Remove the second from the first, since we will be continuing the search and may encounter the first peer again! */
hash_from_uid (dfs_ctx.second_uid, &second_hash);
if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
return;
- if (topology_context->connected
- > topology_context->pg->max_outstanding_connections)
+ if (topology_context->connected >
+ topology_context->pg->max_outstanding_connections)
{
#if VERBOSE_TESTING > 2
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
#endif
topology_context->connected++;
- if (GNUNET_OK != GNUNET_CORE_iterate_peers (core_context->daemon->cfg,
- &internal_topology_callback,
- core_context))
+ if (GNUNET_OK !=
+ GNUNET_CORE_iterate_peers (core_context->daemon->cfg,
+ &internal_topology_callback, core_context))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Topology iteration failed.\n");
internal_topology_callback (core_context, NULL, NULL);
#endif
stats_context->connected++;
- core_context->stats_handle
- = GNUNET_STATISTICS_create ("testing", core_context->daemon->cfg);
+ core_context->stats_handle =
+ GNUNET_STATISTICS_create ("testing", core_context->daemon->cfg);
if (core_context->stats_handle == NULL)
{
internal_stats_cont (core_context, GNUNET_NO);
return;
}
- core_context->stats_get_handle
- = GNUNET_STATISTICS_get (core_context->stats_handle, NULL, NULL,
- GNUNET_TIME_relative_get_forever (),
- &internal_stats_cont,
- &internal_stats_callback, core_context);
+ core_context->stats_get_handle =
+ GNUNET_STATISTICS_get (core_context->stats_handle, NULL, NULL,
+ GNUNET_TIME_relative_get_forever (),
+ &internal_stats_cont, &internal_stats_callback,
+ core_context);
if (core_context->stats_get_handle == NULL)
internal_stats_cont (core_context, GNUNET_NO);
unsigned long long port;
char *to_match;
- if (GNUNET_YES
- != GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "testing",
- "single_statistics_per_host"))
+ if (GNUNET_YES !=
+ GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "testing",
+ "single_statistics_per_host"))
return GNUNET_NO; /* Each peer has its own statistics instance, do nothing! */
pos = *stats_list;
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (specific_peer->cfg,
- "statistics",
- "unixpath",
- &unix_domain_socket))
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (specific_peer->cfg, "statistics",
+ "unixpath", &unix_domain_socket))
return GNUNET_NO;
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (specific_peer->cfg,
- "statistics", "port",
- &port))
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (specific_peer->cfg, "statistics",
+ "port", &port))
{
GNUNET_free (unix_domain_socket);
return GNUNET_NO;
for (i = 0; i < pg->total; i++)
{
- if ((pg->peers[i].daemon->running == GNUNET_YES) && (GNUNET_NO
- ==
- stats_check_existing
- (pg, &pg->peers[i],
- &stats_list)))
+ if ((pg->peers[i].daemon->running == GNUNET_YES) &&
+ (GNUNET_NO == stats_check_existing (pg, &pg->peers[i], &stats_list)))
{
/* Allocate one core context per core we need to connect to */
core_ctx = GNUNET_malloc (sizeof (struct StatsCoreContext));
copy_allowed_topology (pg);
break;
default:
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _
- ("Unknown topology specification, can't connect peers!\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Unknown topology specification, can't connect peers!\n"));
return GNUNET_SYSERR;
}
{
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\n"),
100 * option_modifier);
#endif
break;
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 possible)\n"),
(unsigned int) option_modifier);
#endif
break;
case GNUNET_TESTING_TOPOLOGY_OPTION_ADD_CLOSEST:
#if VERBOSE_TOPOLOGY
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _
- ("Finding additional %u closest peers each (if possible)\n"),
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Finding additional %u closest peers each (if possible)\n"),
(unsigned int) option_modifier);
#endif
#if FIXME
if (internal_context->hostkey_callback != NULL)
internal_context->hostkey_callback (internal_context->hostkey_cls, id, d,
emsg);
- else if (internal_context->peer->pg->started
- == internal_context->peer->pg->total)
+ else if (internal_context->peer->pg->started ==
+ internal_context->peer->pg->total)
{
internal_context->peer->pg->started = 0; /* Internal startup may use this counter! */
GNUNET_TESTING_daemons_continue_startup (internal_context->peer->pg);
return;
}
- if ((internal_context->peer->pg->starting
- < internal_context->peer->pg->max_concurrent_ssh)
- || ((internal_context->hostname != NULL)
- && (count_outstanding_at_host (internal_context->hostname,
- internal_context->peer->pg)
- < internal_context->peer->pg->max_concurrent_ssh)))
+ if ((internal_context->peer->pg->starting <
+ internal_context->peer->pg->max_concurrent_ssh) ||
+ ((internal_context->hostname != NULL) &&
+ (count_outstanding_at_host
+ (internal_context->hostname,
+ internal_context->peer->pg) <
+ internal_context->peer->pg->max_concurrent_ssh)))
{
if (internal_context->hostname != NULL)
increment_outstanding_at_host (internal_context->hostname,
churn_ctx->num_to_start--;
}
- total_left = (churn_ctx->num_to_stop - churn_ctx->num_failed_stop)
- + (churn_ctx->num_to_start - churn_ctx->num_failed_start);
+ total_left =
+ (churn_ctx->num_to_stop - churn_ctx->num_failed_stop) +
+ (churn_ctx->num_to_start - churn_ctx->num_failed_start);
if (total_left == 0)
{
*
*/
void
-service_start_callback (void *cls,
- const struct GNUNET_PeerIdentity *id,
+service_start_callback (void *cls, const struct GNUNET_PeerIdentity *id,
const struct GNUNET_CONFIGURATION_Handle *cfg,
struct GNUNET_TESTING_Daemon *d, const char *emsg)
{
else
{
- GNUNET_TESTING_daemon_start_service (peer_ctx->daemon,
- startup_ctx->service,
+ GNUNET_TESTING_daemon_start_service (peer_ctx->daemon, startup_ctx->service,
startup_ctx->timeout,
&service_start_callback, startup_ctx);
GNUNET_free (peer_ctx);
return;
}
- if ((internal_context->peer->pg->starting
- < internal_context->peer->pg->max_concurrent_ssh)
- || ((internal_context->hostname != NULL)
- && (count_outstanding_at_host (internal_context->hostname,
- internal_context->peer->pg)
- < internal_context->peer->pg->max_concurrent_ssh)))
+ if ((internal_context->peer->pg->starting <
+ internal_context->peer->pg->max_concurrent_ssh) ||
+ ((internal_context->hostname != NULL) &&
+ (count_outstanding_at_host
+ (internal_context->hostname,
+ internal_context->peer->pg) <
+ internal_context->peer->pg->max_concurrent_ssh)))
{
if (internal_context->hostname != NULL)
increment_outstanding_at_host (internal_context->hostname,
internal_context->peer->pg);
internal_context->peer->pg->starting++;
- internal_context->peer->daemon
- = GNUNET_TESTING_daemon_start (internal_context->peer->cfg,
- internal_context->timeout,
- GNUNET_NO,
- internal_context->hostname,
- internal_context->username,
- internal_context->sshport,
- internal_context->hostkey,
- &internal_hostkey_callback,
- internal_context,
- &internal_startup_callback,
- internal_context);
+ internal_context->peer->daemon =
+ GNUNET_TESTING_daemon_start (internal_context->peer->cfg,
+ internal_context->timeout, GNUNET_NO,
+ internal_context->hostname,
+ internal_context->username,
+ internal_context->sshport,
+ internal_context->hostkey,
+ &internal_hostkey_callback,
+ internal_context,
+ &internal_startup_callback,
+ internal_context);
}
else
{
GNUNET_asprintf (&arg, "%s", helper->host->hostname);
/* FIXME: Doesn't support ssh_port option! */
- helper->proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", arg,
- "peerStartHelper.pl", tempdir, NULL);
+ helper->proc =
+ GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", arg,
+ "peerStartHelper.pl", tempdir, NULL);
GNUNET_assert (helper->proc != NULL);
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"starting peers with cmd ssh %s %s %s\n", arg,
for (i = 0; i < pg->total; i++)
{
if (pg->peers[i].internal_context.hostkey_callback != NULL)
- pg->peers[i].internal_context.hostkey_callback (pg->peers
- [i].
+ pg->peers[i].internal_context.hostkey_callback (pg->peers[i].
internal_context.hostkey_cls,
&pg->peers[i].daemon->id,
pg->peers[i].daemon,
if (pg->hosts[i].sshport != 0)
{
GNUNET_asprintf (&ssh_port_str, "%d", pg->hosts[i].sshport);
- proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", "-P",
- ssh_port_str,
+ proc =
+ GNUNET_OS_start_process (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
- proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", arg,
- "mkdir -p", tmpdir, NULL);
+ proc =
+ GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", arg, "mkdir -p",
+ tmpdir, NULL);
GNUNET_assert (proc != NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Creating remote dir with command ssh %s %s %s\n", arg,
GNUNET_free (baseservicehome);
baseservicehome = NULL;
- if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (cfg, "TESTING",
- "HOSTKEYSFILE",
- &hostkeys_file))
+ if (GNUNET_YES ==
+ GNUNET_CONFIGURATION_get_value_string (cfg, "TESTING", "HOSTKEYSFILE",
+ &hostkeys_file))
{
if (GNUNET_YES != GNUNET_DISK_file_test (hostkeys_file))
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
else
{
/* Check hostkey file size, read entire thing into memory */
- fd = GNUNET_DISK_file_open (hostkeys_file,
- GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE);
+ fd = GNUNET_DISK_file_open (hostkeys_file, GNUNET_DISK_OPEN_READ,
+ GNUNET_DISK_PERM_NONE);
if (NULL == fd)
{
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "open", hostkeys_file);
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open",
+ hostkeys_file);
GNUNET_free (hostkeys_file);
for (i = 0; i < pg->num_hosts; i++)
{
hostname = pg->hosts[off % hostcnt].hostname;
username = pg->hosts[off % hostcnt].username;
sshport = pg->hosts[off % hostcnt].sshport;
- pcfg = make_config (cfg, off, &pg->hosts[off % hostcnt].minport,
- &upnum, hostname, &fdnum);
+ pcfg =
+ make_config (cfg, off, &pg->hosts[off % hostcnt].minport, &upnum,
+ hostname, &fdnum);
}
else
{
continue;
}
- if (GNUNET_YES
- == GNUNET_CONFIGURATION_get_value_string (pcfg, "PATHS",
- "SERVICEHOME",
- &baseservicehome))
+ if (GNUNET_YES ==
+ GNUNET_CONFIGURATION_get_value_string (pcfg, "PATHS", "SERVICEHOME",
+ &baseservicehome))
{
if (hostname != NULL)
GNUNET_asprintf (&newservicehome, "%s/%s/%d/", baseservicehome,
pg->peers[off].internal_context.username = username;
pg->peers[off].internal_context.sshport = sshport;
if (pg->hostkey_data != NULL)
- pg->peers[off].internal_context.hostkey = &pg->hostkey_data[off
- *
- HOSTKEYFILESIZE];
+ pg->peers[off].internal_context.hostkey =
+ &pg->hostkey_data[off * HOSTKEYFILESIZE];
pg->peers[off].internal_context.hostkey_callback = hostkey_callback;
pg->peers[off].internal_context.hostkey_cls = hostkey_cls;
pg->peers[off].internal_context.start_cb = cb;
#else
if ((pg->hostkey_data != NULL) && (hostcnt > 0))
{
- pg->peers[off].daemon
- = GNUNET_TESTING_daemon_start (pcfg,
- timeout,
- GNUNET_YES,
- hostname,
- username,
- sshport,
- pg->peers[off].
- internal_context.hostkey,
- &internal_hostkey_callback,
- &pg->peers[off].internal_context,
- &internal_startup_callback,
- &pg->peers[off].internal_context);
+ pg->peers[off].daemon =
+ GNUNET_TESTING_daemon_start (pcfg, timeout, GNUNET_YES, hostname,
+ username, sshport,
+ pg->peers[off].internal_context.hostkey,
+ &internal_hostkey_callback,
+ &pg->peers[off].internal_context,
+ &internal_startup_callback,
+ &pg->peers[off].internal_context);
/**
* At this point, given that we had a hostkeyfile,
* we can call the hostkey callback!
sshport = 0;
}
- if (GNUNET_YES
- == GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS",
- "SERVICEHOME",
- &baseservicehome))
+ if (GNUNET_YES ==
+ GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "SERVICEHOME",
+ &baseservicehome))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "baseservice home is %s\n",
baseservicehome);
}
if (NULL != username)
- GNUNET_asprintf (&arg,
- "%s@%s:%s",
- username, pg->hosts[off].hostname, newservicehome);
+ GNUNET_asprintf (&arg, "%s@%s:%s", username, pg->hosts[off].hostname,
+ newservicehome);
else
- GNUNET_asprintf (&arg,
- "%s:%s", pg->hosts[off].hostname, newservicehome);
+ GNUNET_asprintf (&arg, "%s:%s", pg->hosts[off].hostname,
+ newservicehome);
/* FIXME: Doesn't support ssh_port option! */
- proc = GNUNET_OS_start_process (NULL, NULL,
- "rsync",
- "rsync", "-r", newservicehome, arg, NULL);
+ proc =
+ GNUNET_OS_start_process (NULL, NULL, "rsync", "rsync", "-r",
+ newservicehome, arg, NULL);
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"copying directory with command rsync -r %s %s\n",
for (i = 0; i < pg->total; i++)
{
- if (0 == memcmp (&pg->peers[i].daemon->id, peer_id,
- sizeof (struct GNUNET_PeerIdentity)))
+ if (0 ==
+ memcmp (&pg->peers[i].daemon->id, peer_id,
+ sizeof (struct GNUNET_PeerIdentity)))
return pg->peers[i].daemon;
}
return NULL;
restart_context->callback (restart_context->callback_cls, NULL);
GNUNET_free (restart_context);
}
- else if (restart_context->peers_restart_failed
- + restart_context->peers_restarted ==
+ else if (restart_context->peers_restart_failed +
+ restart_context->peers_restarted ==
restart_context->peer_group->total)
{
restart_context->callback (restart_context->callback_cls,
churn_ctx->num_to_stop--;
}
- total_left = (churn_ctx->num_to_stop - churn_ctx->num_failed_stop)
- + (churn_ctx->num_to_start - churn_ctx->num_failed_start);
+ total_left =
+ (churn_ctx->num_to_stop - churn_ctx->num_failed_stop) +
+ (churn_ctx->num_to_start - churn_ctx->num_failed_start);
if (total_left == 0)
{
*/
void
GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg,
- char *service,
- unsigned int voff, unsigned int von,
+ char *service, unsigned int voff,
+ unsigned int von,
struct GNUNET_TIME_Relative timeout,
GNUNET_TESTING_NotifyCompletion cb, void *cb_cls)
{
stopped_permute = NULL;
if (running > 0)
- running_permute = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK,
- running);
+ running_permute =
+ GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK, running);
if (stopped > 0)
- stopped_permute = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK,
- stopped);
+ stopped_permute =
+ GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK, stopped);
total_running = running;
total_stopped = stopped;
#endif
GNUNET_assert (running_arr != NULL);
peer_shutdown_ctx = GNUNET_malloc (sizeof (struct PeerShutdownContext));
- peer_shutdown_ctx->daemon
- = pg->peers[running_arr[running_permute[i]]].daemon;
+ peer_shutdown_ctx->daemon =
+ pg->peers[running_arr[running_permute[i]]].daemon;
peer_shutdown_ctx->shutdown_ctx = shutdown_ctx;
GNUNET_SCHEDULER_add_now (&schedule_churn_shutdown_task, peer_shutdown_ctx);
}
GNUNET_assert (stopped_arr != NULL);
peer_restart_ctx = GNUNET_malloc (sizeof (struct PeerRestartContext));
peer_restart_ctx->churn_restart_ctx = churn_startup_ctx;
- peer_restart_ctx->daemon
- = pg->peers[stopped_arr[stopped_permute[i]]].daemon;
+ peer_restart_ctx->daemon =
+ pg->peers[stopped_arr[stopped_permute[i]]].daemon;
GNUNET_SCHEDULER_add_now (&schedule_churn_restart, peer_restart_ctx);
}
for (off = 0; off < pg->total; off++)
{
- GNUNET_TESTING_daemon_restart (pg->peers[off].daemon,
- &restart_callback, restart_context);
+ GNUNET_TESTING_daemon_restart (pg->peers[off].daemon, &restart_callback,
+ restart_context);
}
}
}
churn_ctx->cb_cls = cb_cls;
shutdown_ctx->cb_cls = churn_ctx;
GNUNET_TESTING_daemon_stop (pg->peers[offset].daemon, timeout,
- &churn_stop_callback, shutdown_ctx,
- GNUNET_NO, GNUNET_YES);
+ &churn_stop_callback, shutdown_ctx, GNUNET_NO,
+ GNUNET_YES);
}
}
else if (GNUNET_YES == desired_status)
churn_ctx->cb = cb;
churn_ctx->cb_cls = cb_cls;
startup_ctx->churn_ctx = churn_ctx;
- GNUNET_TESTING_daemon_start_stopped (pg->peers[offset].daemon,
- timeout, &churn_start_callback,
- startup_ctx);
+ GNUNET_TESTING_daemon_start_stopped (pg->peers[offset].daemon, timeout,
+ &churn_start_callback, startup_ctx);
}
}
else
shutdown_ctx->peers_failed++;
}
- if ((shutdown_ctx->cb != NULL) && (shutdown_ctx->peers_down
- + shutdown_ctx->peers_failed ==
- shutdown_ctx->total_peers))
+ if ((shutdown_ctx->cb != NULL) &&
+ (shutdown_ctx->peers_down + shutdown_ctx->peers_failed ==
+ shutdown_ctx->total_peers))
{
if (shutdown_ctx->peers_failed > 0)
shutdown_ctx->cb (shutdown_ctx->cb_cls,
shutdown_ctx = peer_shutdown_ctx->shutdown_ctx;
GNUNET_assert (shutdown_ctx != NULL);
- if ((shutdown_ctx->outstanding < shutdown_ctx->pg->max_concurrent_ssh)
- || ((peer_shutdown_ctx->daemon->hostname != NULL)
- && (count_outstanding_at_host (peer_shutdown_ctx->daemon->hostname,
- shutdown_ctx->pg)
- < shutdown_ctx->pg->max_concurrent_ssh)))
+ if ((shutdown_ctx->outstanding < shutdown_ctx->pg->max_concurrent_ssh) ||
+ ((peer_shutdown_ctx->daemon->hostname != NULL) &&
+ (count_outstanding_at_host
+ (peer_shutdown_ctx->daemon->hostname,
+ shutdown_ctx->pg) < shutdown_ctx->pg->max_concurrent_ssh)))
{
if (peer_shutdown_ctx->daemon->hostname != NULL)
increment_outstanding_at_host (peer_shutdown_ctx->daemon->hostname,
int ret;
/* Check for a hostfile containing user@host:port triples */
- if (GNUNET_OK
- != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "hostfile",
- &hostfile))
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "hostfile",
+ &hostfile))
return NULL;
hosts = NULL;
if (hostfile != NULL)
{
if (GNUNET_OK != GNUNET_DISK_file_test (hostfile))
- GNUNET_DISK_fn_write (hostfile, NULL, 0, GNUNET_DISK_PERM_USER_READ
- | GNUNET_DISK_PERM_USER_WRITE);
+ GNUNET_DISK_fn_write (hostfile, NULL, 0,
+ GNUNET_DISK_PERM_USER_READ |
+ GNUNET_DISK_PERM_USER_WRITE);
if ((0 != STAT (hostfile, &frstat)) || (frstat.st_size == 0))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
{
data[count] = '\0';
temphost = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Host));
- ret = sscanf (buf, "%a[a-zA-Z0-9_]@%a[a-zA-Z0-9.]:%hd",
- &temphost->username, &temphost->hostname,
- &temphost->port);
+ ret =
+ sscanf (buf, "%a[a-zA-Z0-9_]@%a[a-zA-Z0-9.]:%hd",
+ &temphost->username, &temphost->hostname, &temphost->port);
if (3 == ret)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
struct PeerConnection *conn_iter;
struct PeerConnection *temp_conn;
#endif
+ struct ConnectContext *cc;
GNUNET_assert (pg->total > 0);
+ while (NULL != (cc = pg->cc_head))
+ {
+ GNUNET_CONTAINER_DLL_remove (pg->cc_head, pg->cc_tail, cc);
+ if (GNUNET_SCHEDULER_NO_TASK != cc->task)
+ GNUNET_SCHEDULER_cancel (cc->task);
+ if (NULL != cc->cc)
+ GNUNET_TESTING_daemons_connect_cancel (cc->cc);
+ GNUNET_free (cc);
+ }
shutdown_ctx = GNUNET_malloc (sizeof (struct ShutdownContext));
- shutdown_ctx->delete_files = GNUNET_CONFIGURATION_get_value_yesno (pg->cfg,
- "TESTING",
- "DELETE_FILES");
+ shutdown_ctx->delete_files =
+ GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "TESTING", "DELETE_FILES");
shutdown_ctx->cb = cb;
shutdown_ctx->cb_cls = cb_cls;
shutdown_ctx->total_peers = pg->total;
shutdown_ctx->timeout = timeout;
shutdown_ctx->pg = pg;
- /* shtudown_ctx->outstanding = 0; */
for (off = 0; off < pg->total; off++)
{