From: Bart Polot Date: Mon, 31 Oct 2011 17:42:05 +0000 (+0000) Subject: Don't try to send traffic to a peer that is not connected to us X-Git-Tag: initial-import-from-subversion-38251~16131 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=cd885f7b532d11a9de8dcbb2ca4fb007e4e53643;p=oweals%2Fgnunet.git Don't try to send traffic to a peer that is not connected to us --- diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index 9b76e6b1e..0a481d6e9 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c @@ -444,6 +444,11 @@ static struct GNUNET_CONTAINER_MultiHashMap *peers; */ static struct GNUNET_CORE_Handle *core_handle; +/** + * Handle to communicate with transport + */ +// static struct GNUNET_TRANSPORT_Handle *transport_handle; + /** * Handle to use DHT */ @@ -1139,14 +1144,29 @@ send_message (const struct GNUNET_MessageHeader *message, { struct MeshDataDescriptor *info; struct MeshPeerInfo *neighbor; + struct MeshPeerPath *p; unsigned int i; size_t size; +// GNUNET_TRANSPORT_try_connect(); + size = ntohs (message->size); info = GNUNET_malloc (sizeof (struct MeshDataDescriptor)); info->data = GNUNET_malloc (size); memcpy (info->data, message, size); neighbor = peer_info_get (peer); + for (p = neighbor->path_head; NULL != p; p = p->next) + { + if (2 == p->length) + { + break; + } + } + if (NULL == p) + { + GNUNET_break (0); + return; + } i = peer_info_transmit_slot (neighbor); info->handler_n = i; info->peer = neighbor; @@ -4328,6 +4348,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, NULL, /* Don't notify about all outbound messages */ GNUNET_NO, /* For header-only out notification */ core_handlers); /* Register these handlers */ + if (core_handle == NULL) { GNUNET_break (0); @@ -4359,6 +4380,13 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, &my_full_id.hashPubKey); myid = GNUNET_PEER_intern (&my_full_id); +// // transport_handle = GNUNET_TRANSPORT_connect(c, +// // &my_full_id, +// // NULL, +// // NULL, +// // NULL, +// // NULL); + dht_handle = GNUNET_DHT_connect (c, 64); if (dht_handle == NULL) {