From 3294e6c66210cdcca65524593ce09bbf4db14c7f Mon Sep 17 00:00:00 2001 From: "Nathan S. Evans" Date: Tue, 15 Feb 2011 12:06:37 +0000 Subject: [PATCH] Testing api change and related test case fixes, remember retry task and clean up on exit for unix domain socket transport. --- src/core/core_api.c | 4 ++ src/core/gnunet-service-core.c | 6 +- src/dht/test_dht_multipeer.c | 5 +- src/dht/test_dht_twopeer.c | 1 + src/dht/test_dht_twopeer_path_tracking.c | 5 +- src/dht/test_dht_twopeer_put_get.c | 1 + src/dv/test_transport_api_dv.c | 5 +- src/fs/fs_test_lib.c | 1 + src/include/gnunet_testing_lib.h | 5 +- src/testing/test_testing_group.c | 5 +- src/testing/test_testing_group_remote.c | 5 +- src/testing/test_testing_large_topology.c | 1 + src/testing/test_testing_topology.c | 1 + src/testing/test_testing_topology_blacklist.c | 2 +- src/testing/test_testing_topology_churn.c | 4 +- src/topology/test_gnunet_daemon_topology.c | 1 + src/transport/plugin_transport_unix.c | 64 ++++++++++++++++++- 17 files changed, 99 insertions(+), 17 deletions(-) diff --git a/src/core/core_api.c b/src/core/core_api.c index a2e0dae09..f4a197909 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c @@ -1728,6 +1728,10 @@ GNUNET_CORE_peer_request_connect (struct GNUNET_CORE_Handle *h, struct GNUNET_CORE_PeerRequestHandle *ret; struct ControlMessage *cm; struct ConnectMessage *msg; + + if (NULL != GNUNET_CONTAINER_multihashmap_get (h->peers, + &peer->hashPubKey)) + GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "core_api", "Received CONNECT requests for already connected peer!\n"); cm = GNUNET_malloc (sizeof (struct ControlMessage) + sizeof (struct ConnectMessage)); diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index 410d65b93..4519991b3 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c @@ -3336,9 +3336,9 @@ process_hello_retry_handle_set_key (void *cls, if (err_msg != NULL) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Error in communication with PEERINFO service\n")); - /* return; */ + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + _("Error in communication with PEERINFO service\n")); + /* return; */ } if (peer == NULL) diff --git a/src/dht/test_dht_multipeer.c b/src/dht/test_dht_multipeer.c index 626c1bc30..593e96527 100644 --- a/src/dht/test_dht_multipeer.c +++ b/src/dht/test_dht_multipeer.c @@ -876,8 +876,9 @@ run (void *cls, &end_badly, "didn't generate all hostkeys within a reasonable amount of time!!!"); pg = GNUNET_TESTING_daemons_start (cfg, - peers_left, - peers_left, + peers_left, /* Total number of peers */ + peers_left, /* Number of outstanding connections */ + peers_left, /* Number of parallel ssh connections, or peers being started at once */ GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers), &hostkey_callback, NULL, diff --git a/src/dht/test_dht_twopeer.c b/src/dht/test_dht_twopeer.c index e85c6101b..8c373d365 100644 --- a/src/dht/test_dht_twopeer.c +++ b/src/dht/test_dht_twopeer.c @@ -415,6 +415,7 @@ run (void *cls, pg = GNUNET_TESTING_daemons_start (cfg, num_peers, 10, + num_peers, TIMEOUT, NULL, NULL, &peers_started_callback, diff --git a/src/dht/test_dht_twopeer_path_tracking.c b/src/dht/test_dht_twopeer_path_tracking.c index f8ce26da6..d4e5a1332 100644 --- a/src/dht/test_dht_twopeer_path_tracking.c +++ b/src/dht/test_dht_twopeer_path_tracking.c @@ -461,8 +461,9 @@ run (void *cls, /* Start num_peers peers, call peers_started_callback on peer start, topology_callback on peer connect */ /* Read the API documentation for other parameters! */ pg = GNUNET_TESTING_daemons_start (cfg, - num_peers, - num_peers, + peers_left, /* Total number of peers */ + peers_left, /* Number of outstanding connections */ + peers_left, /* Number of parallel ssh connections, or peers being started at once */ TIMEOUT, NULL, NULL, diff --git a/src/dht/test_dht_twopeer_put_get.c b/src/dht/test_dht_twopeer_put_get.c index 057f9ebfe..40a165236 100644 --- a/src/dht/test_dht_twopeer_put_get.c +++ b/src/dht/test_dht_twopeer_put_get.c @@ -540,6 +540,7 @@ run (void *cls, pg = GNUNET_TESTING_daemons_start (cfg, num_peers, 2, + 2, TIMEOUT, NULL, NULL, diff --git a/src/dv/test_transport_api_dv.c b/src/dv/test_transport_api_dv.c index 8a2e54142..e6caa43ca 100644 --- a/src/dv/test_transport_api_dv.c +++ b/src/dv/test_transport_api_dv.c @@ -1138,8 +1138,9 @@ run (void *cls, peer_daemon_hash = GNUNET_CONTAINER_multihashmap_create(peers_left); pg = GNUNET_TESTING_daemons_start (cfg, - peers_left, - peers_left, + peers_left, /* Total number of peers */ + peers_left, /* Number of outstanding connections */ + peers_left, /* Number of parallel ssh connections, or peers being started at once */ TIMEOUT, &hostkey_callback, NULL, diff --git a/src/fs/fs_test_lib.c b/src/fs/fs_test_lib.c index 287c0eb1c..a3f33a522 100644 --- a/src/fs/fs_test_lib.c +++ b/src/fs/fs_test_lib.c @@ -395,6 +395,7 @@ GNUNET_FS_TEST_daemons_start (const char *template_cfg_file, sctx->group = GNUNET_TESTING_daemons_start (sctx->cfg, total, total, /* Outstanding connections */ + total, /* Outstanding ssh connections */ timeout, NULL, NULL, diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h index b0c43c44b..6ddc4ea74 100644 --- a/src/include/gnunet_testing_lib.h +++ b/src/include/gnunet_testing_lib.h @@ -567,7 +567,9 @@ void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, * @param cfg configuration template to use * @param total number of daemons to start * @param max_concurrent_connections for testing, how many peers can - * we connect to simultaneously +* we connect to simultaneously + * @param max_concurrent_ssh when starting with ssh, how many ssh + * connections will we allow at once (based on remote hosts allowed!) * @param timeout total time allowed for peers to start * @param hostkey_callback function to call on each peers hostkey generation * if NULL, peers will be started by this call, if non-null, @@ -587,6 +589,7 @@ struct GNUNET_TESTING_PeerGroup * GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int total, unsigned int max_concurrent_connections, + unsigned int max_concurrent_ssh, struct GNUNET_TIME_Relative timeout, GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback, void *hostkey_cls, diff --git a/src/testing/test_testing_group.c b/src/testing/test_testing_group.c index 1facaa63f..0056588bc 100644 --- a/src/testing/test_testing_group.c +++ b/src/testing/test_testing_group.c @@ -116,8 +116,9 @@ run (void *cls, #endif peers_left = NUM_PEERS; pg = GNUNET_TESTING_daemons_start (cfg, - peers_left, - NUM_PEERS, + peers_left, /* Total number of peers */ + peers_left, /* Number of outstanding connections */ + peers_left, /* Number of parallel ssh connections, or peers being started at once */ TIMEOUT, NULL, NULL, &my_cb, NULL, NULL, NULL, NULL); diff --git a/src/testing/test_testing_group_remote.c b/src/testing/test_testing_group_remote.c index 02f76f826..6a4d0cc1e 100644 --- a/src/testing/test_testing_group_remote.c +++ b/src/testing/test_testing_group_remote.c @@ -202,8 +202,9 @@ run (void *cls, peers_left = num_peers; pg = GNUNET_TESTING_daemons_start (cfg, - peers_left, - peers_left, + peers_left, /* Total number of peers */ + peers_left, /* Number of outstanding connections */ + peers_left, /* Number of parallel ssh connections, or peers being started at once */ TIMEOUT, NULL, NULL, &my_cb, NULL, NULL, NULL, hosts); diff --git a/src/testing/test_testing_large_topology.c b/src/testing/test_testing_large_topology.c index 46626618a..9f6b27059 100644 --- a/src/testing/test_testing_large_topology.c +++ b/src/testing/test_testing_large_topology.c @@ -1131,6 +1131,7 @@ run (void *cls, pg = GNUNET_TESTING_daemons_start (cfg, peers_left, peers_left / 2, + peers_left, timeout, &hostkey_callback, NULL, &peers_started_callback, NULL, diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c index 66540c078..5af3e9ed2 100644 --- a/src/testing/test_testing_topology.c +++ b/src/testing/test_testing_topology.c @@ -1181,6 +1181,7 @@ run (void *cls, pg = GNUNET_TESTING_daemons_start (cfg, peers_left, peers_left / 2, + peers_left, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers), diff --git a/src/testing/test_testing_topology_blacklist.c b/src/testing/test_testing_topology_blacklist.c index 2c1a8b31c..ea32e339d 100644 --- a/src/testing/test_testing_topology_blacklist.c +++ b/src/testing/test_testing_topology_blacklist.c @@ -535,7 +535,7 @@ run (void *cls, "didn't start all daemons in reasonable amount of time!!!"); pg = GNUNET_TESTING_daemons_start (cfg, - peers_left, peers_left, + peers_left, peers_left, peers_left, TIMEOUT, &hostkey_callback, NULL, &peers_started_callback, NULL, &topology_callback, NULL, NULL); diff --git a/src/testing/test_testing_topology_churn.c b/src/testing/test_testing_topology_churn.c index 33f3a0737..f1d93fa46 100644 --- a/src/testing/test_testing_topology_churn.c +++ b/src/testing/test_testing_topology_churn.c @@ -281,7 +281,9 @@ run (void *cls, pg = GNUNET_TESTING_daemons_start (cfg, peers_left, - peers_left, TIMEOUT, NULL, NULL, + peers_left, + peers_left, + TIMEOUT, NULL, NULL, &peers_started_callback, NULL, NULL, NULL, NULL); diff --git a/src/topology/test_gnunet_daemon_topology.c b/src/topology/test_gnunet_daemon_topology.c index ae96b071c..dc6cb7375 100644 --- a/src/topology/test_gnunet_daemon_topology.c +++ b/src/topology/test_gnunet_daemon_topology.c @@ -153,6 +153,7 @@ run (void *cls, #endif peers_left = NUM_PEERS; pg = GNUNET_TESTING_daemons_start (cfg, + peers_left, peers_left, peers_left, TIMEOUT, diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c index 790e4451f..0163a8e5b 100644 --- a/src/transport/plugin_transport_unix.c +++ b/src/transport/plugin_transport_unix.c @@ -80,6 +80,24 @@ struct UNIXMessage }; +struct RetryList +{ + /** + * Pointer to next element. + */ + struct RetryList *next; + + /** + * Pointer to previous element. + */ + struct RetryList *prev; + + /** + * The actual retry context. + */ + struct RetrySendContext *retry_ctx; +}; + /** * Network format for IPv4 addresses. */ @@ -191,6 +209,11 @@ struct RetrySendContext * The priority of the message. */ unsigned int priority; + + /** + * Entry in the DLL of retry items. + */ + struct RetryList *retry_list_entry; }; /** @@ -342,6 +365,16 @@ struct Plugin }; +/** + * Head of retry DLL. + */ +static struct RetryList *retry_list_head; + +/** + * Tail of retry DLL. + */ +static struct RetryList *retry_list_tail; + /** * Disconnect from a remote node. Clean up session if we have one for this peer @@ -370,6 +403,22 @@ static int unix_transport_server_stop (void *cls) { struct Plugin *plugin = cls; + struct RetryList *pos; + + pos = retry_list_head; + + while(NULL != (pos = retry_list_head)) + { + GNUNET_CONTAINER_DLL_remove(retry_list_head, retry_list_tail, pos); + if (GNUNET_SCHEDULER_NO_TASK != pos->retry_ctx->retry_task) + { + GNUNET_SCHEDULER_cancel(pos->retry_ctx->retry_task); + } + GNUNET_free(pos->retry_ctx->msg); + GNUNET_free(pos->retry_ctx->addr); + GNUNET_free(pos->retry_ctx); + GNUNET_free(pos); + } if (plugin->select_task != GNUNET_SCHEDULER_NO_TASK) { @@ -428,7 +477,13 @@ void retry_send_message (void *cls, struct RetrySendContext *retry_ctx = cls; if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) - return; + { + GNUNET_free(retry_ctx->msg); + GNUNET_free(retry_ctx->addr); + GNUNET_free(retry_ctx); + return; + } + unix_real_send (retry_ctx->plugin, retry_ctx, retry_ctx->send_handle, @@ -489,6 +544,7 @@ unix_real_send (void *cls, size_t sbs; struct sockaddr_un un; size_t slen; + struct RetryList *retry_list_entry; if (send_handle == NULL) { @@ -542,6 +598,7 @@ unix_real_send (void *cls, { if (incoming_retry_context == NULL) { + retry_list_entry = GNUNET_malloc(sizeof(struct RetryList)); retry_ctx = GNUNET_malloc(sizeof(struct RetrySendContext)); retry_ctx->addr = GNUNET_malloc(addrlen); retry_ctx->msg = GNUNET_malloc(msgbuf_size); @@ -557,6 +614,9 @@ unix_real_send (void *cls, retry_ctx->timeout = GNUNET_TIME_relative_to_absolute(timeout); memcpy(&retry_ctx->target, target, sizeof(struct GNUNET_PeerIdentity)); retry_ctx->delay = GNUNET_TIME_UNIT_MILLISECONDS; + retry_ctx->retry_list_entry = retry_list_entry; + retry_list_entry->retry_ctx = retry_ctx; + GNUNET_CONTAINER_DLL_insert(retry_list_head, retry_list_tail, retry_list_entry); } else { @@ -597,6 +657,8 @@ unix_real_send (void *cls, if (incoming_retry_context != NULL) { + GNUNET_CONTAINER_DLL_remove(retry_list_head, retry_list_tail, incoming_retry_context->retry_list_entry); + GNUNET_free(incoming_retry_context->retry_list_entry); GNUNET_free(incoming_retry_context->msg); GNUNET_free(incoming_retry_context->addr); GNUNET_free(incoming_retry_context); -- 2.25.1