ctx.t = t;
ctx.max_child_ack = 0;
ctx.nchildren = 0;
+ ctx.init = GNUNET_NO;
tree_iterate_children (t->tree, tunnel_get_child_fwd_ack, &ctx);
if (0 == ctx.nchildren)
r = GNUNET_SYSERR;
}
- GNUNET_CRYPTO_hash (&t->local_tid, sizeof (MESH_TunnelNumber), &hash);
- if (NULL != c &&
- GNUNET_YES !=
- GNUNET_CONTAINER_multihashmap_remove (c->own_tunnels, &hash, t))
+ if (NULL != c)
{
- GNUNET_break (0);
- r = GNUNET_SYSERR;
+ GNUNET_CRYPTO_hash (&t->local_tid, sizeof (MESH_TunnelNumber), &hash);
+ if (GNUNET_YES !=
+ GNUNET_CONTAINER_multihashmap_remove (c->own_tunnels, &hash, t))
+ {
+ GNUNET_break (0);
+ r = GNUNET_SYSERR;
+ }
}
+
GNUNET_CRYPTO_hash (&t->local_tid_dest, sizeof (MESH_TunnelNumber), &hash);
for (i = 0; i < t->nclients; i++)
{
r = GNUNET_SYSERR;
}
}
+
if (t->nclients > 0)
{
if (GNUNET_YES !=
}
GNUNET_free (t->clients);
}
+
if (NULL != t->peers)
{
GNUNET_CONTAINER_multihashmap_iterate (t->peers, &peer_info_delete_tunnel,
* @param key the hash of the local tunnel id (used to access the hashmap)
* @param value the value stored at the key (tunnel to destroy)
*
- * @return GNUNET_OK on success
+ * @return GNUNET_OK, keep iterating.
*/
static int
tunnel_destroy_iterator (void *cls, const struct GNUNET_HashCode * key, void *value)
{
struct MeshTunnel *t = value;
struct MeshClient *c = cls;
- int r;
send_client_tunnel_disconnect(t, c);
if (c != t->owner)
return GNUNET_OK;
}
tunnel_send_destroy(t);
- r = tunnel_destroy (t);
- return r;
+ t->owner = NULL;
+ t->destroy = GNUNET_YES;
+
+ return GNUNET_OK;
}
if (GNUNET_YES == t->nobuffer)
opt |= MESH_TUNNEL_OPT_NOBUFFER;
msg->opt = htonl(opt);
+ msg->reserved = 0;
peer_ptr = (struct GNUNET_PeerIdentity *) &msg[1];
for (i = 0; i < p->length; i++)
{
struct MeshTransmissionDescriptor *dd;
struct MeshPathInfo *path_info;
+ struct MeshTunnelChildInfo *cinfo;
+ struct GNUNET_PeerIdentity id;
+ unsigned int i;
+ unsigned int max;
if (GNUNET_YES == clear_cls)
{
switch (queue->type)
{
- case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
- case GNUNET_MESSAGE_TYPE_MESH_MULTICAST:
- case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " type payload\n");
+ case GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY:
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, " cancelling TUNNEL_DESTROY\n");
+ /* fall through */
+ case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
+ case GNUNET_MESSAGE_TYPE_MESH_MULTICAST:
+ case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ " type prebuilt (payload, tunnel destroy)\n");
dd = queue->cls;
data_descriptor_decrement_rc (dd->mesh_data);
break;
- case GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE:
+ case GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " type create path\n");
path_info = queue->cls;
path_destroy (path_info->path);
break;
- default:
+ default:
GNUNET_break (0);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
" type %s unknown!\n",
GNUNET_CONTAINER_DLL_remove (queue->peer->queue_head,
queue->peer->queue_tail,
queue);
+
+ /* Delete from child_fc in the appropiate tunnel */
+ max = queue->tunnel->fwd_queue_max;
+ GNUNET_PEER_resolve (queue->peer->id, &id);
+ cinfo = tunnel_get_neighbor_fc (queue->tunnel, &id);
+ for (i = 0; i < cinfo->send_buffer_n; i++)
+ {
+ unsigned int i2;
+ i2 = (cinfo->send_buffer_start + i) % max;
+ if (cinfo->send_buffer[i2] == queue)
+ {
+ /* Found corresponding entry in the send_buffer. Move all others back. */
+ unsigned int j;
+ unsigned int j2;
+ unsigned int j3;
+
+ for (j = i, j2 = 0, j3 = 0; j < cinfo->send_buffer_n - 1; j++)
+ {
+ j2 = (cinfo->send_buffer_start + j) % max;
+ j3 = (cinfo->send_buffer_start + j + 1) % max;
+ cinfo->send_buffer[j2] = cinfo->send_buffer[j3];
+ }
+
+ cinfo->send_buffer[j3] = NULL;
+
+ cinfo->send_buffer_n--;
+ }
+ }
+ //queue->
+
GNUNET_free (queue);
}
if (cinfo->send_buffer[cinfo->send_buffer_start] != queue)
{
GNUNET_break (0);
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"at pos %u (%p) != %p\n",
cinfo->send_buffer_start,
cinfo->send_buffer[cinfo->send_buffer_start],
queue);
}
- if (cinfo->send_buffer_n > 0) {
+ if (cinfo->send_buffer_n > 0)
+ {
cinfo->send_buffer[cinfo->send_buffer_start] = NULL;
cinfo->send_buffer_n--;
cinfo->send_buffer_start++;
if (NULL != cinfo->send_buffer[i])
{
GNUNET_break (cinfo->send_buffer_n == t->fwd_queue_max); // aka i == start
- queue_destroy(cinfo->send_buffer[cinfo->send_buffer_start], GNUNET_YES);
+ queue_destroy (cinfo->send_buffer[cinfo->send_buffer_start], GNUNET_YES);
cinfo->send_buffer_start++;
cinfo->send_buffer_start %= t->fwd_queue_max;
- cinfo->send_buffer_n--;
+ }
+ else
+ {
+ cinfo->send_buffer_n++;
}
cinfo->send_buffer[i] = queue;
- cinfo->send_buffer_n++;
if (cinfo->send_buffer_n > t->fwd_queue_max)
{
GNUNET_break (0);
while (NULL != q)
{
n = q->next;
- if (q->peer == pi)
- {
- /* try to reroute this traffic instead */
- queue_destroy(q, GNUNET_YES);
- }
+ /* TODO try to reroute this traffic instead */
+ queue_destroy(q, GNUNET_YES);
q = n;
}
+ if (NULL != pi->core_transmit)
+ {
+ GNUNET_CORE_notify_transmit_ready_cancel(pi->core_transmit);
+ pi->core_transmit = NULL;
+ }
peer_info_remove_path (pi, pi->id, myid);
if (myid == pi->id)
{