aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-07-02 19:38:13 +0000
committerBart Polot <bart@net.in.tum.de>2013-07-02 19:38:13 +0000
commit4e5c0e01a3f9b8b6abd08958a09a155fece59e51 (patch)
treeddcb0d4133e53b0cf337f935cf9579a92969abd5 /src
parent1524472d6ceafe79495a81fc9313fa981495a3b1 (diff)
downloadgnunet-4e5c0e01a3f9b8b6abd08958a09a155fece59e51.tar.gz
gnunet-4e5c0e01a3f9b8b6abd08958a09a155fece59e51.zip
- add drop option for future testcases
Diffstat (limited to 'src')
-rw-r--r--src/mesh/gnunet-service-mesh.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index 622d399b4..7803bbf5a 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -526,6 +526,10 @@ static unsigned long long max_msgs_queue;
526 */ 526 */
527static unsigned long long max_peers; 527static unsigned long long max_peers;
528 528
529/**
530 * Percentage of messages that will be dropped (for test purposes only).
531 */
532static unsigned long long drop_percent;
529 533
530/*************************** Static global variables **************************/ 534/*************************** Static global variables **************************/
531 535
@@ -2916,6 +2920,14 @@ queue_send (void *cls, size_t size, void *buf)
2916 data_size = 0; 2920 data_size = 0;
2917 } 2921 }
2918 2922
2923 if (0 < drop_percent &&
2924 GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 101) < drop_percent)
2925 {
2926 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2927 "Dropping message of type %s\n",
2928 GNUNET_MESH_DEBUG_M2S(queue->type));
2929 data_size = 0;
2930 }
2919 /* Free queue, but cls was freed by send_core_* */ 2931 /* Free queue, but cls was freed by send_core_* */
2920 queue_destroy (queue, GNUNET_NO); 2932 queue_destroy (queue, GNUNET_NO);
2921 2933
@@ -5143,6 +5155,20 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
5143 } 5155 }
5144 5156
5145 if (GNUNET_OK != 5157 if (GNUNET_OK !=
5158 GNUNET_CONFIGURATION_get_value_number (c, "MESH", "DROP_PERCENT",
5159 &drop_percent))
5160 {
5161 drop_percent = 0;
5162 }
5163 else
5164 {
5165 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
5166 "Mesh is running with drop mode enabled. "
5167 "This is NOT a good idea! "
5168 "Remove the DROP_PERCENT option from your configuration.\n");
5169 }
5170
5171 if (GNUNET_OK !=
5146 GNUNET_CONFIGURATION_get_value_number (c, "MESH", "DHT_REPLICATION_LEVEL", 5172 GNUNET_CONFIGURATION_get_value_number (c, "MESH", "DHT_REPLICATION_LEVEL",
5147 &dht_replication_level)) 5173 &dht_replication_level))
5148 { 5174 {