- Fixed bugs of incoming data for tunnels without handlers, passing along free'd...
authorBart Polot <bart@net.in.tum.de>
Wed, 18 Apr 2012 17:34:55 +0000 (17:34 +0000)
committerBart Polot <bart@net.in.tum.de>
Wed, 18 Apr 2012 17:34:55 +0000 (17:34 +0000)
src/mesh/mesh_api.c

index 7b9aa06b13617cd2bae952969e320eb76c309017..c8d2162bc6fb766590f3cda3ce41ccf1160260c5 100644 (file)
@@ -805,26 +805,38 @@ process_tunnel_created (struct GNUNET_MESH_Handle *h,
     GNUNET_break (0);
     return;
   }
-  t = create_tunnel (h, tid);
-  t->owner = GNUNET_PEER_intern (&msg->peer);
-  t->npeers = 1;
-  t->peers = GNUNET_malloc (sizeof (struct GNUNET_MESH_Peer *));
-  t->peers[0] = GNUNET_malloc (sizeof (struct GNUNET_MESH_Peer));
-  t->peers[0]->t = t;
-  t->peers[0]->connected = 1;
-  t->peers[0]->id = t->owner;
-  GNUNET_PEER_change_rc (t->owner, 1);
-  t->mesh = h;
-  t->tid = tid;
   if (NULL != h->new_tunnel)
   {
     struct GNUNET_ATS_Information atsi;
 
+    t = create_tunnel (h, tid);
+    t->owner = GNUNET_PEER_intern (&msg->peer);
+    t->npeers = 1;
+    t->peers = GNUNET_malloc (sizeof (struct GNUNET_MESH_Peer *));
+    t->peers[0] = GNUNET_malloc (sizeof (struct GNUNET_MESH_Peer));
+    t->peers[0]->t = t;
+    t->peers[0]->connected = 1;
+    t->peers[0]->id = t->owner;
+    GNUNET_PEER_change_rc (t->owner, 1);
+    t->mesh = h;
+    t->tid = tid;
     atsi.type = 0;
     atsi.value = 0;
     t->ctx = h->new_tunnel (h->cls, t, &msg->peer, &atsi);
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "new incoming tunnel %X\n", t->tid);
+  }
+  else
+  {
+    struct GNUNET_MESH_TunnelMessage d_msg;
+
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "No handler for incoming tunnels\n");
+
+    d_msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY);
+    d_msg.header.size = htons (sizeof (struct GNUNET_MESH_TunnelMessage));
+    d_msg.tunnel_id = msg->tunnel_id;
+
+    send_packet (h, &d_msg.header, NULL);
   }
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "new incoming tunnel %X\n", t->tid);
   return;
 }
 
@@ -1446,7 +1458,7 @@ GNUNET_MESH_tunnel_destroy (struct GNUNET_MESH_Tunnel *tunnel)
   }
 
   destroy_tunnel (tunnel, GNUNET_NO);
-  send_packet (h, &msg.header, tunnel);
+  send_packet (h, &msg.header, NULL);
 }