From 8df13cbe011501b88c0edd2ecb54e0ce3ae2ff0e Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Mon, 24 Oct 2011 17:00:00 +0000 Subject: [PATCH] Refactored 'type' DHT response processing --- src/mesh/gnunet-service-mesh.c | 50 ++++++++-------------------------- 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index cbe369cdf..0b44daf6b 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c @@ -2917,12 +2917,12 @@ handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer, GNUNET_break_op (0); return GNUNET_OK; } - peer_info = peer_info_get (&msg->peer_id); - if (NULL == peer_info) + if (NULL != t->dht_get_type) { - GNUNET_break_op (0); - return GNUNET_OK; + GNUNET_DHT_get_stop (t->dht_get_type); + t->dht_get_type = NULL; } + peer_info = peer_info_get (&msg->peer_id); n = tree_find_peer(t->tree->root, peer_info->id); if (NULL == n) { @@ -3147,11 +3147,9 @@ dht_get_type_handler (void *cls, struct GNUNET_TIME_Absolute exp, const void *data) { const struct GNUNET_PeerIdentity *pi = data; - struct GNUNET_PeerIdentity id; struct MeshTunnel *t = cls; struct MeshPeerInfo *peer_info; struct MeshPeerPath *p; - int i; if (size != sizeof (struct GNUNET_PeerIdentity)) { @@ -3159,42 +3157,18 @@ dht_get_type_handler (void *cls, struct GNUNET_TIME_Absolute exp, return; } GNUNET_assert (NULL != t->client); - GNUNET_DHT_get_stop (t->dht_get_type); - t->dht_get_type = NULL; peer_info = peer_info_get (pi); - GNUNET_CONTAINER_multihashmap_put (t->peers, &pi->hashPubKey, peer_info, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); - - if ((NULL == get_path || NULL == put_path) && NULL == peer_info->path_head && - NULL == peer_info->dhtget) - { - peer_info_connect (peer_info, t); - return; - } + (void) GNUNET_CONTAINER_multihashmap_put ( + t->peers, + &pi->hashPubKey, + peer_info, + GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); - p = path_build_from_dht (get_path, get_path_length, put_path, put_path_length); + p = path_build_from_dht (get_path, get_path_length, + put_path, put_path_length); path_add_to_peer (peer_info, p); tunnel_add_peer(t, peer_info); - p = tree_get_path_to_peer(t->tree, peer_info->id); -#if MESH_DEBUG - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "MESH: new route for tunnel 0x%x found, has %u hops\n", - t->local_tid, p->length); - for (i = 0; i < p->length; i++) - { - GNUNET_PEER_resolve (p->peers[0], &id); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH:\t%d\t%s\n", i, - GNUNET_h2s_full (&id.hashPubKey)); - } -#endif - - if (p->length > 1) - { - send_create_path(peer_info, p, t); - return; - } - path_destroy(p); - send_client_peer_connected(t, myid); + peer_info_connect (peer_info, t); } -- 2.25.1