/**
- * Get string description for tunnel state.
+ * Get string description for tunnel state. Reentrant.
*
* @param s Tunnel state.
*
enum MeshConnectionState state)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Connection %s state was %s\n",
- GMC_2s (c), GMC_state2s (c->state));
+ "Connection %s state %s -> %s\n",
+ GMC_2s (c), GMC_state2s (c->state), GMC_state2s (state));
if (MESH_CONNECTION_DESTROYED == c->state)
{
LOG (GNUNET_ERROR_TYPE_DEBUG, "state not changing anymore\n");
return;
}
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Connection %s state is now %s\n",
- GMC_2s (c), GMC_state2s (state));
c->state = state;
if (MESH_CONNECTION_READY == state)
c->create_retry = 1;
if (path->peers[j] == shortid)
{
LOG (GNUNET_ERROR_TYPE_DEBUG, " already exists at pos %u\n", j);
- offset += i - j;
- LOG (GNUNET_ERROR_TYPE_DEBUG, " offset now\n", offset);
+ offset = i - j;
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " offset now %u\n", offset);
GNUNET_PEER_change_rc (shortid, -1);
}
}
/**
- * Core handler for notifications of broken paths
+ * Core handler for notifications of broken connections.
*
* @param cls Closure (unused).
* @param id Peer identity of sending neighbor.
c = connection_get (&msg->cid);
if (NULL == c)
{
- GNUNET_break_op (0);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " duplicate CONNECTION_BROKEN\n");
return GNUNET_OK;
}
fwd = is_fwd (c, id);
if (GMC_is_terminal (c, fwd))
{
+ struct GNUNET_MessageHeader *msg;
+ struct MeshPeer *peer;
+
+ peer = get_hop (c, !fwd);
path_invalidate (c->path);
- if (0 < c->pending_messages)
- c->destroy = GNUNET_YES;
- else
- GMC_destroy (c);
+ c->state = MESH_CONNECTION_DESTROYED;
+ while (NULL != (msg = GMP_connection_pop (peer, c)))
+ {
+ GNUNET_assert (NULL ==
+ GMT_send_prebuilt_message (msg, c->t, NULL, GNUNET_YES,
+ NULL, NULL));
+ }
+
+ GMC_destroy (c);
}
else
{
return;
}
create_connection_time = GNUNET_TIME_UNIT_SECONDS;
- connections = GNUNET_CONTAINER_multihashmap_create (1024, GNUNET_YES);
+ connections = GNUNET_CONTAINER_multihashmap_create (1024, GNUNET_NO);
}