diff options
author | Bart Polot <bart@net.in.tum.de> | 2011-10-24 17:00:00 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2011-10-24 17:00:00 +0000 |
commit | 8df13cbe011501b88c0edd2ecb54e0ce3ae2ff0e (patch) | |
tree | bc2099b4d60e8b422851eceed21e2b150644ff97 | |
parent | 26e8ea09d29f816b7a47797c8c7320ccbad086e9 (diff) | |
download | gnunet-8df13cbe011501b88c0edd2ecb54e0ce3ae2ff0e.tar.gz gnunet-8df13cbe011501b88c0edd2ecb54e0ce3ae2ff0e.zip |
Refactored 'type' DHT response processing
-rw-r--r-- | src/mesh/gnunet-service-mesh.c | 50 |
1 files 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, | |||
2917 | GNUNET_break_op (0); | 2917 | GNUNET_break_op (0); |
2918 | return GNUNET_OK; | 2918 | return GNUNET_OK; |
2919 | } | 2919 | } |
2920 | peer_info = peer_info_get (&msg->peer_id); | 2920 | if (NULL != t->dht_get_type) |
2921 | if (NULL == peer_info) | ||
2922 | { | 2921 | { |
2923 | GNUNET_break_op (0); | 2922 | GNUNET_DHT_get_stop (t->dht_get_type); |
2924 | return GNUNET_OK; | 2923 | t->dht_get_type = NULL; |
2925 | } | 2924 | } |
2925 | peer_info = peer_info_get (&msg->peer_id); | ||
2926 | n = tree_find_peer(t->tree->root, peer_info->id); | 2926 | n = tree_find_peer(t->tree->root, peer_info->id); |
2927 | if (NULL == n) | 2927 | if (NULL == n) |
2928 | { | 2928 | { |
@@ -3147,11 +3147,9 @@ dht_get_type_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
3147 | const void *data) | 3147 | const void *data) |
3148 | { | 3148 | { |
3149 | const struct GNUNET_PeerIdentity *pi = data; | 3149 | const struct GNUNET_PeerIdentity *pi = data; |
3150 | struct GNUNET_PeerIdentity id; | ||
3151 | struct MeshTunnel *t = cls; | 3150 | struct MeshTunnel *t = cls; |
3152 | struct MeshPeerInfo *peer_info; | 3151 | struct MeshPeerInfo *peer_info; |
3153 | struct MeshPeerPath *p; | 3152 | struct MeshPeerPath *p; |
3154 | int i; | ||
3155 | 3153 | ||
3156 | if (size != sizeof (struct GNUNET_PeerIdentity)) | 3154 | if (size != sizeof (struct GNUNET_PeerIdentity)) |
3157 | { | 3155 | { |
@@ -3159,42 +3157,18 @@ dht_get_type_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
3159 | return; | 3157 | return; |
3160 | } | 3158 | } |
3161 | GNUNET_assert (NULL != t->client); | 3159 | GNUNET_assert (NULL != t->client); |
3162 | GNUNET_DHT_get_stop (t->dht_get_type); | ||
3163 | t->dht_get_type = NULL; | ||
3164 | peer_info = peer_info_get (pi); | 3160 | peer_info = peer_info_get (pi); |
3165 | GNUNET_CONTAINER_multihashmap_put (t->peers, &pi->hashPubKey, peer_info, | 3161 | (void) GNUNET_CONTAINER_multihashmap_put ( |
3166 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 3162 | t->peers, |
3167 | 3163 | &pi->hashPubKey, | |
3168 | if ((NULL == get_path || NULL == put_path) && NULL == peer_info->path_head && | 3164 | peer_info, |
3169 | NULL == peer_info->dhtget) | 3165 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); |
3170 | { | ||
3171 | peer_info_connect (peer_info, t); | ||
3172 | return; | ||
3173 | } | ||
3174 | 3166 | ||
3175 | p = path_build_from_dht (get_path, get_path_length, put_path, put_path_length); | 3167 | p = path_build_from_dht (get_path, get_path_length, |
3168 | put_path, put_path_length); | ||
3176 | path_add_to_peer (peer_info, p); | 3169 | path_add_to_peer (peer_info, p); |
3177 | tunnel_add_peer(t, peer_info); | 3170 | tunnel_add_peer(t, peer_info); |
3178 | p = tree_get_path_to_peer(t->tree, peer_info->id); | 3171 | peer_info_connect (peer_info, t); |
3179 | #if MESH_DEBUG | ||
3180 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3181 | "MESH: new route for tunnel 0x%x found, has %u hops\n", | ||
3182 | t->local_tid, p->length); | ||
3183 | for (i = 0; i < p->length; i++) | ||
3184 | { | ||
3185 | GNUNET_PEER_resolve (p->peers[0], &id); | ||
3186 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH:\t%d\t%s\n", i, | ||
3187 | GNUNET_h2s_full (&id.hashPubKey)); | ||
3188 | } | ||
3189 | #endif | ||
3190 | |||
3191 | if (p->length > 1) | ||
3192 | { | ||
3193 | send_create_path(peer_info, p, t); | ||
3194 | return; | ||
3195 | } | ||
3196 | path_destroy(p); | ||
3197 | send_client_peer_connected(t, myid); | ||
3198 | } | 3172 | } |
3199 | 3173 | ||
3200 | 3174 | ||