struct Neighbour *n = cls;
struct GNUNET_TRANSPORT_CoreHandle *h = n->h;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Notifying CORE that more bandwidth is available for %s\n",
+ GNUNET_i2s (&n->id));
+
if (NULL != h->neb_cb)
h->neb_cb (h->cls,
&n->id,
}
+/**
+ * A message from the handler's message queue to a neighbour was
+ * transmitted. Now trigger (possibly delayed) notification of the
+ * neighbour's message queue that we are done and thus ready for
+ * the next message.
+ *
+ * @param cls the `struct Neighbour` where the message was sent
+ */
+static void
+notify_send_done_fin (void *cls)
+{
+ struct Neighbour *n = cls;
+
+ n->timeout_task = NULL;
+ n->is_ready = GNUNET_YES;
+ GNUNET_MQ_impl_send_continue (n->mq);
+}
+
+
/**
* A message from the handler's message queue to a neighbour was
* transmitted. Now trigger (possibly delayed) notification of the
{
GNUNET_BANDWIDTH_tracker_consume (&n->out_tracker,
n->env_size + n->traffic_overhead);
- n->traffic_overhead = 0;
n->env = NULL;
+ n->traffic_overhead = 0;
}
delay = GNUNET_BANDWIDTH_tracker_get_delay (&n->out_tracker,
128);
GNUNET_MQ_impl_send_continue (n->mq);
return;
}
+ GNUNET_MQ_impl_send_in_flight (n->mq);
/* cannot send even a small message without violating
- quota, wait a before notifying MQ */
+ quota, wait a before allowing MQ to send next message */
n->timeout_task = GNUNET_SCHEDULER_add_delayed (delay,
- ¬ify_send_done,
+ ¬ify_send_done_fin,
n);
}
GNUNET_assert (GNUNET_YES == n->is_ready);
msize = ntohs (msg->size);
- if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*obm))
+ if (msize >= GNUNET_MAX_MESSAGE_SIZE - sizeof (*obm))
{
GNUNET_break (0);
GNUNET_MQ_impl_send_continue (mq);
return;
}
+ GNUNET_assert (NULL == n->env);
n->env = GNUNET_MQ_msg_nested_mh (obm,
GNUNET_MESSAGE_TYPE_TRANSPORT_SEND,
msg);
GNUNET_MQ_send (h->mq,
n->env);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Queued message for neighbour `%s'.\n",
+ "Queued message of type %u for neighbour `%s'.\n",
+ ntohs (msg->type),
GNUNET_i2s (&n->id));
}
struct GNUNET_TRANSPORT_CoreHandle *h = cls;
struct Neighbour *n;
- n = neighbour_find (h, &qm->peer);
+ n = neighbour_find (h,
+ &qm->peer);
if (NULL == n)
{
GNUNET_break (0);
static void
reconnect (void *cls)
{
- GNUNET_MQ_hd_var_size (hello,
- GNUNET_MESSAGE_TYPE_HELLO,
- struct GNUNET_MessageHeader);
- GNUNET_MQ_hd_fixed_size (connect,
- GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT,
- struct ConnectInfoMessage);
- GNUNET_MQ_hd_fixed_size (disconnect,
- GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT,
- struct DisconnectInfoMessage);
- GNUNET_MQ_hd_fixed_size (send_ok,
- GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK,
- struct SendOkMessage);
- GNUNET_MQ_hd_var_size (recv,
- GNUNET_MESSAGE_TYPE_TRANSPORT_RECV,
- struct InboundMessage);
- GNUNET_MQ_hd_fixed_size (set_quota,
- GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA,
- struct QuotaSetMessage);
struct GNUNET_TRANSPORT_CoreHandle *h = cls;
struct GNUNET_MQ_MessageHandler handlers[] = {
- make_hello_handler (h),
- make_connect_handler (h),
- make_disconnect_handler (h),
- make_send_ok_handler (h),
- make_recv_handler (h),
- make_set_quota_handler (h),
+ GNUNET_MQ_hd_var_size (hello,
+ GNUNET_MESSAGE_TYPE_HELLO,
+ struct GNUNET_MessageHeader,
+ h),
+ GNUNET_MQ_hd_fixed_size (connect,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT,
+ struct ConnectInfoMessage,
+ h),
+ GNUNET_MQ_hd_fixed_size (disconnect,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT,
+ struct DisconnectInfoMessage,
+ h),
+ GNUNET_MQ_hd_fixed_size (send_ok,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK,
+ struct SendOkMessage,
+ h),
+ GNUNET_MQ_hd_var_size (recv,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_RECV,
+ struct InboundMessage,
+ h),
+ GNUNET_MQ_hd_fixed_size (set_quota,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA,
+ struct QuotaSetMessage,
+ h),
GNUNET_MQ_handler_end ()
};
struct GNUNET_MQ_Envelope *env;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Connecting to transport service.\n");
GNUNET_assert (NULL == h->mq);
- h->mq = GNUNET_CLIENT_connecT (h->cfg,
+ h->mq = GNUNET_CLIENT_connect (h->cfg,
"transport",
handlers,
&mq_error_handler,
/**
* Disconnect from the transport service.
*
- * @param handle handle to the service as returned from #GNUNET_TRANSPORT_connect()
+ * @param handle handle to the service as returned from #GNUNET_TRANSPORT_core_connect()
*/
void
GNUNET_TRANSPORT_core_disconnect (struct GNUNET_TRANSPORT_CoreHandle *handle)