From: Bart Polot Date: Wed, 12 Oct 2011 07:10:07 +0000 (+0000) Subject: Fixed bugs, added debug messages, extended unicast testcase X-Git-Tag: initial-import-from-subversion-38251~16603 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=93e3a5ea3d6f758e290f0fb24fa613c8c48c8b08;p=oweals%2Fgnunet.git Fixed bugs, added debug messages, extended unicast testcase --- 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, { GNUNET_assert (0 != own_pos); tree_add_path(t->tree, p, NULL); + if (NULL == t->tree->me) + t->tree->me = tree_find_peer(t->tree->root, p->peers[own_pos]); } @@ -2243,10 +2245,14 @@ handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { struct GNUNET_MESH_PathACK *msg; + struct GNUNET_PeerIdentity id; struct MeshTunnelTreeNode *n; struct MeshPeerInfo *peer_info; struct MeshTunnel *t; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "MESH: Received a path ACK msg [%s]\n", + GNUNET_i2s(&my_full_id)); msg = (struct GNUNET_MESH_PathACK *) message; t = tunnel_get (&msg->oid, msg->tid); if (NULL == t) @@ -2258,6 +2264,8 @@ handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer, /* Message for us? */ if (0 == memcmp (&msg->oid, &my_full_id, sizeof (struct GNUNET_PeerIdentity))) { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "MESH: It's for us!\n"); if (NULL == t->client) { GNUNET_break_op (0); @@ -2279,7 +2287,10 @@ handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer, send_client_peer_connected(t, peer_info->id); return GNUNET_OK; } - + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "MESH: not for us, retransmitting...\n"); + GNUNET_PEER_resolve(t->tree->me->parent->peer, &id); peer_info = peer_info_get (&msg->oid); if (NULL == peer_info) { @@ -2291,8 +2302,7 @@ handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer, memcpy (msg, message, sizeof (struct GNUNET_MESH_PathACK)); GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, GNUNET_TIME_UNIT_FOREVER_REL, - path_get_first_hop (t->tree, - peer_info->id), + &id, sizeof (struct GNUNET_MESH_PathACK), &send_core_data_raw, msg); return GNUNET_OK; @@ -3303,20 +3313,26 @@ core_connect (void *cls, const struct GNUNET_PeerIdentity *peer, struct MeshPeerInfo *peer_info; struct MeshPeerPath *path; +#if MESH_DEBUG_CONNECTION GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Peer connected\n"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: %s\n", GNUNET_h2s(&my_full_id.hashPubKey)); +#endif peer_info = peer_info_get (peer); if (myid == peer_info->id) { +#if MESH_DEBUG_CONNECTION GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: (self)\n"); +#endif return; } +#if MESH_DEBUG_CONNECTION else { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: %s\n", GNUNET_h2s(&peer->hashPubKey)); } +#endif path = path_new (2); path->peers[0] = myid; path->peers[1] = peer_info->id; @@ -3338,7 +3354,9 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) struct MeshPeerInfo *pi; unsigned int i; +#if MESH_DEBUG_CONNECTION GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Peer disconnected\n"); +#endif pi = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); if (NULL == pi) { @@ -3350,10 +3368,12 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) peer_info_cancel_transmission(pi, i); } path_remove_from_peer (pi, pi->id, myid); +#if MESH_DEBUG_CONNECTION if (myid == pi->id) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: (self)\n"); } +#endif return; } 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 }; -// static struct MeshPeer *peer_head; -// -// static struct MeshPeer *peer_tail; - /** * How long until we give up on connecting the peers? */ #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1500) +/** + * Time to wait for stuff that should be rather fast + */ +#define SHORT_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) + +#define OK_GOAL 2 + static int ok; /** @@ -147,7 +150,7 @@ shutdown_callback (void *cls, const char *emsg) #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Shutdown of peers failed!\n"); #endif - ok++; + ok--; } else { @@ -220,9 +223,11 @@ incoming_tunnel (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Incoming tunnel from %s\n", GNUNET_i2s(initiator)); + ok++; GNUNET_SCHEDULER_cancel (disconnect_task); - disconnect_task = GNUNET_SCHEDULER_add_now(&disconnect_mesh_peers, NULL); - ok = 0; + disconnect_task = GNUNET_SCHEDULER_add_delayed(SHORT_TIME, + &disconnect_mesh_peers, + NULL); return NULL; } @@ -258,6 +263,8 @@ dh (void *cls, const struct GNUNET_PeerIdentity *peer) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: peer %s disconnected\n", GNUNET_i2s(peer)); + if (memcmp(&d2->id, peer, sizeof(d2->id))) + ok++; return; } @@ -428,7 +435,7 @@ peergroup_ready (void *cls, const char *emsg) "test: Peergroup callback called with error, aborting test!\n"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Error from testing: `%s'\n", emsg); - ok++; + ok--; GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); return; } @@ -529,7 +536,7 @@ run (void *cls, char *const *args, const char *cfgfile, unsigned long long temp_wait; struct GNUNET_TESTING_Host *hosts; - ok = 1; + ok = 0; testing_cfg = GNUNET_CONFIGURATION_dup (cfg); GNUNET_log_setup ("test_mesh_small_unicast", @@ -662,11 +669,12 @@ main (int argc, char *argv[]) #if REMOVE_DIR GNUNET_DISK_directory_remove ("/tmp/test_mesh_small_unicast"); #endif - if (0 != ok) + if (OK_GOAL != ok) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "test: FAILED!\n"); + return 1; } - return ok; + return 0; } /* end of test_mesh_small_unicast.c */