static void
connection_cancel_queues (struct MeshConnection *c, int fwd)
{
- struct MeshPeerQueue *q;
- struct MeshPeerQueue *next;
+
struct MeshFlowControl *fc;
struct MeshPeer *peer;
GNUNET_break (0);
return;
}
- fc = fwd ? &c->fwd_fc : &c->bck_fc;
+
peer = connection_get_hop (c, fwd);
+ GMP_queue_cancel (peer, c);
- for (q = peer->queue_head; NULL != q; q = next)
- {
- next = q->next;
- if (q->c == c)
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "connection_cancel_queue %s\n",
- GNUNET_MESH_DEBUG_M2S (q->type));
- queue_destroy (q, GNUNET_YES);
- }
- }
- if (NULL == peer->queue_head)
+ fc = fwd ? &c->fwd_fc : &c->bck_fc;
+ if (GNUNET_SCHEDULER_NO_TASK != fc->poll_task)
{
- if (NULL != peer->core_transmit)
- {
- GNUNET_CORE_notify_transmit_ready_cancel (peer->core_transmit);
- peer->core_transmit = NULL;
- }
- if (GNUNET_SCHEDULER_NO_TASK != fc->poll_task)
- {
- GNUNET_SCHEDULER_cancel (fc->poll_task);
- fc->poll_task = GNUNET_SCHEDULER_NO_TASK;
- }
+ GNUNET_SCHEDULER_cancel (fc->poll_task);
+ fc->poll_task = GNUNET_SCHEDULER_NO_TASK;
}
}
}
+/**
+ * Cancel all queued messages to a peer that belong to a certain connection.
+ *
+ * @param peer Peer towards whom to cancel.
+ * @param c Connection whose queued messages to cancel.
+ */
+void
+GMP_queue_cancel (struct MeshPeer *peer, struct MeshConnection *c)
+{
+ struct MeshPeerQueue *q;
+ struct MeshPeerQueue *next;
+
+ for (q = peer->queue_head; NULL != q; q = next)
+ {
+ next = q->next;
+ if (q->c == c)
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "connection_cancel_queue %s\n",
+ GNUNET_MESH_DEBUG_M2S (q->type));
+ GMP_queue_destroy (q, GNUNET_YES);
+ }
+ }
+ if (NULL == peer->queue_head)
+ {
+ if (NULL != peer->core_transmit)
+ {
+ GNUNET_CORE_notify_transmit_ready_cancel (peer->core_transmit);
+ peer->core_transmit = NULL;
+ }
+ }
+}
+
/**
* Initialize the peer subsystem.
}
+/**
+ * Remove a connection from a neighboring peer.
+ *
+ * @param peer Peer to remove connection from.
+ * @param c Connection to remove.
+ *
+ * @return GNUNET_OK on success.
+ */
int
GMP_remove_connection (struct MeshPeer *peer,
const struct MeshConnection *c)
int fwd,
GMP_sent callback, void *callback_cls);
+/**
+ * Cancel all queued messages to a peer that belong to a certain connection.
+ *
+ * @param peer Peer towards whom to cancel.
+ * @param c Connection whose queued messages to cancel.
+ */
+void
+GMP_queue_cancel (struct MeshPeer *peer, struct MeshConnection *c);
+
/**
* Set tunnel.
*
int
GMP_add_connection (struct MeshPeer *peer, struct MeshConnection *c);
+/**
+ * Remove a connection from a neighboring peer.
+ *
+ * @param peer Peer to remove connection from.
+ * @param c Connection to remove.
+ *
+ * @return GNUNET_OK on success.
+ */
int
GMP_remove_connection (struct MeshPeer *peer, struct MeshConnection *c);