*/
struct GNUNET_MQ_Handle *mq;
+ /**
+ * Task to allow mq to send more traffic.
+ */
+ struct GNUNET_SCHEDULER_Task *mq_cont;
+
/**
* Window change handler.
*/
}
+/**
+ * Notify the application about a change in the window size (if needed).
+ *
+ * @param ch Channel to notify about.
+ */
+static void
+notify_window_size (struct GNUNET_CADET_Channel *ch)
+{
+ if (NULL != ch->window_changes)
+ {
+ ch->window_changes (ch->ctx, ch, ch->allow_send);
+ }
+}
+
/******************************************************************************/
/*********************** MQ API CALLBACKS ****************************/
/******************************************************************************/
+/**
+ * Allow the MQ implementation to send the next message.
+ *
+ * @param cls Closure (channel whose mq to activate).
+ */
+static void
+cadet_mq_send_continue (void *cls)
+{
+ struct GNUNET_CADET_Channel *ch = cls;
+
+ GNUNET_MQ_impl_send_continue (ch->mq);
+}
/**
* Implement sending functionality of a message queue for
msg);
cadet_msg->ccn = ch->ccn;
GNUNET_MQ_send (h->mq, env);
- GNUNET_MQ_impl_send_continue (mq);
+
+ GNUNET_assert (0 < ch->allow_send);
+ ch->allow_send--;
+ notify_window_size (ch);
+ if (0 < ch->allow_send)
+ {
+ ch->mq_cont = GNUNET_SCHEDULER_add_now (&cadet_mq_send_continue, ch);
+ } /* Otherwise it will be called upon ACK receipt. */
}
*
* @param h Cadet handle.
* @param message Message itself.
- *
- * FIXME either delete or port to MQ
*/
static void
handle_local_ack (void *cls,
"Got an ACK on channel %X, allow send now %u!\n",
ntohl (ch->ccn.channel_of_client),
ch->allow_send);
+ if (NULL != ch->mq)
+ {
+ notify_window_size (ch);
+ if (1 == ch->allow_send)
+ {
+ ch->mq_cont = GNUNET_SCHEDULER_add_now (&cadet_mq_send_continue, ch);
+ }
+ return;
+ }
+
+ /** @deprecated */
+ /* Old style API */
for (th = h->th_head; NULL != th; th = th->next)
{
if ( (th->channel == ch) &&
* @param cls Closure from #GNUNET_CADET_open_porT.
* @param channel New handle to the channel.
* @param source Peer that started this channel.
- * FIXME: Add port that this channel is created for, or is cls enough?
- * Port cannot be closed yet, #handle_channel_create would have
- * rejected it.
* @return Closure for the incoming @a channel. It's given to:
* - The #GNUNET_CADET_DisconnectEventHandler (given to
* #GNUNET_CADET_open_porT) when the channel dies.