#define DEBUG_HANDSHAKE GNUNET_NO
+#define DEBUG_CORE_QUOTA GNUNET_YES
+
/**
* Receive and send buffer windows grow over time. For
* how long can 'unused' bandwidth accumulate before we
memcpy (cbuf, &m[1], m->size);
ret = m->size;
n->available_send_window -= m->size;
- process_encrypted_neighbour_queue (n);
-
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Copied message of type %u and size %u into transport buffer for `%4s'\n",
ntohs (((struct GNUNET_MessageHeader *) &m[1])->type),
ret, GNUNET_i2s (&n->peer));
#endif
+ process_encrypted_neighbour_queue (n);
}
else
{
unsigned long long slack; /* how long could we wait before missing deadlines? */
size_t off;
int discard_low_prio;
+ unsigned int queue_size;
GNUNET_assert (NULL != n->messages);
now = GNUNET_TIME_absolute_get ();
/* should we remove the entry with the lowest
priority from consideration for scheduling at the
end of the loop? */
+ queue_size = 0;
+ pos = n->messages;
+ while (pos != NULL)
+ {
+ queue_size++;
+ pos = pos->next;
+ }
discard_low_prio = GNUNET_YES;
while (GNUNET_YES == discard_low_prio)
{
sense since new message might be scheduled in the
meantime... */
while ((pos != NULL) && (off < size * 2))
- {
+ {
if (pos->do_transmit == GNUNET_YES)
{
/* already removed from consideration */
}
/* guard against sending "tiny" messages with large headers without
urgent deadlines */
- if ( (slack > 1000) && (size > 4 * off) )
+ if ( (slack > 1000) &&
+ (size > 4 * off) &&
+ (queue_size < MAX_PEER_QUEUE_SIZE / 2) )
{
/* less than 25% of message would be filled with deadlines still
being met if we delay by one second or more; so just wait for
}
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Deferring transmission for 1s due to underfull message buffer size\n");
+ "Deferring transmission for 1s due to underfull message buffer size (%u/%u)\n",
+ (unsigned int) off,
+ (unsigned int) size);
#endif
return 0;
}
/* discard new entry */
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Queue full, discarding new request\n");
+ "Queue full (%u/%u), discarding new request (%u bytes of type %u)\n",
+ queue_size,
+ MAX_PEER_QUEUE_SIZE,
+ msize,
+ ntohs (message->type));
#endif
if (client != NULL)
GNUNET_SERVER_receive_done (client, GNUNET_OK);
double pref_rel;
double share;
unsigned long long distributable;
+ uint32_t qin_ms;
+ uint32_t qout_ms;
n->quota_update_task = GNUNET_SCHEDULER_NO_TASK;
/* calculate relative preference among all neighbours;
(n->bpm_in - MIN_BPM_CHANGE > q_in) )
{
n->bpm_in = q_in;
+ /* need to convert to bytes / ms, rounding up! */
+ qin_ms = (q_in == 0) ? 0 : 1 + q_in / 60000;
+ qout_ms = (n->bpm_out == 0) ? 0 : 1 + n->bpm_out / 60000;
GNUNET_TRANSPORT_set_quota (transport,
&n->peer,
n->bpm_in,