From: Nathan S. Evans Date: Thu, 4 Mar 2010 10:16:43 +0000 (+0000) Subject: connecting peers relies on connections completed thus far, instead of estimating... X-Git-Tag: initial-import-from-subversion-38251~22568 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=2ca2d00cf87bdc35900e6d0de1d79cfc38d13eb9;p=oweals%2Fgnunet.git connecting peers relies on connections completed thus far, instead of estimating how many should be complete --- diff --git a/src/testing/test_testing_data_topology_clique.conf b/src/testing/test_testing_data_topology_clique.conf index 2a8934c34..535b6db8c 100644 --- a/src/testing/test_testing_data_topology_clique.conf +++ b/src/testing/test_testing_data_topology_clique.conf @@ -24,13 +24,17 @@ PORT = 2568 [peerinfo] PORT = 2569 +#DEBUG = YES +#PREFIX = xterm -e xterm -T peerinfo -e gdb --args [core] PORT = 2570 -#DEBUG = YES +#PREFIX = xterm -e xterm -T CORE -e gdb --args +#PREFIX = valgrind --tool=memcheck --log-file=logs%p +DEBUG = YES [testing] -NUM_PEERS = 5 +NUM_PEERS = 8 WEAKRANDOM = YES TOPOLOGY = 0 F2F = YES diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c index 778c0c00a..910dead55 100644 --- a/src/testing/test_testing_topology.c +++ b/src/testing/test_testing_topology.c @@ -25,10 +25,10 @@ #include "gnunet_testing_lib.h" #include "gnunet_core_service.h" -#define VERBOSE GNUNET_NO +#define VERBOSE GNUNET_YES -#define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) +#define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 360) /** * How long until we give up on connecting the peers? */ diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index 94f8dce04..30c4fc886 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c @@ -44,6 +44,8 @@ */ #define HIGH_PORT 32000 +#define MAX_OUTSTANDING_CONNECTIONS 30 + #define CONNECT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 180) struct PeerConnection @@ -164,6 +166,22 @@ struct UpdateContext unsigned int nport; }; + +struct ConnectContext +{ + struct GNUNET_TESTING_Daemon *first; + + struct GNUNET_TESTING_Daemon *second; + + struct GNUNET_TESTING_PeerGroup *pg; +}; + +/** + * Number of connects we are waiting on, allows us to rate limit + * connect attempts. + */ +static int outstanding_connects; + /** * Function to iterate over options. Copies * the options to the target configuration, @@ -908,7 +926,53 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg) return ret; } +/** + * Internal notification of a connection, kept so that we can ensure some connections + * happen instead of flooding all testing daemons with requests to connect. + */ +static void internal_connect_notify (void *cls, + const struct GNUNET_PeerIdentity *first, + const struct GNUNET_PeerIdentity *second, + const struct GNUNET_CONFIGURATION_Handle *first_cfg, + const struct GNUNET_CONFIGURATION_Handle *second_cfg, + struct GNUNET_TESTING_Daemon *first_daemon, + struct GNUNET_TESTING_Daemon *second_daemon, + const char *emsg) +{ + struct GNUNET_TESTING_PeerGroup *pg = cls; + outstanding_connects--; + + pg->notify_connection(pg->notify_connection_cls, first, second, first_cfg, second_cfg, first_daemon, second_daemon, emsg); + +} + +static void schedule_connect(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +{ + struct ConnectContext *connect_context = cls; + if (outstanding_connects > MAX_OUTSTANDING_CONNECTIONS) + { +#if VERBOSE_TESTING + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + _("Delaying connect, we have too many outstanding connections!\n")); +#endif + GNUNET_SCHEDULER_add_delayed(connect_context->pg->sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3), &schedule_connect, connect_context); + } + else + { +#if VERBOSE_TESTING + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + _("Creating connection, outstanding_connections is %d\n"), outstanding_connects); +#endif + outstanding_connects++; + GNUNET_TESTING_daemons_connect (connect_context->first, + connect_context->second, + CONNECT_TIMEOUT, + &internal_connect_notify, + connect_context->pg); + GNUNET_free(connect_context); + } +} /* * Connect the topology as specified by the PeerConnection's @@ -921,29 +985,34 @@ connect_topology (struct GNUNET_TESTING_PeerGroup *pg) { unsigned int pg_iter; struct PeerConnection *connection_iter; - int connect_count; + struct ConnectContext *connect_context; - connect_count = 0; for (pg_iter = 0; pg_iter < pg->total; pg_iter++) { connection_iter = pg->peers[pg_iter].connected_peers; while (connection_iter != NULL) { - GNUNET_TESTING_daemons_connect (pg->peers[pg_iter].daemon, + connect_context = GNUNET_malloc(sizeof(struct ConnectContext)); + connect_context->pg = pg; + connect_context->first = pg->peers[pg_iter].daemon; + connect_context->second = connection_iter->daemon; + + GNUNET_SCHEDULER_add_now(pg->sched, &schedule_connect, connect_context); + /*GNUNET_TESTING_daemons_connect (pg->peers[pg_iter].daemon, connection_iter->daemon, CONNECT_TIMEOUT, pg->notify_connection, - pg->notify_connection_cls); + pg->notify_connection_cls);*/ connection_iter = connection_iter->next; - connect_count++; - if (connect_count % 50 == 0) + + /*if (outstanding_connects > MAX_OUTSTANDING_CONNECTS) { #if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Sleeping to give peers a chance to connect!\n")); #endif sleep(2); - } + } */ } } }