From: Nathan S. Evans Date: Tue, 7 Dec 2010 17:18:53 +0000 (+0000) Subject: fixes for DV with new transport distance and core changes over the past few weeks X-Git-Tag: initial-import-from-subversion-38251~19541 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=0bb2e2d462b67cc2c6372de8b524f23245ab8926;p=oweals%2Fgnunet.git fixes for DV with new transport distance and core changes over the past few weeks --- diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c index 78e63facc..28362b82f 100644 --- a/src/dv/gnunet-service-dv.c +++ b/src/dv/gnunet-service-dv.c @@ -855,7 +855,7 @@ size_t core_transmit_notify (void *cls, */ static void try_core_send (void *cls, - const struct GNUNET_SCHEDULER_TaskContext *tc) + const struct GNUNET_SCHEDULER_TaskContext *tc) { struct PendingMessage *pending; pending = core_pending_head; @@ -863,8 +863,8 @@ try_core_send (void *cls, if (core_transmit_handle != NULL) return; /* Message send already in progress */ - if (pending != NULL) - core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, pending->importance, pending->timeout, &pending->recipient, pending->msg_size, &core_transmit_notify, NULL); + if ((pending != NULL) && (coreAPI != NULL)) + core_transmit_handle = GNUNET_CORE_notify_transmit_ready (coreAPI, pending->importance, pending->timeout, &pending->recipient, pending->msg_size, &core_transmit_notify, NULL); } /** @@ -1440,8 +1440,6 @@ handle_dv_data_message (void *cls, pos = pos->next; } #endif - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "%s: unknown sender (%u), Message uid %u from %s!\n", my_short_id, ntohl(incoming->sender), ntohl(incoming->uid), GNUNET_i2s(&dn->identity)); found_pos = -1; for (i = 0; i< MAX_OUTSTANDING_MESSAGES; i++) @@ -2148,6 +2146,7 @@ shutdown_task (void *cls, GNUNET_CONTAINER_heap_destroy(neighbor_min_heap); GNUNET_CORE_disconnect (coreAPI); + coreAPI = NULL; GNUNET_PEERINFO_disconnect(peerinfo_handle); GNUNET_SERVER_mst_destroy(coreMST); GNUNET_free_non_null(my_short_id); @@ -2963,6 +2962,7 @@ void handle_core_disconnect (void *cls, struct DistantNeighbor *referee; struct FindDestinationContext fdc; struct DisconnectContext disconnect_context; + struct PendingMessage *pending_pos; #if DEBUG_DV GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -2971,10 +2971,24 @@ void handle_core_disconnect (void *cls, neighbor = GNUNET_CONTAINER_multihashmap_get (direct_neighbors, &peer->hashPubKey); + if (neighbor == NULL) { return; } + + pending_pos = core_pending_head; + while (NULL != pending_pos) + { + if (0 == memcmp(&pending_pos->recipient, &neighbor->identity, sizeof(struct GNUNET_PeerIdentity))) + { + GNUNET_CONTAINER_DLL_remove(core_pending_head, core_pending_tail, pending_pos); + pending_pos = core_pending_head; + } + else + pending_pos = pending_pos->next; + } + while (NULL != (referee = neighbor->referee_head)) distant_neighbor_free (referee); @@ -2992,11 +3006,12 @@ void handle_core_disconnect (void *cls, GNUNET_assert (neighbor->referee_tail == NULL); if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_remove (direct_neighbors, - &peer->hashPubKey, neighbor)) + &peer->hashPubKey, neighbor)) { GNUNET_break(0); } - if ((neighbor->send_context != NULL) && (neighbor->send_context->task != GNUNET_SCHEDULER_NO_TASK)) + if ((neighbor->send_context != NULL) && + (neighbor->send_context->task != GNUNET_SCHEDULER_NO_TASK)) GNUNET_SCHEDULER_cancel(neighbor->send_context->task); GNUNET_free (neighbor); } @@ -3072,8 +3087,8 @@ run (void *cls, /* Scheduled the task to clean up when shutdown is called */ cleanup_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &shutdown_task, - NULL); + &shutdown_task, + NULL); } diff --git a/src/dv/test_transport_api_dv.c b/src/dv/test_transport_api_dv.c index 47b35a358..c37448342 100644 --- a/src/dv/test_transport_api_dv.c +++ b/src/dv/test_transport_api_dv.c @@ -25,7 +25,7 @@ #include "gnunet_testing_lib.h" #include "gnunet_core_service.h" -#define VERBOSE GNUNET_YES +#define VERBOSE GNUNET_NO #define TEST_ALL GNUNET_NO @@ -502,66 +502,111 @@ static struct GNUNET_CORE_MessageHandler handlers[] = { {NULL, 0, 0} }; +/** + * Notify of all peer1's peers, once peer 2 is found, schedule connect + * to peer two for message send. + * + * @param cls closure + * @param peer peer identity this notification is about + * @param atsi performance data for the connection + */ +static void connect_notify_peer2 (void *cls, + const struct + GNUNET_PeerIdentity *peer, + const struct GNUNET_TRANSPORT_ATS_Information *atsi) +{ + struct TestMessageContext *pos = cls; + + if (0 == memcmp(&pos->peer1->id, peer, sizeof(struct GNUNET_PeerIdentity))) + { +#if VERBOSE + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Core connection from `%s' to `%4s' verfied, sending message!\n", + GNUNET_i2s(&pos->peer2->id), GNUNET_h2s (&peer->hashPubKey)); +#endif + if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, + 0, + TIMEOUT, + &pos->peer2->id, + sizeof (struct GNUNET_TestMessage), + &transmit_ready, pos)) + { + /* This probably shouldn't happen, but it does (timing issue?) */ + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", + GNUNET_i2s (&pos->peer2->id)); + transmit_ready_failed++; + total_other_expected_messages--; + } + else + { + transmit_ready_scheduled++; + } + } +} + static void 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 = cls; - #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Core connection to `%4s' established, scheduling message send\n", + "Core connection to `%4s' established, awaiting connections.\n", GNUNET_i2s (my_identity)); #endif total_server_connections++; +} - if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, - 0, - TIMEOUT, - &pos->peer2->id, - sizeof (struct GNUNET_TestMessage), - &transmit_ready, pos)) +/** + * Notify of all peer1's peers, once peer 2 is found, schedule connect + * to peer two for message send. + * + * @param cls closure + * @param peer peer identity this notification is about + * @param atsi performance data for the connection + */ +static void connect_notify_peer1 (void *cls, + const struct + GNUNET_PeerIdentity *peer, + const struct GNUNET_TRANSPORT_ATS_Information *atsi) +{ + struct TestMessageContext *pos = cls; + + if (0 == memcmp(&pos->peer2->id, peer, sizeof(struct GNUNET_PeerIdentity))) { +#if VERBOSE 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++; + "Core connection from `%s' to `%4s' verified.\n", + GNUNET_i2s(&pos->peer1->id), GNUNET_h2s (&peer->hashPubKey)); +#endif + /* + * Connect to the receiving peer + */ + pos->peer2handle = GNUNET_CORE_connect (pos->peer2->cfg, + 1, + pos, + &init_notify_peer2, + &connect_notify_peer2, + NULL, + NULL, NULL, + GNUNET_YES, NULL, GNUNET_YES, handlers); } } - static void init_notify_peer1 (void *cls, struct GNUNET_CORE_Handle *server, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) { - struct TestMessageContext *pos = cls; total_server_connections++; - #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Core connection to `%4s' established, setting up handles\n", + "Core connection to `%4s' established, awaiting connections...\n", GNUNET_i2s (my_identity)); #endif - - /* - * Connect to the receiving peer - */ - pos->peer2handle = GNUNET_CORE_connect (pos->peer2->cfg, - 1, - pos, - &init_notify_peer2, - NULL, - NULL, - NULL, NULL, - GNUNET_YES, NULL, GNUNET_YES, handlers); } @@ -595,7 +640,8 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) 1, pos, &init_notify_peer1, - NULL, NULL, + &connect_notify_peer1, + NULL, NULL, NULL, GNUNET_NO, NULL, GNUNET_NO, no_handlers); @@ -718,9 +764,7 @@ topology_callback (void *cls, temp_context->uid = total_connections; temp_context->disconnect_task = GNUNET_SCHEDULER_NO_TASK; test_messages = temp_context; - expected_messages++; - } #if VERBOSE else @@ -864,7 +908,6 @@ static void all_connect_handler (void *cls, } #endif - if (dotOutFile != NULL) { if (distance == 1) diff --git a/src/dv/test_transport_dv_data.conf b/src/dv/test_transport_dv_data.conf index 63ca7b3c2..69121e275 100644 --- a/src/dv/test_transport_dv_data.conf +++ b/src/dv/test_transport_dv_data.conf @@ -46,8 +46,8 @@ HOSTNAME = localhost PORT = 2571 [testing] -NUM_PEERS = 3 -ADDITIONAL_MESSAGES = 2 +NUM_PEERS = 5 +ADDITIONAL_MESSAGES = 10 DEBUG = NO WEAKRANDOM = YES TOPOLOGY = CLIQUE