aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2012-12-21 02:00:18 +0000
committerBart Polot <bart@net.in.tum.de>2012-12-21 02:00:18 +0000
commit2681bd7b9af783970e4a57f07f2661a9b9606255 (patch)
tree48491e357926d1fc0df25ac01c12eea09cdea1b7 /src/mesh
parent696f4160105f3b69f2afd17bd1796df1681095cb (diff)
downloadgnunet-2681bd7b9af783970e4a57f07f2661a9b9606255.tar.gz
gnunet-2681bd7b9af783970e4a57f07f2661a9b9606255.zip
- cache node parent to retransmit tunnel_destroy in case of pure relay node
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-service-mesh.c46
1 files changed, 30 insertions, 16 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index 30d091352..06cdb241c 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -4395,29 +4395,37 @@ tunnel_unlock_bck_queue (struct MeshTunnel *t)
4395 * valid. 4395 * valid.
4396 * 4396 *
4397 * @param t The tunnel whose peers to notify. 4397 * @param t The tunnel whose peers to notify.
4398 * @param send_back Do we need to notify our parent node? 4398 * @param parent ID of the parent, in case the tree is already destroyed.
4399 */ 4399 */
4400static void 4400static void
4401tunnel_send_destroy (struct MeshTunnel *t, int send_back) 4401tunnel_send_destroy (struct MeshTunnel *t, GNUNET_PEER_Id parent)
4402{ 4402{
4403 struct GNUNET_MESH_TunnelDestroy msg; 4403 struct GNUNET_MESH_TunnelDestroy msg;
4404 struct GNUNET_PeerIdentity id; 4404 struct GNUNET_PeerIdentity id;
4405 GNUNET_PEER_Id parent;
4406 4405
4407 msg.header.size = htons (sizeof (msg)); 4406 msg.header.size = htons (sizeof (msg));
4408 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY); 4407 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY);
4409 GNUNET_PEER_resolve (t->id.oid, &msg.oid); 4408 GNUNET_PEER_resolve (t->id.oid, &msg.oid);
4410 msg.tid = htonl (t->id.tid); 4409 msg.tid = htonl (t->id.tid);
4410 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4411 " sending tunnel destroy for tunnel: %s [%X]\n",
4412 GNUNET_i2s (&msg.oid), t->id.tid);
4411 if (tree_count_children(t->tree) > 0) 4413 if (tree_count_children(t->tree) > 0)
4412 { 4414 {
4415 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " sending multicast to children\n");
4413 tunnel_send_multicast (t, &msg.header); 4416 tunnel_send_multicast (t, &msg.header);
4414 } 4417 }
4415 parent = tree_get_predecessor(t->tree); 4418 if (0 == parent)
4416 if (GNUNET_NO == send_back || 0 == parent) 4419 parent = tree_get_predecessor (t->tree);
4420 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " parent: %u\n", parent);
4421 if (0 == parent)
4417 return; 4422 return;
4418 4423
4419 GNUNET_PEER_resolve (parent, &id); 4424 GNUNET_PEER_resolve (parent, &id);
4420 send_prebuilt_message(&msg.header, &id, t); 4425 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4426 " sending back to %s\n",
4427 GNUNET_i2s (&id));
4428 send_prebuilt_message (&msg.header, &id, t);
4421} 4429}
4422 4430
4423 4431
@@ -4599,7 +4607,7 @@ tunnel_destroy_empty_delayed (void *cls,
4599 } 4607 }
4600 #endif 4608 #endif
4601 4609
4602 tunnel_send_destroy (t, GNUNET_YES); 4610 tunnel_send_destroy (t, 0);
4603 if (0 == t->pending_messages) 4611 if (0 == t->pending_messages)
4604 tunnel_destroy (t); 4612 tunnel_destroy (t);
4605 else 4613 else
@@ -4779,7 +4787,7 @@ tunnel_destroy_iterator (void *cls,
4779 tunnel_destroy_empty (t); 4787 tunnel_destroy_empty (t);
4780 return GNUNET_OK; 4788 return GNUNET_OK;
4781 } 4789 }
4782 tunnel_send_destroy (t, GNUNET_YES); 4790 tunnel_send_destroy (t, 0);
4783 t->owner = NULL; 4791 t->owner = NULL;
4784 t->destroy = GNUNET_YES; 4792 t->destroy = GNUNET_YES;
4785 4793
@@ -5846,11 +5854,17 @@ handle_mesh_tunnel_destroy (void *cls, const struct GNUNET_PeerIdentity *peer,
5846 pid = GNUNET_PEER_search (peer); 5854 pid = GNUNET_PEER_search (peer);
5847 if (pid != parent) 5855 if (pid != parent)
5848 { 5856 {
5857 unsigned int nc;
5858
5849 tree_del_peer (t->tree, pid, &tunnel_child_removed, t); 5859 tree_del_peer (t->tree, pid, &tunnel_child_removed, t);
5850 if (tree_count_children(t->tree) > 0 || 5860 nc = tree_count_children(t->tree);
5851 NULL != t->owner || 5861 if (nc > 0 || NULL != t->owner || t->nclients > 0)
5852 t->nclients > 0) 5862 {
5863 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
5864 "still in use: %u cl, %u ch\n",
5865 t->nclients, nc);
5853 return GNUNET_OK; 5866 return GNUNET_OK;
5867 }
5854 } 5868 }
5855 if (t->local_tid_dest >= GNUNET_MESH_LOCAL_TUNNEL_ID_SERV) 5869 if (t->local_tid_dest >= GNUNET_MESH_LOCAL_TUNNEL_ID_SERV)
5856 { 5870 {
@@ -5859,7 +5873,7 @@ handle_mesh_tunnel_destroy (void *cls, const struct GNUNET_PeerIdentity *peer,
5859 t->local_tid, t->local_tid_dest); 5873 t->local_tid, t->local_tid_dest);
5860 send_clients_tunnel_destroy (t); 5874 send_clients_tunnel_destroy (t);
5861 } 5875 }
5862 tunnel_send_destroy (t, GNUNET_YES); 5876 tunnel_send_destroy (t, parent);
5863 t->destroy = GNUNET_YES; 5877 t->destroy = GNUNET_YES;
5864 // TODO: add timeout to destroy the tunnel anyway 5878 // TODO: add timeout to destroy the tunnel anyway
5865 return GNUNET_OK; 5879 return GNUNET_OK;
@@ -7242,14 +7256,14 @@ handle_local_tunnel_destroy (void *cls, struct GNUNET_SERVER_Client *client,
7242 GNUNET_SERVER_receive_done (client, GNUNET_OK); 7256 GNUNET_SERVER_receive_done (client, GNUNET_OK);
7243 return; 7257 return;
7244 } 7258 }
7245 send_client_tunnel_disconnect(t, c); 7259 send_client_tunnel_disconnect (t, c);
7246 client_delete_tunnel(c, t); 7260 client_delete_tunnel (c, t);
7247 7261
7248 /* Don't try to ACK the client about the tunnel_destroy multicast packet */ 7262 /* Don't try to ACK the client about the tunnel_destroy multicast packet */
7249 t->owner = NULL; 7263 t->owner = NULL;
7250 tunnel_send_destroy (t, GNUNET_YES); 7264 tunnel_send_destroy (t, 0);
7251 t->destroy = GNUNET_YES; 7265 t->destroy = GNUNET_YES;
7252 // The tunnel will be destroyed when the last message is transmitted. 7266 /* The tunnel will be destroyed when the last message is transmitted. */
7253 GNUNET_SERVER_receive_done (client, GNUNET_OK); 7267 GNUNET_SERVER_receive_done (client, GNUNET_OK);
7254 return; 7268 return;
7255} 7269}