aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-10-20 12:49:52 +0000
committerBart Polot <bart@net.in.tum.de>2011-10-20 12:49:52 +0000
commit1a2b9898a2c18e10c587072d7a10ac48fc8e956c (patch)
treee85c56380657e2ff8387af1865fea03efda7be37 /src/mesh
parentd1e4d9e7667b952bdd88cbb3f4f05e3698c31323 (diff)
downloadgnunet-1a2b9898a2c18e10c587072d7a10ac48fc8e956c.tar.gz
gnunet-1a2b9898a2c18e10c587072d7a10ac48fc8e956c.zip
Fixed bugs in tunnel destruction chain
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-service-mesh.c42
-rw-r--r--src/mesh/mesh_api_new.c1
2 files changed, 40 insertions, 3 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index cb7602b90..3108d9149 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -787,6 +787,7 @@ send_subscribed_clients (const struct GNUNET_MessageHeader *msg,
787 787
788/** 788/**
789 * Notify the client that owns the tunnel that a peer has connected to it 789 * Notify the client that owns the tunnel that a peer has connected to it
790 * (the requested path to it has been confirmed).
790 * 791 *
791 * @param t Tunnel whose owner to notify 792 * @param t Tunnel whose owner to notify
792 * @param id Short id of the peer that has connected 793 * @param id Short id of the peer that has connected
@@ -806,6 +807,24 @@ send_client_peer_connected (const struct MeshTunnel *t, const GNUNET_PEER_Id id)
806 807
807 808
808/** 809/**
810 * Notify all clients (not depending on registration status) that the incoming
811 * tunnel is no longer valid.
812 *
813 * @param t Tunnel that was destroyed.
814 */
815static void
816send_clients_tunnel_destroy (struct MeshTunnel *t)
817{
818 struct GNUNET_MESH_TunnelMessage msg;
819
820 msg.header.size = htons (sizeof (msg));
821 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY);
822 msg.tunnel_id = htonl (t->local_tid);
823 GNUNET_SERVER_notification_context_broadcast(nc, &msg.header, GNUNET_NO);
824}
825
826
827/**
809 * Function called to notify a client about the socket 828 * Function called to notify a client about the socket
810 * being ready to queue more data. "buf" will be 829 * being ready to queue more data. "buf" will be
811 * NULL and "size" zero if the socket was closed for 830 * NULL and "size" zero if the socket was closed for
@@ -1777,7 +1796,11 @@ tunnel_send_multicast (struct MeshTunnel *t,
1777 GNUNET_assert (NULL != t->tree->me); 1796 GNUNET_assert (NULL != t->tree->me);
1778 n = t->tree->me->children_head; 1797 n = t->tree->me->children_head;
1779 if (NULL == n) 1798 if (NULL == n)
1799 {
1800 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1801 "MESH: no children in the tree, no one to send.\n");
1780 return 0; 1802 return 0;
1803 }
1781 copies = GNUNET_malloc (sizeof (unsigned int)); 1804 copies = GNUNET_malloc (sizeof (unsigned int));
1782 for (*copies = 0; NULL != n; n = n->next) 1805 for (*copies = 0; NULL != n; n = n->next)
1783 (*copies)++; 1806 (*copies)++;
@@ -1836,7 +1859,7 @@ tunnel_send_destroy (struct MeshTunnel *t)
1836 1859
1837 msg.header.size = htons (sizeof (msg)); 1860 msg.header.size = htons (sizeof (msg));
1838 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY); 1861 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY);
1839 msg.oid = my_full_id; 1862 GNUNET_PEER_resolve (t->id.oid, &msg.oid);
1840 msg.tid = htonl (t->id.tid); 1863 msg.tid = htonl (t->id.tid);
1841 tunnel_send_multicast (t, &msg.header); 1864 tunnel_send_multicast (t, &msg.header);
1842} 1865}
@@ -2558,6 +2581,10 @@ handle_mesh_tunnel_destroy (void *cls, const struct GNUNET_PeerIdentity *peer,
2558 "MESH: Got a TUNNEL DESTROY packet from %s\n", 2581 "MESH: Got a TUNNEL DESTROY packet from %s\n",
2559 GNUNET_i2s (peer)); 2582 GNUNET_i2s (peer));
2560 msg = (struct GNUNET_MESH_TunnelDestroy *) message; 2583 msg = (struct GNUNET_MESH_TunnelDestroy *) message;
2584 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2585 "MESH: for tunnel %s [%u]\n",
2586 GNUNET_i2s (&msg->oid),
2587 ntohl (msg->tid));
2561 t = tunnel_get (&msg->oid, ntohl (msg->tid)); 2588 t = tunnel_get (&msg->oid, ntohl (msg->tid));
2562 if (NULL == t) 2589 if (NULL == t)
2563 { 2590 {
@@ -2565,6 +2592,16 @@ handle_mesh_tunnel_destroy (void *cls, const struct GNUNET_PeerIdentity *peer,
2565 GNUNET_break_op (0); 2592 GNUNET_break_op (0);
2566 return GNUNET_OK; 2593 return GNUNET_OK;
2567 } 2594 }
2595 if (t->id.oid == myid)
2596 {
2597 GNUNET_break_op (0);
2598 return GNUNET_OK;
2599 }
2600 if (t->local_tid >= GNUNET_MESH_LOCAL_TUNNEL_ID_SERV)
2601 {
2602 /* Tunnel was incoming, notify clients */
2603 send_clients_tunnel_destroy (t);
2604 }
2568 tunnel_send_destroy (t); 2605 tunnel_send_destroy (t);
2569 tunnel_destroy (t); 2606 tunnel_destroy (t);
2570 return GNUNET_OK; 2607 return GNUNET_OK;
@@ -3376,7 +3413,8 @@ handle_local_tunnel_destroy (void *cls, struct GNUNET_SERVER_Client *client,
3376 MESH_TunnelNumber tid; 3413 MESH_TunnelNumber tid;
3377 GNUNET_HashCode hash; 3414 GNUNET_HashCode hash;
3378 3415
3379 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: destroying tunnel\n"); 3416 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3417 "MESH: Got a DESTROY TUNNEL from client!\n");
3380 3418
3381 /* Sanity check for client registration */ 3419 /* Sanity check for client registration */
3382 if (NULL == (c = client_get (client))) 3420 if (NULL == (c = client_get (client)))
diff --git a/src/mesh/mesh_api_new.c b/src/mesh/mesh_api_new.c
index df5461080..81933e858 100644
--- a/src/mesh/mesh_api_new.c
+++ b/src/mesh/mesh_api_new.c
@@ -796,7 +796,6 @@ process_tunnel_destroy (struct GNUNET_MESH_Handle *h,
796 796
797 if (NULL == t) 797 if (NULL == t)
798 { 798 {
799 GNUNET_break (0);
800 return; 799 return;
801 } 800 }
802 if (0 == t->owner) 801 if (0 == t->owner)