aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/gnunet-service-mesh.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-07-16 12:54:25 +0000
committerBart Polot <bart@net.in.tum.de>2013-07-16 12:54:25 +0000
commit5b3b6d8650d775ee0cd6c1bc22c76b0b7863ef61 (patch)
tree15bf825992343491e2baa36fd60e4c48701c16bd /src/mesh/gnunet-service-mesh.c
parent11ffc0a8c052bbf695826336b4c85488ab9c9dad (diff)
downloadgnunet-5b3b6d8650d775ee0cd6c1bc22c76b0b7863ef61.tar.gz
gnunet-5b3b6d8650d775ee0cd6c1bc22c76b0b7863ef61.zip
- make send_client_destroy generic and same-client-friendly
Diffstat (limited to 'src/mesh/gnunet-service-mesh.c')
-rw-r--r--src/mesh/gnunet-service-mesh.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index a03308fb8..a60793c7f 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -1045,27 +1045,24 @@ send_client_tunnel_create (struct MeshTunnel *t)
1045/** 1045/**
1046 * Notify dest client that the incoming tunnel is no longer valid. 1046 * Notify dest client that the incoming tunnel is no longer valid.
1047 * 1047 *
1048 * @param c Client to notify..
1049 * @param t Tunnel that is destroyed. 1048 * @param t Tunnel that is destroyed.
1049 * @param fwd Forward notification (owner->dest)?
1050 */ 1050 */
1051static void 1051static void
1052send_client_tunnel_destroy (struct MeshClient *c, struct MeshTunnel *t) 1052send_client_tunnel_destroy (struct MeshTunnel *t, int fwd)
1053{ 1053{
1054 struct GNUNET_MESH_TunnelMessage msg; 1054 struct GNUNET_MESH_TunnelMessage msg;
1055 struct MeshClient *c;
1055 1056
1057 c = fwd ? t->client : t->owner;
1056 if (NULL == c) 1058 if (NULL == c)
1057 { 1059 {
1058 GNUNET_break (0); 1060 GNUNET_break (0);
1059 return; 1061 return;
1060 } 1062 }
1061 if (c != t->client && c != t->owner)
1062 {
1063 GNUNET_break (0);
1064 return;
1065 }
1066 msg.header.size = htons (sizeof (msg)); 1063 msg.header.size = htons (sizeof (msg));
1067 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY); 1064 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY);
1068 msg.tunnel_id = htonl (t->local_tid_dest); 1065 msg.tunnel_id = htonl (fwd ? t->local_tid_dest : t->local_tid);
1069 msg.port = htonl (0); 1066 msg.port = htonl (0);
1070 memset (&msg.peer, 0, sizeof (msg.peer)); 1067 memset (&msg.peer, 0, sizeof (msg.peer));
1071 msg.opt = htonl (0); 1068 msg.opt = htonl (0);
@@ -2661,11 +2658,11 @@ tunnel_send_destroy (struct MeshTunnel *t)
2661 } 2658 }
2662 if (NULL != t->owner) 2659 if (NULL != t->owner)
2663 { 2660 {
2664 send_client_tunnel_destroy (t->owner, t); 2661 send_client_tunnel_destroy (t, GNUNET_NO);
2665 } 2662 }
2666 if (NULL != t->client) 2663 if (NULL != t->client)
2667 { 2664 {
2668 send_client_tunnel_destroy (t->client, t); 2665 send_client_tunnel_destroy (t, GNUNET_YES);
2669 } 2666 }
2670} 2667}
2671 2668
@@ -3010,7 +3007,7 @@ tunnel_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3010 "Tunnel %s [%X] timed out. Destroying.\n", 3007 "Tunnel %s [%X] timed out. Destroying.\n",
3011 GNUNET_i2s(&id), t->id.tid); 3008 GNUNET_i2s(&id), t->id.tid);
3012 if (NULL != t->client) 3009 if (NULL != t->client)
3013 send_client_tunnel_destroy (t->client, t); 3010 send_client_tunnel_destroy (t, GNUNET_YES);
3014 tunnel_destroy (t); /* Do not notify other */ 3011 tunnel_destroy (t); /* Do not notify other */
3015} 3012}
3016 3013