static struct MeshTunnel *
tunnel_get_by_local_id (struct MeshClient *c, MESH_TunnelNumber tid)
{
+ if (0 == (tid & GNUNET_MESH_LOCAL_TUNNEL_ID_CLI))
+ {
+ GNUNET_break_op (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "TID %X not a local tid\n", tid);
+ return NULL;
+ }
if (tid >= GNUNET_MESH_LOCAL_TUNNEL_ID_SERV)
{
return tunnel_get_incoming (tid);
}
else
{
- GNUNET_assert (tid >= GNUNET_MESH_LOCAL_TUNNEL_ID_CLI);
return GNUNET_CONTAINER_multihashmap32_get (c->own_tunnels, tid);
}
}
t->owner = client;
fc_init (&t->next_fc);
fc_init (&t->prev_fc);
+ t->next_fc.t = t;
+ t->prev_fc.t = t;
t->local_tid = local;
n_tunnels++;
GNUNET_STATISTICS_update (stats, "# tunnels", 1, GNUNET_NO);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"* %s starting poll timeout\n",
GNUNET_i2s (&my_full_id));
- fc->t = t;
fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time,
&tunnel_poll, fc);
}
t_msg = (struct GNUNET_MESH_TunnelMessage *) message;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " towards %s\n",
GNUNET_i2s (&t_msg->peer));
- /* Sanity check for tunnel numbering */
tid = ntohl (t_msg->tunnel_id);
- if (0 == (tid & GNUNET_MESH_LOCAL_TUNNEL_ID_CLI))
- {
- GNUNET_break (0);
- GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
- return;
- }
/* Sanity check for duplicate tunnel IDs */
if (NULL != tunnel_get_by_local_id (c, tid))
{
/* Retrieve tunnel */
tid = ntohl (tunnel_msg->tunnel_id);
- t = tunnel_get_by_local_id(c, tid);
+ t = tunnel_get_by_local_id (c, tid);
if (NULL == t)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, " tunnel %X not found\n", tid);
/* Cleanup after the tunnel */
client_delete_tunnel (c, t);
- if (c == t->client)
+ if (c == t->client && GNUNET_MESH_LOCAL_TUNNEL_ID_SERV >= tid)
{
t->client = NULL;
}
- if (c == t->owner)
+ else if (c == t->owner && GNUNET_MESH_LOCAL_TUNNEL_ID_SERV < tid)
{
peer_info_remove_tunnel (peer_get_short (t->dest), t);
t->owner = NULL;
}
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ " tunnel %X client %p (%p, %p)\n",
+ tid, c, t->owner, t->client);
+ GNUNET_break (0);
+ }
/* The tunnel will be destroyed when the last message is transmitted. */
tunnel_destroy_empty (t);
/* Tunnel exists? */
tid = ntohl (data_msg->tid);
- if (tid < GNUNET_MESH_LOCAL_TUNNEL_ID_CLI)
- {
- GNUNET_break (0);
- GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
- return;
- }
t = tunnel_get_by_local_id (c, tid);
if (NULL == t)
{