From: Nathan S. Evans Date: Tue, 27 Apr 2010 15:32:55 +0000 (+0000) Subject: testing bug fixes (hopefully) X-Git-Tag: initial-import-from-subversion-38251~21993 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=7346e9edb1c5d68312a76ae10a38d360beaa39b5;p=oweals%2Fgnunet.git testing bug fixes (hopefully) --- diff --git a/src/testing/test_testing_connect.c b/src/testing/test_testing_connect.c index 9dd07f993..60721298e 100644 --- a/src/testing/test_testing_connect.c +++ b/src/testing/test_testing_connect.c @@ -24,7 +24,7 @@ #include "platform.h" #include "gnunet_testing_lib.h" -#define VERBOSE GNUNET_YES +#define VERBOSE GNUNET_NO /** diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c index eae59913c..6961f0418 100644 --- a/src/testing/test_testing_topology.c +++ b/src/testing/test_testing_topology.c @@ -25,7 +25,7 @@ #include "gnunet_testing_lib.h" #include "gnunet_core_service.h" -#define VERBOSE GNUNET_NO +#define VERBOSE GNUNET_YES /** * How long until we fail the whole testcase? @@ -37,7 +37,9 @@ */ #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) -#define DEFAULT_NUM_PEERS 4; +#define DEFAULT_NUM_PEERS 4 + +#define MAX_OUTSTANDING_CONNECTIONS 300 static float fail_percentage = 0.05; @@ -75,12 +77,25 @@ static char *topology_string; static int transmit_ready_scheduled; -static int transmit_ready_called; +static int transmit_ready_failed; -struct TestMessageContext *global_pos; +static int transmit_ready_called; #define MTYPE 12345 +struct GNUNET_TestMessage +{ + /** + * Header of the message + */ + struct GNUNET_MessageHeader header; + + /** + * Unique identifier for this message. + */ + uint32_t uid; +}; + struct TestMessageContext { /* This is a linked list */ @@ -98,46 +113,45 @@ struct TestMessageContext /* Handle to the receiving peer daemon */ struct GNUNET_TESTING_Daemon *peer2; - /* Maintain some state */ - int first_step_done; + /* Identifier for this message, so we don't disconnect other peers! */ + uint32_t uid; }; -struct Connection -{ - struct Connection *next; - struct GNUNET_TESTING_Daemon *peer; - struct GNUNET_CORE_Handle *server; -}; - -static struct Connection *global_connections; - static struct TestMessageContext *test_messages; static void finish_testing () { GNUNET_assert (pg != NULL); - struct Connection *pos; + struct TestMessageContext *pos; + struct TestMessageContext *free_pos; #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called finish testing, stopping daemons.\n"); #endif int count; count = 0; - pos = global_connections; + pos = test_messages; while (pos != NULL) { - if (pos->server != NULL) + if (pos->peer1handle != NULL) + { + GNUNET_CORE_disconnect(pos->peer1handle); + pos->peer1handle = NULL; + } + if (pos->peer2handle != NULL) { - GNUNET_CORE_disconnect(pos->server); - pos->server = NULL; + GNUNET_CORE_disconnect(pos->peer2handle); + pos->peer2handle = NULL; } + free_pos = pos; pos = pos->next; + GNUNET_free(free_pos); } #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "transmit_ready's scheduled %d, transmit_ready's called %d\n", transmit_ready_scheduled, transmit_ready_called); + "transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n", transmit_ready_scheduled, transmit_ready_failed, transmit_ready_called); #endif sleep(1); #if VERBOSE @@ -158,6 +172,32 @@ finish_testing () ok = 0; } + +static void +disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) +{ + struct TestMessageContext *pos = cls; + + /* Disconnect from the respective cores */ +#if VERBOSE + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Disconnecting from peer 1 `%4s'\n", GNUNET_i2s (&pos->peer1->id)); +#endif + if (pos->peer1handle != NULL) + GNUNET_CORE_disconnect(pos->peer1handle); +#if VERBOSE + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Disconnecting from peer 2 `%4s'\n", GNUNET_i2s (&pos->peer2->id)); +#endif + if (pos->peer2handle != NULL) + GNUNET_CORE_disconnect(pos->peer2handle); + /* Set handles to NULL so test case can be ended properly */ + pos->peer1handle = NULL; + pos->peer2handle = NULL; + /* Decrement total connections so new can be established */ + total_server_connections -= 2; +} + static int process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, @@ -165,6 +205,11 @@ process_mtype (void *cls, struct GNUNET_TIME_Relative latency, uint32_t distance) { + struct TestMessageContext *pos = cls; + struct GNUNET_TestMessage *msg = (struct GNUNET_TestMessage *)message; + if (pos->uid != ntohl(msg->uid)) + return GNUNET_OK; + total_messages_received++; #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -178,6 +223,11 @@ process_mtype (void *cls, GNUNET_SCHEDULER_cancel (sched, die_task); GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); } + else + { + GNUNET_SCHEDULER_add_now(sched, &disconnect_cores, pos); + } + return GNUNET_OK; } @@ -187,17 +237,25 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) char *msg = cls; GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "End badly was called (%s)... stopping daemons.\n", msg); - struct Connection *pos; + struct TestMessageContext *pos; + struct TestMessageContext *free_pos; - pos = global_connections; + pos = test_messages; while (pos != NULL) { - if (pos->server != NULL) + if (pos->peer1handle != NULL) + { + GNUNET_CORE_disconnect(pos->peer1handle); + pos->peer1handle = NULL; + } + if (pos->peer2handle != NULL) { - GNUNET_CORE_disconnect(pos->server); - pos->server = NULL; + GNUNET_CORE_disconnect(pos->peer2handle); + pos->peer2handle = NULL; } + free_pos = pos; pos = pos->next; + GNUNET_free(free_pos); } if (pg != NULL) @@ -216,195 +274,151 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) } -/** - * Forward declaration. - */ -static size_t -transmit_ready (void *cls, size_t size, void *buf); - -static void -schedule_transmission (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) -{ - - if (global_pos != NULL) - { - if (NULL == GNUNET_CORE_notify_transmit_ready (global_pos->peer1handle, - 0, - TIMEOUT, - &global_pos->peer2->id, - sizeof (struct GNUNET_MessageHeader), - &transmit_ready, &global_pos->peer1->id)) - { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", - GNUNET_i2s (&global_pos->peer2->id)); - } - else - { - transmit_ready_scheduled++; - } - global_pos = global_pos->next; - } - else - { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Transmit ready scheduled on %d messages\n", - transmit_ready_scheduled); - } - -} static size_t transmit_ready (void *cls, size_t size, void *buf) { - struct GNUNET_MessageHeader *m; -#if VERBOSE - struct GNUNET_PeerIdentity *peer = cls; -#endif - GNUNET_assert (buf != NULL); - m = (struct GNUNET_MessageHeader *) buf; - m->type = htons (MTYPE); - m->size = htons (sizeof (struct GNUNET_MessageHeader)); + struct GNUNET_TestMessage *m; + struct TestMessageContext *pos = cls; + GNUNET_assert (buf != NULL); + m = (struct GNUNET_TestMessage *) buf; + m->header.type = htons (MTYPE); + m->header.size = htons (sizeof (struct GNUNET_TestMessage)); + m->uid = htonl(pos->uid); transmit_ready_called++; #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "transmit ready for peer %s\ntransmit_ready's scheduled %d, transmit_ready's called %d\n", GNUNET_i2s(peer), transmit_ready_scheduled, transmit_ready_called); + "transmit ready for peer %s\ntransmit_ready's scheduled %d, transmit_ready's called %d\n", GNUNET_i2s(&pos->peer1->id), transmit_ready_scheduled, transmit_ready_called); #endif - GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 50), &schedule_transmission, NULL); - return sizeof (struct GNUNET_MessageHeader); + return sizeof (struct GNUNET_TestMessage); } -static struct GNUNET_CORE_MessageHandler handlers[] = { - {&process_mtype, MTYPE, sizeof (struct GNUNET_MessageHeader)}, +static struct GNUNET_CORE_MessageHandler no_handlers[] = { {NULL, 0, 0} }; - +static struct GNUNET_CORE_MessageHandler handlers[] = { + {&process_mtype, MTYPE, sizeof (struct GNUNET_TestMessage)}, + {NULL, 0, 0} +}; static void -send_test_messages () +init_notify_peer2 (void *cls, + struct GNUNET_CORE_Handle *server, + const struct GNUNET_PeerIdentity *my_identity, + const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) { - struct TestMessageContext *pos; - struct Connection *conn_pos; - die_task = GNUNET_SCHEDULER_add_delayed (sched, - TEST_TIMEOUT, - &end_badly, "from send test messages"); - - int count = 0; - int conn_count = 0; - pos = test_messages; - while (pos != NULL) - { - conn_pos = global_connections; - conn_count = 0; - while (conn_pos != NULL) - { - if (conn_pos->peer == pos->peer1) - { - pos->peer1handle = conn_pos->server; - break; - } - conn_count++; - conn_pos = conn_pos->next; - } - GNUNET_assert(pos->peer1handle != NULL); - - /* - if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, - 0, - TIMEOUT, - &pos->peer2->id, - sizeof (struct GNUNET_MessageHeader), - &transmit_ready, &pos->peer1->id)) - { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", - GNUNET_i2s (&pos->peer2->id)); - } - else - { - transmit_ready_scheduled++; - } - */ - pos = pos->next; - count++; - - } + struct TestMessageContext *pos = cls; +#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Prepared %d messages\n", - count); - global_pos = test_messages; + "Core connection to `%4s' established, scheduling message send\n", + GNUNET_i2s (my_identity)); +#endif + total_server_connections++; - GNUNET_SCHEDULER_add_now(sched, &schedule_transmission, NULL); + if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, + 0, + TIMEOUT, + &pos->peer2->id, + sizeof (struct GNUNET_TestMessage), + &transmit_ready, pos)) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", + GNUNET_i2s (&pos->peer2->id)); + transmit_ready_failed++; + } + else + { + transmit_ready_scheduled++; + } } - static void -init_notify (void *cls, +init_notify_peer1 (void *cls, struct GNUNET_CORE_Handle *server, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) { - struct Connection *connection = cls; + struct TestMessageContext *pos = cls; + total_server_connections++; #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core connection to `%4s' established, setting up handles\n", GNUNET_i2s (my_identity)); #endif - connection->server = server; - total_server_connections++; - if (total_server_connections == num_peers) - { - GNUNET_SCHEDULER_cancel(sched, die_task); - GNUNET_SCHEDULER_add_now(sched, &send_test_messages, NULL); - } + /* + * Connect to the receiving peer + */ + pos->peer2handle = GNUNET_CORE_connect (sched, + pos->peer2->cfg, + TIMEOUT, + pos, + &init_notify_peer2, + NULL, + NULL, + NULL, + GNUNET_YES, NULL, GNUNET_YES, handlers); + } static void -setup_handlers () +send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) { - int i; - struct Connection *new_connection; + struct TestMessageContext *pos = cls; - struct GNUNET_TESTING_Daemon *temp_daemon; - die_task = GNUNET_SCHEDULER_add_delayed (sched, - TEST_TIMEOUT, - &end_badly, "from setup_handlers"); + if ((tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) || (cls == NULL)) + return; + if (die_task == GNUNET_SCHEDULER_NO_TASK) + { + die_task = GNUNET_SCHEDULER_add_delayed (sched, + TEST_TIMEOUT, + &end_badly, "from create topology (timeout)"); + } - /** - * Set up a single handler for each peer + if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS) + { + GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), + &send_test_messages, pos); + return; /* Otherwise we'll double schedule messages here! */ + } + + /* + * Connect to the sending peer */ - for (i = 0; i < num_peers; i++) + pos->peer1handle = GNUNET_CORE_connect (sched, + pos->peer1->cfg, + TIMEOUT, + pos, + &init_notify_peer1, + NULL, + NULL, + NULL, + GNUNET_NO, NULL, GNUNET_NO, no_handlers); + + GNUNET_assert(pos->peer1handle != NULL); + + if (total_server_connections < MAX_OUTSTANDING_CONNECTIONS) { - new_connection = GNUNET_malloc(sizeof(struct Connection)); - temp_daemon = GNUNET_TESTING_daemon_get(pg, i); - new_connection->peer = temp_daemon; - new_connection->server = NULL; - new_connection->next = global_connections; - global_connections = new_connection; - - GNUNET_CORE_connect (sched, - temp_daemon->cfg, - TIMEOUT, - new_connection, - &init_notify, - NULL, - NULL, - NULL, - GNUNET_YES, NULL, GNUNET_YES, handlers); + GNUNET_SCHEDULER_add_now (sched, + &send_test_messages, pos->next); + } + else + { + GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), + &send_test_messages, pos->next); } } - void topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, @@ -425,12 +439,10 @@ topology_callback (void *cls, second_daemon->shortname); #endif temp_context = GNUNET_malloc(sizeof(struct TestMessageContext)); - temp_context->first_step_done = 0; - temp_context->peer1handle = NULL; temp_context->peer1 = first_daemon; temp_context->peer2 = second_daemon; - temp_context->peer2handle = NULL; temp_context->next = test_messages; + temp_context->uid = total_connections; test_messages = temp_context; expected_messages++; @@ -456,16 +468,16 @@ topology_callback (void *cls, #endif GNUNET_SCHEDULER_cancel (sched, die_task); - /* die_task = GNUNET_SCHEDULER_add_now (sched, &setup_handlers, NULL); */ - die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1), &setup_handlers, NULL); + die_task = GNUNET_SCHEDULER_NO_TASK; + GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1), &send_test_messages, test_messages); } else if (total_connections + failed_connections == expected_connections) { if (failed_connections < (unsigned int)(fail_percentage * total_connections)) { GNUNET_SCHEDULER_cancel (sched, die_task); - /* die_task = GNUNET_SCHEDULER_add_now (sched, &setup_handlers, NULL); */ - die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1), &setup_handlers, NULL); + die_task = GNUNET_SCHEDULER_NO_TASK; + GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1), &send_test_messages, test_messages); } else { @@ -541,7 +553,7 @@ my_cb (void *cls, die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5), - &end_badly, NULL); + &end_badly, "from my_cb"); create_topology (); ok = 0; } @@ -580,7 +592,7 @@ run (void *cls, die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5), - &end_badly, NULL); + &end_badly, "didn't start all daemons in reasonable amount of time!!!"); pg = GNUNET_TESTING_daemons_start (sched, cfg, peers_left, &my_cb, NULL, diff --git a/src/testing/testing.c b/src/testing/testing.c index 1df3ad68c..fcc8c9767 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c @@ -38,6 +38,7 @@ #include "gnunet_hello_lib.h" #define DEBUG_TESTING GNUNET_NO +#define DEBUG_TESTING_RECONNECT GNUNET_YES /** * How long do we wait after starting gnunet-service-arm @@ -64,14 +65,26 @@ static void process_hello (void *cls, const struct GNUNET_MessageHeader *message) { struct GNUNET_TESTING_Daemon *daemon = cls; - GNUNET_TRANSPORT_get_hello_cancel(daemon->th, &process_hello, daemon); + if (daemon == NULL) + return; + + if (daemon->server != NULL) + { + GNUNET_CORE_disconnect(daemon->server); + daemon->server = NULL; + } + + GNUNET_assert (message != NULL); + if (daemon->th != NULL) + { + GNUNET_TRANSPORT_get_hello_cancel(daemon->th, &process_hello, daemon); + } #if DEBUG_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' from transport service of `%4s'\n", "HELLO", GNUNET_i2s (&daemon->id)); #endif - GNUNET_assert (message != NULL); GNUNET_free_non_null(daemon->hello); daemon->hello = GNUNET_malloc(ntohs(message->size)); memcpy(daemon->hello, message, ntohs(message->size)); @@ -126,6 +139,7 @@ testing_init (void *cls, d->id = *my_identity; d->shortname = strdup (GNUNET_i2s (my_identity)); d->server = server; + d->running = GNUNET_YES; if (GNUNET_YES == d->dead) GNUNET_TESTING_daemon_stop (d, d->dead_cb, d->dead_cb_cls); else if (NULL != cb) @@ -344,6 +358,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } GNUNET_CONFIGURATION_destroy (d->cfg); GNUNET_free (d->cfgfile); + GNUNET_free_non_null(d->hello); GNUNET_free_non_null (d->hostname); GNUNET_free_non_null (d->username); GNUNET_free_non_null (d->shortname); @@ -370,6 +385,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } GNUNET_CONFIGURATION_destroy (d->cfg); GNUNET_free (d->cfgfile); + GNUNET_free_non_null(d->hello); GNUNET_free_non_null (d->hostname); GNUNET_free_non_null (d->username); GNUNET_free_non_null (d->shortname); @@ -388,6 +404,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /* state clean up and notifications */ GNUNET_CONFIGURATION_destroy (d->cfg); GNUNET_free (d->cfgfile); + GNUNET_free_non_null(d->hello); GNUNET_free_non_null (d->hostname); GNUNET_free_non_null (d->username); GNUNET_free_non_null (d->shortname); @@ -633,14 +650,11 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, "-c", d->cfgfile, "-e", "-d", "-q", NULL); } - GNUNET_free_non_null(d->hello); - d->wait_runs = 0; d->task = GNUNET_SCHEDULER_add_delayed (d->sched, GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, d); - return; } @@ -820,6 +834,12 @@ notify_connect_result (void *cls, ctx->hello_send_task = GNUNET_SCHEDULER_NO_TASK; } + if ((ctx->timeout_task != GNUNET_SCHEDULER_NO_TASK) && (tc->reason != GNUNET_SCHEDULER_REASON_TIMEOUT)) + { + GNUNET_SCHEDULER_cancel(ctx->d1->sched, ctx->timeout_task); + ctx->timeout_task = GNUNET_SCHEDULER_NO_TASK; + } + if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) { if (ctx->d2th != NULL) @@ -842,10 +862,20 @@ notify_connect_result (void *cls, ctx->cb (ctx->cb_cls, &ctx->d1->id, &ctx->d2->id, ctx->d1->cfg, ctx->d2->cfg, ctx->d1, ctx->d2, NULL); } - GNUNET_SCHEDULER_cancel(ctx->d1->sched, ctx->timeout_task); } else if (remaining.value > 0) { + if (ctx->d1core != NULL) + { + GNUNET_CORE_disconnect(ctx->d1core); + ctx->d1core = NULL; + } + + if (ctx->d2th != NULL) + { + GNUNET_TRANSPORT_disconnect(ctx->d2th); + ctx->d2th = NULL; + } GNUNET_SCHEDULER_add_now(ctx->d1->sched, &reattempt_daemons_connect, ctx); return; } @@ -859,7 +889,6 @@ notify_connect_result (void *cls, } } - GNUNET_TRANSPORT_disconnect (ctx->d2th); ctx->d2th = NULL; GNUNET_CORE_disconnect (ctx->d1core); @@ -886,6 +915,8 @@ connect_notify (void *cls, const struct GNUNET_PeerIdentity * peer, struct GNUNE if (memcmp(&ctx->d2->id, peer, sizeof(struct GNUNET_PeerIdentity)) == 0) { ctx->connected = GNUNET_YES; + GNUNET_SCHEDULER_cancel(ctx->d1->sched, ctx->timeout_task); + ctx->timeout_task = GNUNET_SCHEDULER_NO_TASK; GNUNET_SCHEDULER_add_now (ctx->d1->sched, ¬ify_connect_result, ctx); @@ -935,7 +966,7 @@ GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, { struct ConnectContext *ctx; - if ((d1->server == NULL) || (d2->server == NULL)) + if ((d1->running == GNUNET_NO) || (d2->running == GNUNET_NO)) { if (NULL != cb) cb (cb_cls, &d1->id, &d2->id, d1->cfg, d2->cfg, d1, d2, @@ -988,6 +1019,7 @@ GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, d2->cfg, d2, NULL, NULL, NULL); if (ctx->d2th == NULL) { + GNUNET_CORE_disconnect(ctx->d1core); GNUNET_free (ctx); if (NULL != cb) cb (cb_cls, &d1->id, &d2->id, d1->cfg, d2->cfg, d1, d2, @@ -1011,22 +1043,12 @@ reattempt_daemons_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext { return; } -#if DEBUG_TESTING +#if DEBUG_TESTING_RECONNECT GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "re-attempting connect of peer %s to peer %s\n", ctx->d1->shortname, ctx->d2->shortname); #endif - if (ctx->d1core != NULL) - { - GNUNET_CORE_disconnect(ctx->d1core); - ctx->d1core = NULL; - } - - if (ctx->d2th != NULL) - { - GNUNET_TRANSPORT_disconnect(ctx->d2th); - ctx->d2th = NULL; - } + GNUNET_assert(ctx->d1core == NULL); ctx->d1core = GNUNET_CORE_connect (ctx->d1->sched, ctx->d1->cfg, @@ -1049,6 +1071,7 @@ reattempt_daemons_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext ctx->d2->cfg, ctx->d2, NULL, NULL, NULL); if (ctx->d2th == NULL) { + GNUNET_CORE_disconnect(ctx->d1core); GNUNET_free (ctx); if (NULL != ctx->cb) ctx->cb (ctx->cb_cls, &ctx->d1->id, &ctx->d2->id, ctx->d1->cfg, ctx->d2->cfg, ctx->d1, ctx->d2, diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index 49ab8a349..136b167fb 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c @@ -84,7 +84,6 @@ struct PeerData /* * Linked list of peer connections (simply indexes of PeerGroup) - * FIXME: Question, store pointer or integer? Pointer for now... */ struct PeerConnection *connected_peers; }; @@ -255,7 +254,7 @@ make_config (const struct GNUNET_CONFIGURATION_Handle *cfg, uint16_t * port, con if (GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "control_host", &control_host) == GNUNET_OK) { - GNUNET_asprintf(&allowed_hosts, "%s 127.0.0.1;", control_host); + GNUNET_asprintf(&allowed_hosts, "%s; 127.0.0.1;", control_host); GNUNET_CONFIGURATION_set_value_string(uc.ret, "core", "ACCEPT_FROM", allowed_hosts); GNUNET_free_non_null(control_host); GNUNET_free(allowed_hosts); @@ -957,6 +956,10 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg) } } +#if VERBOSE_TESTING + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + _("Finished copying all friend files!\n")); +#endif GNUNET_free(pidarr); return ret; }