From: Bart Polot Date: Tue, 15 Oct 2013 14:20:46 +0000 (+0000) Subject: - fix new connection handler X-Git-Tag: initial-import-from-subversion-38251~6528 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5f09226e9088614acbf3e915d8bd63afac46e464;p=oweals%2Fgnunet.git - fix new connection handler --- diff --git a/src/mesh/gnunet-service-mesh_connection.c b/src/mesh/gnunet-service-mesh_connection.c index a47a3b835..5ca287cb1 100644 --- a/src/mesh/gnunet-service-mesh_connection.c +++ b/src/mesh/gnunet-service-mesh_connection.c @@ -929,6 +929,23 @@ unregister_neighbors (struct MeshConnection *c) } +/** + * Bind the connection to the peer and the tunnel to that peer. + * + * If the peer has no tunnel, create one. Update tunnel and connection + * data structres to reflect new status. + * + * @param c Connection. + * @param peer Peer. + */ +static void +add_to_peer (struct MeshConnection *c, struct MeshPeer *peer) +{ + GMP_add_tunnel (peer); + c->t = GMP_get_tunnel (peer); + GMT_add_connection (c->t, c); +} + /******************************************************************************/ /******************************** API ***********************************/ /******************************************************************************/ @@ -1040,8 +1057,7 @@ GMC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer, LOG (GNUNET_ERROR_TYPE_DEBUG, " It's for us!\n"); GMP_add_path_to_origin (orig_peer, path, GNUNET_YES); - GMP_add_tunnel (orig_peer); - GMP_add_connection (orig_peer, c); + add_to_peer (c, orig_peer); if (MESH_TUNNEL3_NEW == GMT_get_state (c->t)) GMT_change_state (c->t, MESH_TUNNEL3_WAITING); diff --git a/src/mesh/gnunet-service-mesh_peer.c b/src/mesh/gnunet-service-mesh_peer.c index 0127615c1..ff0d43813 100644 --- a/src/mesh/gnunet-service-mesh_peer.c +++ b/src/mesh/gnunet-service-mesh_peer.c @@ -1390,6 +1390,7 @@ GMP_is_neighbor (const struct MeshPeer *peer) /** * Create and initialize a new tunnel towards a peer, in case it has none. + * In case the peer already has a tunnel, nothing is done. * * Does not generate any traffic, just creates the local data structures. *