aboutsummaryrefslogtreecommitdiff
path: root/src/dht
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-06-12 19:23:11 +0000
committerChristian Grothoff <christian@grothoff.org>2012-06-12 19:23:11 +0000
commit4f315d96b8ea8a169ab36b10dd131642d6ab5d84 (patch)
treee69672a55f6b5e6a836127edf0083435b3873f58 /src/dht
parent6c471eeb15e27f8226492b4860a3c2acb94c5f25 (diff)
downloadgnunet-4f315d96b8ea8a169ab36b10dd131642d6ab5d84.tar.gz
gnunet-4f315d96b8ea8a169ab36b10dd131642d6ab5d84.zip
-fixing #2420
Diffstat (limited to 'src/dht')
-rw-r--r--src/dht/gnunet-service-dht_neighbours.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c
index 891519314..fdbb29371 100644
--- a/src/dht/gnunet-service-dht_neighbours.c
+++ b/src/dht/gnunet-service-dht_neighbours.c
@@ -70,6 +70,11 @@
70#define MAXIMUM_REPLICATION_LEVEL 16 70#define MAXIMUM_REPLICATION_LEVEL 16
71 71
72/** 72/**
73 * Maximum allowed number of pending messages per peer.
74 */
75#define MAXIMUM_PENDING_PER_PEER 64
76
77/**
73 * How often to update our preference levels for peers in our routing tables. 78 * How often to update our preference levels for peers in our routing tables.
74 */ 79 */
75#define DHT_DEFAULT_PREFERENCE_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 2) 80#define DHT_DEFAULT_PREFERENCE_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 2)
@@ -301,8 +306,7 @@ struct PeerInfo
301 struct PeerInfo *prev; 306 struct PeerInfo *prev;
302 307
303 /** 308 /**
304 * Count of outstanding messages for peer. FIXME: NEEDED? 309 * Count of outstanding messages for peer.
305 * FIXME: bound queue size!?
306 */ 310 */
307 unsigned int pending_count; 311 unsigned int pending_count;
308 312
@@ -1238,6 +1242,12 @@ GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
1238 for (i = 0; i < target_count; i++) 1242 for (i = 0; i < target_count; i++)
1239 { 1243 {
1240 target = targets[i]; 1244 target = targets[i];
1245 if (target->pending_count >= MAXIMUM_PENDING_PER_PEER)
1246 {
1247 GNUNET_STATISTICS_update (GDS_stats, gettext_noop ("# P2P messages dropped due to full queue"),
1248 1, GNUNET_NO);
1249 continue; /* skip */
1250 }
1241 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1251 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1242 "Routing PUT for %s after %u hops to %s\n", GNUNET_h2s (key), 1252 "Routing PUT for %s after %u hops to %s\n", GNUNET_h2s (key),
1243 (unsigned int) hop_count, GNUNET_i2s (&target->id)); 1253 (unsigned int) hop_count, GNUNET_i2s (&target->id));
@@ -1345,6 +1355,12 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
1345 for (i = 0; i < target_count; i++) 1355 for (i = 0; i < target_count; i++)
1346 { 1356 {
1347 target = targets[i]; 1357 target = targets[i];
1358 if (target->pending_count >= MAXIMUM_PENDING_PER_PEER)
1359 {
1360 GNUNET_STATISTICS_update (GDS_stats, gettext_noop ("# P2P messages dropped due to full queue"),
1361 1, GNUNET_NO);
1362 continue; /* skip */
1363 }
1348 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1364 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1349 "Routing GET for %s after %u hops to %s\n", GNUNET_h2s (key), 1365 "Routing GET for %s after %u hops to %s\n", GNUNET_h2s (key),
1350 (unsigned int) hop_count, GNUNET_i2s (&target->id)); 1366 (unsigned int) hop_count, GNUNET_i2s (&target->id));
@@ -1438,6 +1454,14 @@ GDS_NEIGHBOURS_handle_reply (const struct GNUNET_PeerIdentity *target,
1438 /* peer disconnected in the meantime, drop reply */ 1454 /* peer disconnected in the meantime, drop reply */
1439 return; 1455 return;
1440 } 1456 }
1457 if (pi->pending_count >= MAXIMUM_PENDING_PER_PEER)
1458 {
1459 /* skip */
1460 GNUNET_STATISTICS_update (GDS_stats, gettext_noop ("# P2P messages dropped due to full queue"),
1461 1, GNUNET_NO);
1462 return;
1463 }
1464
1441 GNUNET_STATISTICS_update (GDS_stats, 1465 GNUNET_STATISTICS_update (GDS_stats,
1442 gettext_noop 1466 gettext_noop
1443 ("# RESULT messages queued for transmission"), 1, 1467 ("# RESULT messages queued for transmission"), 1,