*/
#define MAXIMUM_REPLICATION_LEVEL 16
+/**
+ * Maximum allowed number of pending messages per peer.
+ */
+#define MAXIMUM_PENDING_PER_PEER 64
+
/**
* How often to update our preference levels for peers in our routing tables.
*/
struct PeerInfo *prev;
/**
- * Count of outstanding messages for peer. FIXME: NEEDED?
- * FIXME: bound queue size!?
+ * Count of outstanding messages for peer.
*/
unsigned int pending_count;
for (i = 0; i < target_count; i++)
{
target = targets[i];
+ if (target->pending_count >= MAXIMUM_PENDING_PER_PEER)
+ {
+ GNUNET_STATISTICS_update (GDS_stats, gettext_noop ("# P2P messages dropped due to full queue"),
+ 1, GNUNET_NO);
+ continue; /* skip */
+ }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Routing PUT for %s after %u hops to %s\n", GNUNET_h2s (key),
(unsigned int) hop_count, GNUNET_i2s (&target->id));
for (i = 0; i < target_count; i++)
{
target = targets[i];
+ if (target->pending_count >= MAXIMUM_PENDING_PER_PEER)
+ {
+ GNUNET_STATISTICS_update (GDS_stats, gettext_noop ("# P2P messages dropped due to full queue"),
+ 1, GNUNET_NO);
+ continue; /* skip */
+ }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Routing GET for %s after %u hops to %s\n", GNUNET_h2s (key),
(unsigned int) hop_count, GNUNET_i2s (&target->id));
/* peer disconnected in the meantime, drop reply */
return;
}
+ if (pi->pending_count >= MAXIMUM_PENDING_PER_PEER)
+ {
+ /* skip */
+ GNUNET_STATISTICS_update (GDS_stats, gettext_noop ("# P2P messages dropped due to full queue"),
+ 1, GNUNET_NO);
+ return;
+ }
+
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop
("# RESULT messages queued for transmission"), 1,