(const struct QuotaSetMessage *) message;
struct NeighbourList *n;
struct TransportPlugin *p;
- struct ReadyList *rl;
+ struct ReadyList *rl;
+ uint32_t qin;
n = find_neighbour (&qsm->peer);
if (n == NULL)
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
-
+ qin = ntohl (qsm->quota_in);
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received `%s' request (new quota %u, old quota %u) from client for peer `%4s'\n",
- "SET_QUOTA", ntohl(qsm->quota_in), n->quota_in, GNUNET_i2s (&qsm->peer));
+ "SET_QUOTA", qin, n->quota_in, GNUNET_i2s (&qsm->peer));
#endif
-
update_quota (n);
- if (n->quota_in < ntohl (qsm->quota_in))
+ if (n->quota_in < qin)
n->last_quota_update = GNUNET_TIME_absolute_get ();
- n->quota_in = ntohl (qsm->quota_in);
+ n->quota_in = qin;
rl = n->plugins;
while (rl != NULL)
{
p = rl->plugin;
p->api->set_receive_quota (p->api->cls,
- &qsm->peer, ntohl (qsm->quota_in));
+ &qsm->peer, qin);
rl = rl->next;
}
GNUNET_SERVER_receive_done (client, GNUNET_OK);
struct PendingMessage *pm;
struct WelcomeMessage welcome;
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+ "tcp",
+ "Creating new session for peer `%4s'\n",
+ GNUNET_i2s (target));
ret = GNUNET_malloc (sizeof (struct Session));
ret->plugin = plugin;
ret->next = plugin->sessions;
session = find_session_by_target (plugin, target);
if (session == NULL)
- return; /* peer must have disconnected, ignore */
+ {
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+ "tcp",
+ "Could not find session for peer `%4s' to update quota.\n",
+ GNUNET_i2s (target));
+ return; /* peer must have disconnected, ignore */
+ }
if (session->quota_in != quota_in)
{
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+ "tcp",
+ "Changing quota for peer `%4s' from %u to %u\n",
+ GNUNET_i2s (target),
+ session->quota_in,
+ quota_in);
update_quota (session, GNUNET_YES);
if (session->quota_in > quota_in)
session->last_quota_update = GNUNET_TIME_absolute_get ();
return GNUNET_TIME_UNIT_ZERO; /* can receive right now */
excess = session->last_received - avail;
ret.value = excess / session->quota_in;
+ GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING,
+ "tcp",
+ "Throttling read (%llu bytes excess at %llu b/ms), waiting %llums before reading more.\n",
+ (unsigned long long) excess,
+ (unsigned long long) session->quota_in,
+ (unsigned long long) ret.value);
return ret;
}