aboutsummaryrefslogtreecommitdiff
path: root/src/dv
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-12-07 17:18:53 +0000
committerNathan S. Evans <evans@in.tum.de>2010-12-07 17:18:53 +0000
commit0bb2e2d462b67cc2c6372de8b524f23245ab8926 (patch)
tree75f7d41651b2583166e6334f5089dbb83cf2e0f3 /src/dv
parent811e9e592ec037114b016889609f59d19f414011 (diff)
downloadgnunet-0bb2e2d462b67cc2c6372de8b524f23245ab8926.tar.gz
gnunet-0bb2e2d462b67cc2c6372de8b524f23245ab8926.zip
fixes for DV with new transport distance and core changes over the past few weeks
Diffstat (limited to 'src/dv')
-rw-r--r--src/dv/gnunet-service-dv.c33
-rw-r--r--src/dv/test_transport_api_dv.c117
-rw-r--r--src/dv/test_transport_dv_data.conf4
3 files changed, 106 insertions, 48 deletions
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,
855 */ 855 */
856static void 856static void
857try_core_send (void *cls, 857try_core_send (void *cls,
858 const struct GNUNET_SCHEDULER_TaskContext *tc) 858 const struct GNUNET_SCHEDULER_TaskContext *tc)
859{ 859{
860 struct PendingMessage *pending; 860 struct PendingMessage *pending;
861 pending = core_pending_head; 861 pending = core_pending_head;
@@ -863,8 +863,8 @@ try_core_send (void *cls,
863 if (core_transmit_handle != NULL) 863 if (core_transmit_handle != NULL)
864 return; /* Message send already in progress */ 864 return; /* Message send already in progress */
865 865
866 if (pending != NULL) 866 if ((pending != NULL) && (coreAPI != NULL))
867 core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, pending->importance, pending->timeout, &pending->recipient, pending->msg_size, &core_transmit_notify, NULL); 867 core_transmit_handle = GNUNET_CORE_notify_transmit_ready (coreAPI, pending->importance, pending->timeout, &pending->recipient, pending->msg_size, &core_transmit_notify, NULL);
868} 868}
869 869
870/** 870/**
@@ -1440,8 +1440,6 @@ handle_dv_data_message (void *cls,
1440 pos = pos->next; 1440 pos = pos->next;
1441 } 1441 }
1442#endif 1442#endif
1443 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1444 "%s: unknown sender (%u), Message uid %u from %s!\n", my_short_id, ntohl(incoming->sender), ntohl(incoming->uid), GNUNET_i2s(&dn->identity));
1445 1443
1446 found_pos = -1; 1444 found_pos = -1;
1447 for (i = 0; i< MAX_OUTSTANDING_MESSAGES; i++) 1445 for (i = 0; i< MAX_OUTSTANDING_MESSAGES; i++)
@@ -2148,6 +2146,7 @@ shutdown_task (void *cls,
2148 GNUNET_CONTAINER_heap_destroy(neighbor_min_heap); 2146 GNUNET_CONTAINER_heap_destroy(neighbor_min_heap);
2149 2147
2150 GNUNET_CORE_disconnect (coreAPI); 2148 GNUNET_CORE_disconnect (coreAPI);
2149 coreAPI = NULL;
2151 GNUNET_PEERINFO_disconnect(peerinfo_handle); 2150 GNUNET_PEERINFO_disconnect(peerinfo_handle);
2152 GNUNET_SERVER_mst_destroy(coreMST); 2151 GNUNET_SERVER_mst_destroy(coreMST);
2153 GNUNET_free_non_null(my_short_id); 2152 GNUNET_free_non_null(my_short_id);
@@ -2963,6 +2962,7 @@ void handle_core_disconnect (void *cls,
2963 struct DistantNeighbor *referee; 2962 struct DistantNeighbor *referee;
2964 struct FindDestinationContext fdc; 2963 struct FindDestinationContext fdc;
2965 struct DisconnectContext disconnect_context; 2964 struct DisconnectContext disconnect_context;
2965 struct PendingMessage *pending_pos;
2966 2966
2967#if DEBUG_DV 2967#if DEBUG_DV
2968 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2968 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2971,10 +2971,24 @@ void handle_core_disconnect (void *cls,
2971 2971
2972 neighbor = 2972 neighbor =
2973 GNUNET_CONTAINER_multihashmap_get (direct_neighbors, &peer->hashPubKey); 2973 GNUNET_CONTAINER_multihashmap_get (direct_neighbors, &peer->hashPubKey);
2974
2974 if (neighbor == NULL) 2975 if (neighbor == NULL)
2975 { 2976 {
2976 return; 2977 return;
2977 } 2978 }
2979
2980 pending_pos = core_pending_head;
2981 while (NULL != pending_pos)
2982 {
2983 if (0 == memcmp(&pending_pos->recipient, &neighbor->identity, sizeof(struct GNUNET_PeerIdentity)))
2984 {
2985 GNUNET_CONTAINER_DLL_remove(core_pending_head, core_pending_tail, pending_pos);
2986 pending_pos = core_pending_head;
2987 }
2988 else
2989 pending_pos = pending_pos->next;
2990 }
2991
2978 while (NULL != (referee = neighbor->referee_head)) 2992 while (NULL != (referee = neighbor->referee_head))
2979 distant_neighbor_free (referee); 2993 distant_neighbor_free (referee);
2980 2994
@@ -2992,11 +3006,12 @@ void handle_core_disconnect (void *cls,
2992 3006
2993 GNUNET_assert (neighbor->referee_tail == NULL); 3007 GNUNET_assert (neighbor->referee_tail == NULL);
2994 if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_remove (direct_neighbors, 3008 if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_remove (direct_neighbors,
2995 &peer->hashPubKey, neighbor)) 3009 &peer->hashPubKey, neighbor))
2996 { 3010 {
2997 GNUNET_break(0); 3011 GNUNET_break(0);
2998 } 3012 }
2999 if ((neighbor->send_context != NULL) && (neighbor->send_context->task != GNUNET_SCHEDULER_NO_TASK)) 3013 if ((neighbor->send_context != NULL) &&
3014 (neighbor->send_context->task != GNUNET_SCHEDULER_NO_TASK))
3000 GNUNET_SCHEDULER_cancel(neighbor->send_context->task); 3015 GNUNET_SCHEDULER_cancel(neighbor->send_context->task);
3001 GNUNET_free (neighbor); 3016 GNUNET_free (neighbor);
3002} 3017}
@@ -3072,8 +3087,8 @@ run (void *cls,
3072 3087
3073 /* Scheduled the task to clean up when shutdown is called */ 3088 /* Scheduled the task to clean up when shutdown is called */
3074 cleanup_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 3089 cleanup_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
3075 &shutdown_task, 3090 &shutdown_task,
3076 NULL); 3091 NULL);
3077} 3092}
3078 3093
3079 3094
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 @@
25#include "gnunet_testing_lib.h" 25#include "gnunet_testing_lib.h"
26#include "gnunet_core_service.h" 26#include "gnunet_core_service.h"
27 27
28#define VERBOSE GNUNET_YES 28#define VERBOSE GNUNET_NO
29 29
30#define TEST_ALL GNUNET_NO 30#define TEST_ALL GNUNET_NO
31 31
@@ -502,66 +502,111 @@ static struct GNUNET_CORE_MessageHandler handlers[] = {
502 {NULL, 0, 0} 502 {NULL, 0, 0}
503}; 503};
504 504
505/**
506 * Notify of all peer1's peers, once peer 2 is found, schedule connect
507 * to peer two for message send.
508 *
509 * @param cls closure
510 * @param peer peer identity this notification is about
511 * @param atsi performance data for the connection
512 */
513static void connect_notify_peer2 (void *cls,
514 const struct
515 GNUNET_PeerIdentity *peer,
516 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
517{
518 struct TestMessageContext *pos = cls;
519
520 if (0 == memcmp(&pos->peer1->id, peer, sizeof(struct GNUNET_PeerIdentity)))
521 {
522#if VERBOSE
523 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
524 "Core connection from `%s' to `%4s' verfied, sending message!\n",
525 GNUNET_i2s(&pos->peer2->id), GNUNET_h2s (&peer->hashPubKey));
526#endif
527 if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle,
528 0,
529 TIMEOUT,
530 &pos->peer2->id,
531 sizeof (struct GNUNET_TestMessage),
532 &transmit_ready, pos))
533 {
534 /* This probably shouldn't happen, but it does (timing issue?) */
535 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
536 "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n",
537 GNUNET_i2s (&pos->peer2->id));
538 transmit_ready_failed++;
539 total_other_expected_messages--;
540 }
541 else
542 {
543 transmit_ready_scheduled++;
544 }
545 }
546}
547
505static void 548static void
506init_notify_peer2 (void *cls, 549init_notify_peer2 (void *cls,
507 struct GNUNET_CORE_Handle *server, 550 struct GNUNET_CORE_Handle *server,
508 const struct GNUNET_PeerIdentity *my_identity, 551 const struct GNUNET_PeerIdentity *my_identity,
509 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) 552 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
510{ 553{
511 struct TestMessageContext *pos = cls;
512
513#if VERBOSE 554#if VERBOSE
514 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 555 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
515 "Core connection to `%4s' established, scheduling message send\n", 556 "Core connection to `%4s' established, awaiting connections.\n",
516 GNUNET_i2s (my_identity)); 557 GNUNET_i2s (my_identity));
517#endif 558#endif
518 total_server_connections++; 559 total_server_connections++;
560}
519 561
520 if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, 562/**
521 0, 563 * Notify of all peer1's peers, once peer 2 is found, schedule connect
522 TIMEOUT, 564 * to peer two for message send.
523 &pos->peer2->id, 565 *
524 sizeof (struct GNUNET_TestMessage), 566 * @param cls closure
525 &transmit_ready, pos)) 567 * @param peer peer identity this notification is about
568 * @param atsi performance data for the connection
569 */
570static void connect_notify_peer1 (void *cls,
571 const struct
572 GNUNET_PeerIdentity *peer,
573 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
574{
575 struct TestMessageContext *pos = cls;
576
577 if (0 == memcmp(&pos->peer2->id, peer, sizeof(struct GNUNET_PeerIdentity)))
526 { 578 {
579#if VERBOSE
527 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 580 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
528 "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", 581 "Core connection from `%s' to `%4s' verified.\n",
529 GNUNET_i2s (&pos->peer2->id)); 582 GNUNET_i2s(&pos->peer1->id), GNUNET_h2s (&peer->hashPubKey));
530 transmit_ready_failed++; 583#endif
531 } 584 /*
532 else 585 * Connect to the receiving peer
533 { 586 */
534 transmit_ready_scheduled++; 587 pos->peer2handle = GNUNET_CORE_connect (pos->peer2->cfg,
588 1,
589 pos,
590 &init_notify_peer2,
591 &connect_notify_peer2,
592 NULL,
593 NULL, NULL,
594 GNUNET_YES, NULL, GNUNET_YES, handlers);
535 } 595 }
536} 596}
537 597
538
539static void 598static void
540init_notify_peer1 (void *cls, 599init_notify_peer1 (void *cls,
541 struct GNUNET_CORE_Handle *server, 600 struct GNUNET_CORE_Handle *server,
542 const struct GNUNET_PeerIdentity *my_identity, 601 const struct GNUNET_PeerIdentity *my_identity,
543 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) 602 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
544{ 603{
545 struct TestMessageContext *pos = cls;
546 total_server_connections++; 604 total_server_connections++;
547
548#if VERBOSE 605#if VERBOSE
549 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 606 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
550 "Core connection to `%4s' established, setting up handles\n", 607 "Core connection to `%4s' established, awaiting connections...\n",
551 GNUNET_i2s (my_identity)); 608 GNUNET_i2s (my_identity));
552#endif 609#endif
553
554 /*
555 * Connect to the receiving peer
556 */
557 pos->peer2handle = GNUNET_CORE_connect (pos->peer2->cfg,
558 1,
559 pos,
560 &init_notify_peer2,
561 NULL,
562 NULL,
563 NULL, NULL,
564 GNUNET_YES, NULL, GNUNET_YES, handlers);
565} 610}
566 611
567 612
@@ -595,7 +640,8 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
595 1, 640 1,
596 pos, 641 pos,
597 &init_notify_peer1, 642 &init_notify_peer1,
598 NULL, NULL, 643 &connect_notify_peer1,
644 NULL,
599 NULL, 645 NULL,
600 NULL, 646 NULL,
601 GNUNET_NO, NULL, GNUNET_NO, no_handlers); 647 GNUNET_NO, NULL, GNUNET_NO, no_handlers);
@@ -718,9 +764,7 @@ topology_callback (void *cls,
718 temp_context->uid = total_connections; 764 temp_context->uid = total_connections;
719 temp_context->disconnect_task = GNUNET_SCHEDULER_NO_TASK; 765 temp_context->disconnect_task = GNUNET_SCHEDULER_NO_TASK;
720 test_messages = temp_context; 766 test_messages = temp_context;
721
722 expected_messages++; 767 expected_messages++;
723
724 } 768 }
725#if VERBOSE 769#if VERBOSE
726 else 770 else
@@ -864,7 +908,6 @@ static void all_connect_handler (void *cls,
864 } 908 }
865#endif 909#endif
866 910
867
868 if (dotOutFile != NULL) 911 if (dotOutFile != NULL)
869 { 912 {
870 if (distance == 1) 913 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
46PORT = 2571 46PORT = 2571
47 47
48[testing] 48[testing]
49NUM_PEERS = 3 49NUM_PEERS = 5
50ADDITIONAL_MESSAGES = 2 50ADDITIONAL_MESSAGES = 10
51DEBUG = NO 51DEBUG = NO
52WEAKRANDOM = YES 52WEAKRANDOM = YES
53TOPOLOGY = CLIQUE 53TOPOLOGY = CLIQUE