* Closure given to the DHT GET
*/
struct MeshPathInfo *dhtgetcls;
-
- /**
- * Transmission queue to this peer, head
- */
- struct MeshPeerQueue *queue_head;
-
- /**
- * Transmission queue to this peer, tail
- */
- struct MeshPeerQueue *queue_tail;
/**
* Array of tunnels this peer participates in
* Number of tunnels this peers participates in
*/
unsigned int ntunnels;
-
- /**
- * Handle to stop queued transmission
- */
- struct GNUNET_CORE_TransmitHandle *core_transmit;
};
static struct MeshClient *clients;
static struct MeshClient *clients_tail;
+/**
+ * Transmission queue to core
+ */
+struct MeshPeerQueue *queue_head;
+struct MeshPeerQueue *queue_tail;
+
/**
* Tunnels known, indexed by MESH_TunnelID (MeshTunnel)
*/
*/
static struct GNUNET_CONTAINER_MultiHashMap *peers;
+/*
+ * Handle to communicate with transport
+ */
+// static struct GNUNET_TRANSPORT_Handle *transport_handle;
+
/**
* Handle to communicate with core
*/
static struct GNUNET_CORE_Handle *core_handle;
/**
- * Handle to communicate with transport
+ * Handle to for queued transmissions
*/
-// static struct GNUNET_TRANSPORT_Handle *transport_handle;
+struct GNUNET_CORE_TransmitHandle *core_transmit;
/**
* Handle to use DHT
{
struct MeshTransmissionDescriptor *dd;
struct MeshPathInfo *path_info;
- struct MeshPeerInfo *peer;
- peer = queue->peer;
if (GNUNET_YES == clear_cls)
{
switch (queue->type)
}
GNUNET_free_non_null (queue->cls);
}
- GNUNET_CONTAINER_DLL_remove (peer->queue_head, peer->queue_tail, queue);
- GNUNET_free(queue);
+ GNUNET_CONTAINER_DLL_remove (queue_head, queue_tail, queue);
+ GNUNET_free (queue);
}
struct MeshPeerQueue *queue;
size_t data_size;
- peer->core_transmit = NULL;
- queue = peer->queue_head;
+ core_transmit = NULL;
+ queue = queue_head;
/* If queue is empty, send should have been cancelled */
if (NULL == queue)
struct GNUNET_PeerIdentity id;
GNUNET_PEER_resolve (peer->id, &id);
- peer->core_transmit =
+ core_transmit =
GNUNET_CORE_notify_transmit_ready(core_handle,
0,
0,
queue_destroy(queue, GNUNET_NO);
/* If more data in queue, send next */
- if (NULL != peer->queue_head)
+ if (NULL != queue_head)
{
struct GNUNET_PeerIdentity id;
GNUNET_PEER_resolve (peer->id, &id);
- peer->core_transmit =
+ core_transmit =
GNUNET_CORE_notify_transmit_ready(core_handle,
0,
0,
GNUNET_TIME_UNIT_FOREVER_REL,
&id,
- peer->queue_head->size,
+ queue_head->size,
&queue_send,
peer);
}
queue->type = type;
queue->size = size;
queue->peer = dst;
- GNUNET_CONTAINER_DLL_insert_tail (dst->queue_head, dst->queue_tail, queue);
- if (NULL == dst->core_transmit)
+ GNUNET_CONTAINER_DLL_insert_tail (queue_head, queue_tail, queue);
+ if (NULL == core_transmit)
{
struct GNUNET_PeerIdentity id;
GNUNET_PEER_resolve (dst->id, &id);
- dst->core_transmit =
+ core_transmit =
GNUNET_CORE_notify_transmit_ready(core_handle,
0,
0,
core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
struct MeshPeerInfo *pi;
+ struct MeshPeerQueue *q;
+ struct MeshPeerQueue *n;
DEBUG_CONN ("Peer disconnected\n");
pi = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey);
GNUNET_break (0);
return;
}
- while (NULL != pi->queue_head)
+ q = queue_head;
+ while (NULL != q)
{
- queue_destroy(pi->queue_head, GNUNET_YES);
+ n = q->next;
+ if (q->peer == pi)
+ {
+ /* try to reroute this traffic instead */
+ queue_destroy(queue_head, GNUNET_YES);
+ }
+ q = n;
}
peer_info_remove_path (pi, pi->id, myid);
if (myid == pi->id)
shutdown_peer (void *cls, const GNUNET_HashCode * key, void *value)
{
struct MeshPeerInfo *p = value;
+ struct MeshPeerQueue *q;
+ struct MeshPeerQueue *n;
- while (NULL != p->queue_head)
+ q = queue_head;
+ while (NULL != q)
{
- queue_destroy(p->queue_head, GNUNET_YES);
+ n = q->next;
+ if (q->peer == p)
+ {
+ queue_destroy(queue_head, GNUNET_YES);
+ }
+ q = n;
}
peer_info_destroy (p);
return GNUNET_YES;