struct UpdateContext
{
struct GNUNET_CONFIGURATION_Handle *ret;
+ const struct GNUNET_CONFIGURATION_Handle *orig;
const char *hostname;
unsigned int nport;
unsigned int upnum;
unsigned int ival;
char cval[12];
char uval[128];
+ char *single_variable;
if ((0 == strcmp (option, "PORT")) && (1 == sscanf (value, "%u", &ival)))
{
- if (ival != 0)
+ GNUNET_asprintf(&single_variable, "single_%s_per_host", section);
+ 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;
}
+
+ GNUNET_free(single_variable);
}
if (0 == strcmp (option, "UNIXPATH"))
{
- GNUNET_snprintf (uval,
- sizeof (uval),
- "/tmp/test-service-%s-%u",
- section,
- ctx->upnum++);
- value = uval;
+ GNUNET_asprintf(&single_variable, "single_%s_per_host", section);
+ 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++);
+ value = uval;
+ }
+ GNUNET_free(single_variable);
+
}
if ((0 == strcmp (option, "HOSTNAME")) && (ctx->hostname != NULL))
uc.upnum = *upnum;
uc.ret = GNUNET_CONFIGURATION_create ();
uc.hostname = hostname;
+ uc.orig = cfg;
GNUNET_CONFIGURATION_iterate (cfg, &update_config, &uc);
if (uc.nport >= HIGH_PORT)
unsigned int distance;
double probability, random, percentage;
unsigned int smallWorldConnections;
+ unsigned int small_world_it;
char *p_string;
int connect_attempts;
square = floor (sqrt (pg->total));
"TESTING");
GNUNET_free (p_string);
}
+ if (percentage < 0.0)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Invalid value `%s' for option `%s' in section `%s': got %f, needed value greater than 0\n"),
+ "PERCENTAGE", "TESTING", percentage);
+ percentage = 0.5;
+ }
probability = 0.5; /* FIXME: default percentage? */
if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(pg->cfg,
"TESTING",
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Total connections added thus far: %u!\n"), connect_attempts);
#endif
smallWorldConnections = 0;
- for (i = 0; i < (int) (natLog * percentage); i++)
+ small_world_it = (unsigned int)(natLog * percentage);
+ GNUNET_assert(small_world_it > 0 && small_world_it < (unsigned int)-1);
+ for (i = 0; i < small_world_it; i++)
{
for (j = 0; j < pg->total; j++)
{
int unblacklisted_connections;
GNUNET_assert (pg->notify_connection != NULL);
- ret = GNUNET_OK;
switch (topology)
{
return NULL;
}
+/*
+ * Get a daemon by peer identity, so callers can
+ * retrieve the daemon without knowing it's offset.
+ *
+ * @param pg the peer group to retrieve the daemon from
+ * @param peer_id the peer identity of the daemon to retrieve
+ *
+ * @return the daemon on success, or NULL if no such peer identity is found
+ */
+struct GNUNET_TESTING_Daemon *
+GNUNET_TESTING_daemon_get_by_id (struct GNUNET_TESTING_PeerGroup *pg, struct GNUNET_PeerIdentity *peer_id)
+{
+ unsigned int i;
+
+ for (i = 0; i < pg->total; i ++)
+ {
+ if (0 == memcmp(&pg->peers[i].daemon->id, peer_id, sizeof(struct GNUNET_PeerIdentity)))
+ return pg->peers[i].daemon;
+ }
+
+ return NULL;
+}
+
/**
* Prototype of a function that will be called when a
* particular operation was completed the testing library.
}
}
+ GNUNET_assert(running >= voff);
for (i = 0; i < voff; i++)
{
#if DEBUG_CHURN
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Stopping peer %d!\n", running_permute[i]);
#endif
+ GNUNET_assert(running_arr != NULL);
GNUNET_TESTING_daemon_stop (pg->peers[running_arr[running_permute[i]]].daemon,
timeout,
&churn_stop_callback, churn_ctx,
GNUNET_NO, GNUNET_YES);
}
+ GNUNET_assert(stopped >= von);
for (i = 0; i < von; i++)
{
#if DEBUG_CHURN
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Starting up peer %d!\n", stopped_permute[i]);
#endif
+ GNUNET_assert(stopped_arr != NULL);
GNUNET_TESTING_daemon_start_stopped(pg->peers[stopped_arr[stopped_permute[i]]].daemon,
timeout, &churn_start_callback, churn_ctx);
}
schedule_shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
{
struct PeerShutdownContext *peer_shutdown_ctx = cls;
- struct ShutdownContext *shutdown_ctx = peer_shutdown_ctx->shutdown_ctx;
+ struct ShutdownContext *shutdown_ctx;
GNUNET_assert(peer_shutdown_ctx != NULL);
+ shutdown_ctx = peer_shutdown_ctx->shutdown_ctx;
GNUNET_assert(shutdown_ctx != NULL);
if (shutdown_ctx->outstanding > MAX_CONCURRENT_SHUTDOWN)