diff options
author | Bart Polot <bart@net.in.tum.de> | 2011-10-12 07:10:07 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2011-10-12 07:10:07 +0000 |
commit | 93e3a5ea3d6f758e290f0fb24fa613c8c48c8b08 (patch) | |
tree | 8354a3000aa652813443cea37036852c8e7a4203 /src/mesh | |
parent | ac4befb8c44d653f60924a088f5c6ffd671e13f6 (diff) | |
download | gnunet-93e3a5ea3d6f758e290f0fb24fa613c8c48c8b08.tar.gz gnunet-93e3a5ea3d6f758e290f0fb24fa613c8c48c8b08.zip |
Fixed bugs, added debug messages, extended unicast testcase
Diffstat (limited to 'src/mesh')
-rw-r--r-- | src/mesh/gnunet-service-mesh.c | 26 | ||||
-rw-r--r-- | src/mesh/test_mesh_small_unicast.c | 30 |
2 files changed, 42 insertions, 14 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index dfec4157f..026c8b882 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c | |||
@@ -1427,6 +1427,8 @@ tunnel_add_path (struct MeshTunnel *t, | |||
1427 | { | 1427 | { |
1428 | GNUNET_assert (0 != own_pos); | 1428 | GNUNET_assert (0 != own_pos); |
1429 | tree_add_path(t->tree, p, NULL); | 1429 | tree_add_path(t->tree, p, NULL); |
1430 | if (NULL == t->tree->me) | ||
1431 | t->tree->me = tree_find_peer(t->tree->root, p->peers[own_pos]); | ||
1430 | } | 1432 | } |
1431 | 1433 | ||
1432 | 1434 | ||
@@ -2243,10 +2245,14 @@ handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2243 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 2245 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
2244 | { | 2246 | { |
2245 | struct GNUNET_MESH_PathACK *msg; | 2247 | struct GNUNET_MESH_PathACK *msg; |
2248 | struct GNUNET_PeerIdentity id; | ||
2246 | struct MeshTunnelTreeNode *n; | 2249 | struct MeshTunnelTreeNode *n; |
2247 | struct MeshPeerInfo *peer_info; | 2250 | struct MeshPeerInfo *peer_info; |
2248 | struct MeshTunnel *t; | 2251 | struct MeshTunnel *t; |
2249 | 2252 | ||
2253 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2254 | "MESH: Received a path ACK msg [%s]\n", | ||
2255 | GNUNET_i2s(&my_full_id)); | ||
2250 | msg = (struct GNUNET_MESH_PathACK *) message; | 2256 | msg = (struct GNUNET_MESH_PathACK *) message; |
2251 | t = tunnel_get (&msg->oid, msg->tid); | 2257 | t = tunnel_get (&msg->oid, msg->tid); |
2252 | if (NULL == t) | 2258 | if (NULL == t) |
@@ -2258,6 +2264,8 @@ handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2258 | /* Message for us? */ | 2264 | /* Message for us? */ |
2259 | if (0 == memcmp (&msg->oid, &my_full_id, sizeof (struct GNUNET_PeerIdentity))) | 2265 | if (0 == memcmp (&msg->oid, &my_full_id, sizeof (struct GNUNET_PeerIdentity))) |
2260 | { | 2266 | { |
2267 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2268 | "MESH: It's for us!\n"); | ||
2261 | if (NULL == t->client) | 2269 | if (NULL == t->client) |
2262 | { | 2270 | { |
2263 | GNUNET_break_op (0); | 2271 | GNUNET_break_op (0); |
@@ -2279,7 +2287,10 @@ handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2279 | send_client_peer_connected(t, peer_info->id); | 2287 | send_client_peer_connected(t, peer_info->id); |
2280 | return GNUNET_OK; | 2288 | return GNUNET_OK; |
2281 | } | 2289 | } |
2282 | 2290 | ||
2291 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2292 | "MESH: not for us, retransmitting...\n"); | ||
2293 | GNUNET_PEER_resolve(t->tree->me->parent->peer, &id); | ||
2283 | peer_info = peer_info_get (&msg->oid); | 2294 | peer_info = peer_info_get (&msg->oid); |
2284 | if (NULL == peer_info) | 2295 | if (NULL == peer_info) |
2285 | { | 2296 | { |
@@ -2291,8 +2302,7 @@ handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2291 | memcpy (msg, message, sizeof (struct GNUNET_MESH_PathACK)); | 2302 | memcpy (msg, message, sizeof (struct GNUNET_MESH_PathACK)); |
2292 | GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, | 2303 | GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, |
2293 | GNUNET_TIME_UNIT_FOREVER_REL, | 2304 | GNUNET_TIME_UNIT_FOREVER_REL, |
2294 | path_get_first_hop (t->tree, | 2305 | &id, |
2295 | peer_info->id), | ||
2296 | sizeof (struct GNUNET_MESH_PathACK), | 2306 | sizeof (struct GNUNET_MESH_PathACK), |
2297 | &send_core_data_raw, msg); | 2307 | &send_core_data_raw, msg); |
2298 | return GNUNET_OK; | 2308 | return GNUNET_OK; |
@@ -3303,20 +3313,26 @@ core_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3303 | struct MeshPeerInfo *peer_info; | 3313 | struct MeshPeerInfo *peer_info; |
3304 | struct MeshPeerPath *path; | 3314 | struct MeshPeerPath *path; |
3305 | 3315 | ||
3316 | #if MESH_DEBUG_CONNECTION | ||
3306 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Peer connected\n"); | 3317 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Peer connected\n"); |
3307 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: %s\n", | 3318 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: %s\n", |
3308 | GNUNET_h2s(&my_full_id.hashPubKey)); | 3319 | GNUNET_h2s(&my_full_id.hashPubKey)); |
3320 | #endif | ||
3309 | peer_info = peer_info_get (peer); | 3321 | peer_info = peer_info_get (peer); |
3310 | if (myid == peer_info->id) | 3322 | if (myid == peer_info->id) |
3311 | { | 3323 | { |
3324 | #if MESH_DEBUG_CONNECTION | ||
3312 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: (self)\n"); | 3325 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: (self)\n"); |
3326 | #endif | ||
3313 | return; | 3327 | return; |
3314 | } | 3328 | } |
3329 | #if MESH_DEBUG_CONNECTION | ||
3315 | else | 3330 | else |
3316 | { | 3331 | { |
3317 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: %s\n", | 3332 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: %s\n", |
3318 | GNUNET_h2s(&peer->hashPubKey)); | 3333 | GNUNET_h2s(&peer->hashPubKey)); |
3319 | } | 3334 | } |
3335 | #endif | ||
3320 | path = path_new (2); | 3336 | path = path_new (2); |
3321 | path->peers[0] = myid; | 3337 | path->peers[0] = myid; |
3322 | path->peers[1] = peer_info->id; | 3338 | path->peers[1] = peer_info->id; |
@@ -3338,7 +3354,9 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
3338 | struct MeshPeerInfo *pi; | 3354 | struct MeshPeerInfo *pi; |
3339 | unsigned int i; | 3355 | unsigned int i; |
3340 | 3356 | ||
3357 | #if MESH_DEBUG_CONNECTION | ||
3341 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Peer disconnected\n"); | 3358 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Peer disconnected\n"); |
3359 | #endif | ||
3342 | pi = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); | 3360 | pi = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); |
3343 | if (NULL == pi) | 3361 | if (NULL == pi) |
3344 | { | 3362 | { |
@@ -3350,10 +3368,12 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
3350 | peer_info_cancel_transmission(pi, i); | 3368 | peer_info_cancel_transmission(pi, i); |
3351 | } | 3369 | } |
3352 | path_remove_from_peer (pi, pi->id, myid); | 3370 | path_remove_from_peer (pi, pi->id, myid); |
3371 | #if MESH_DEBUG_CONNECTION | ||
3353 | if (myid == pi->id) | 3372 | if (myid == pi->id) |
3354 | { | 3373 | { |
3355 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: (self)\n"); | 3374 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: (self)\n"); |
3356 | } | 3375 | } |
3376 | #endif | ||
3357 | return; | 3377 | return; |
3358 | } | 3378 | } |
3359 | 3379 | ||
diff --git a/src/mesh/test_mesh_small_unicast.c b/src/mesh/test_mesh_small_unicast.c index 871aa0c25..5660dc0b0 100644 --- a/src/mesh/test_mesh_small_unicast.c +++ b/src/mesh/test_mesh_small_unicast.c | |||
@@ -47,15 +47,18 @@ struct StatsContext | |||
47 | }; | 47 | }; |
48 | 48 | ||
49 | 49 | ||
50 | // static struct MeshPeer *peer_head; | ||
51 | // | ||
52 | // static struct MeshPeer *peer_tail; | ||
53 | |||
54 | /** | 50 | /** |
55 | * How long until we give up on connecting the peers? | 51 | * How long until we give up on connecting the peers? |
56 | */ | 52 | */ |
57 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1500) | 53 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1500) |
58 | 54 | ||
55 | /** | ||
56 | * Time to wait for stuff that should be rather fast | ||
57 | */ | ||
58 | #define SHORT_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) | ||
59 | |||
60 | #define OK_GOAL 2 | ||
61 | |||
59 | static int ok; | 62 | static int ok; |
60 | 63 | ||
61 | /** | 64 | /** |
@@ -147,7 +150,7 @@ shutdown_callback (void *cls, const char *emsg) | |||
147 | #if VERBOSE | 150 | #if VERBOSE |
148 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Shutdown of peers failed!\n"); | 151 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Shutdown of peers failed!\n"); |
149 | #endif | 152 | #endif |
150 | ok++; | 153 | ok--; |
151 | } | 154 | } |
152 | else | 155 | else |
153 | { | 156 | { |
@@ -220,9 +223,11 @@ incoming_tunnel (void *cls, | |||
220 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 223 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
221 | "test: Incoming tunnel from %s\n", | 224 | "test: Incoming tunnel from %s\n", |
222 | GNUNET_i2s(initiator)); | 225 | GNUNET_i2s(initiator)); |
226 | ok++; | ||
223 | GNUNET_SCHEDULER_cancel (disconnect_task); | 227 | GNUNET_SCHEDULER_cancel (disconnect_task); |
224 | disconnect_task = GNUNET_SCHEDULER_add_now(&disconnect_mesh_peers, NULL); | 228 | disconnect_task = GNUNET_SCHEDULER_add_delayed(SHORT_TIME, |
225 | ok = 0; | 229 | &disconnect_mesh_peers, |
230 | NULL); | ||
226 | return NULL; | 231 | return NULL; |
227 | } | 232 | } |
228 | 233 | ||
@@ -258,6 +263,8 @@ dh (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
258 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 263 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
259 | "test: peer %s disconnected\n", | 264 | "test: peer %s disconnected\n", |
260 | GNUNET_i2s(peer)); | 265 | GNUNET_i2s(peer)); |
266 | if (memcmp(&d2->id, peer, sizeof(d2->id))) | ||
267 | ok++; | ||
261 | return; | 268 | return; |
262 | } | 269 | } |
263 | 270 | ||
@@ -428,7 +435,7 @@ peergroup_ready (void *cls, const char *emsg) | |||
428 | "test: Peergroup callback called with error, aborting test!\n"); | 435 | "test: Peergroup callback called with error, aborting test!\n"); |
429 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 436 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
430 | "test: Error from testing: `%s'\n", emsg); | 437 | "test: Error from testing: `%s'\n", emsg); |
431 | ok++; | 438 | ok--; |
432 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); | 439 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); |
433 | return; | 440 | return; |
434 | } | 441 | } |
@@ -529,7 +536,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
529 | unsigned long long temp_wait; | 536 | unsigned long long temp_wait; |
530 | struct GNUNET_TESTING_Host *hosts; | 537 | struct GNUNET_TESTING_Host *hosts; |
531 | 538 | ||
532 | ok = 1; | 539 | ok = 0; |
533 | testing_cfg = GNUNET_CONFIGURATION_dup (cfg); | 540 | testing_cfg = GNUNET_CONFIGURATION_dup (cfg); |
534 | 541 | ||
535 | GNUNET_log_setup ("test_mesh_small_unicast", | 542 | GNUNET_log_setup ("test_mesh_small_unicast", |
@@ -662,11 +669,12 @@ main (int argc, char *argv[]) | |||
662 | #if REMOVE_DIR | 669 | #if REMOVE_DIR |
663 | GNUNET_DISK_directory_remove ("/tmp/test_mesh_small_unicast"); | 670 | GNUNET_DISK_directory_remove ("/tmp/test_mesh_small_unicast"); |
664 | #endif | 671 | #endif |
665 | if (0 != ok) | 672 | if (OK_GOAL != ok) |
666 | { | 673 | { |
667 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "test: FAILED!\n"); | 674 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "test: FAILED!\n"); |
675 | return 1; | ||
668 | } | 676 | } |
669 | return ok; | 677 | return 0; |
670 | } | 678 | } |
671 | 679 | ||
672 | /* end of test_mesh_small_unicast.c */ | 680 | /* end of test_mesh_small_unicast.c */ |