From 0799af8eedff5c9e42b00dc8bd7baee78baa61a7 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Tue, 8 Nov 2011 21:27:30 +0000 Subject: [PATCH] Added comments, fixed debug code, added doxygen --- src/testing/testing.c | 8 ++++---- src/testing/testing_group.c | 9 +++++++++ src/testing/testing_peergroup.c | 16 ++++++++++------ 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/testing/testing.c b/src/testing/testing.c index b778b7d03..175888621 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c @@ -106,7 +106,7 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message) #endif GNUNET_assert (daemon->phase == SP_GET_HELLO || daemon->phase == SP_START_DONE); - daemon->cb = NULL; + daemon->cb = NULL; // FIXME: why??? (see fsm:SP_START_CORE, notify_daemon_started) if (daemon->task != GNUNET_SCHEDULER_NO_TASK) /* Assertion here instead? */ GNUNET_SCHEDULER_cancel (daemon->task); @@ -148,13 +148,12 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message) daemon->phase = SP_START_DONE; } -static void -start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); /** * Notify of a peer being up and running. Scheduled as a task * so that variables which may need to be set are set before * the connect callback can set up new operations. + * FIXME: what variables?????? where from???? * * @param cls the testing daemon * @param tc task scheduler context @@ -189,7 +188,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) int bytes_read; #if DEBUG_TESTING - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer FSM is in phase %u.\n", d->phase); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %s FSM is in phase %u.\n", + GNUNET_i2s (&d->id), d->phase); #endif d->task = GNUNET_SCHEDULER_NO_TASK; diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index 171cf1c48..db763d22a 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c @@ -5543,6 +5543,15 @@ internal_startup_callback (void *cls, const struct GNUNET_PeerIdentity *id, emsg); } + +/** + * Calls GNUNET_TESTING_daemon_continue_startup to set the daemon's state + * from HOSTKEY_CREATED to TOPOLOGY_SETUP. Makes sure not to saturate a host + * with requests delaying them when needed. + * + * @param cls closure: internal context of the daemon. + * @param tc TaskContext + */ static void internal_continue_startup (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) diff --git a/src/testing/testing_peergroup.c b/src/testing/testing_peergroup.c index a46e1bfb2..d3290a36c 100644 --- a/src/testing/testing_peergroup.c +++ b/src/testing/testing_peergroup.c @@ -416,7 +416,7 @@ internal_topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created %d total connections, which is our target number! Starting next phase of testing.\n", - total_connections); + pg_start_ctx->total_connections); #endif #if TIMING @@ -472,7 +472,8 @@ internal_peers_started_callback (void *cls, #if VERBOSE > 1 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Started daemon %llu out of %llu\n", - (num_peers - peers_left) + 1, num_peers); + (pg_start_ctx->total - pg_start_ctx->peers_left) + 1, + pg_start_ctx->total); #endif pg_start_ctx->peers_left--; @@ -481,12 +482,14 @@ internal_peers_started_callback (void *cls, { #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "All %d daemons started, now connecting peers!\n", num_peers); + "All %d daemons started, now connecting peers!\n", + pg_start_ctx->total); #endif GNUNET_assert (pg_start_ctx->die_task != GNUNET_SCHEDULER_NO_TASK); GNUNET_SCHEDULER_cancel (pg_start_ctx->die_task); pg_start_ctx->expected_connections = UINT_MAX; + // FIXME: why whould peers_left be != 0?? Or pg NULL? if ((pg_start_ctx->pg != NULL) && (pg_start_ctx->peers_left == 0)) { pg_start_ctx->connect_start_time = GNUNET_TIME_absolute_get (); @@ -549,17 +552,18 @@ internal_hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id, #if VERBOSE > 1 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Hostkey (%d/%d) created for peer `%s'\n", num_peers - peers_left, - num_peers, GNUNET_i2s (id)); + "Hostkey (%d/%d) created for peer `%s'\n", + pg_start_ctx->total - pg_start_ctx->peers_left, + pg_start_ctx->total, GNUNET_i2s (id)); #endif pg_start_ctx->peers_left--; if (GNUNET_YES == update_meter (pg_start_ctx->hostkey_meter)) { GNUNET_SCHEDULER_cancel (pg_start_ctx->die_task); + GNUNET_free_non_null (pg_start_ctx->fail_reason); /* Set up task in case topology creation doesn't finish * within a reasonable amount of time */ - GNUNET_free_non_null (pg_start_ctx->fail_reason); pg_start_ctx->fail_reason = GNUNET_strdup ("from create_topology"); pg_start_ctx->die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining -- 2.25.1