[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r36448 - gnunet/src/cadet
From: |
gnunet |
Subject: |
[GNUnet-SVN] r36448 - gnunet/src/cadet |
Date: |
Tue, 6 Oct 2015 14:03:16 +0200 |
Author: bartpolot
Date: 2015-10-06 14:03:16 +0200 (Tue, 06 Oct 2015)
New Revision: 36448
Modified:
gnunet/src/cadet/gnunet-service-cadet_peer.c
gnunet/src/cadet/test_cadet.c
Log:
- refactor test dropping, reduce test load
Modified: gnunet/src/cadet/gnunet-service-cadet_peer.c
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_peer.c 2015-10-06 12:03:14 UTC
(rev 36447)
+++ gnunet/src/cadet/gnunet-service-cadet_peer.c 2015-10-06 12:03:16 UTC
(rev 36448)
@@ -1139,6 +1139,28 @@
/**
+ * Debug function should NEVER return true in production code, useful to
+ * simulate losses for testcases.
+ *
+ * @param q Queue handle with info about the message.
+ *
+ * @return #GNUNET_YES or #GNUNET_NO with the decision to drop.
+ */
+static int
+should_I_drop (struct CadetPeerQueue *q)
+{
+ static int i = 0;
+
+ if (0 == drop_percent)
+ return GNUNET_NO;
+
+ if (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 101) <
drop_percent)
+ return GNUNET_YES;
+
+ return GNUNET_NO;
+}
+
+/**
* Core callback to write a queued packet to core buffer
*
* @param cls Closure (peer info).
@@ -1237,8 +1259,7 @@
msg_size = fill_buf (queue, (void *) dst, size, &pid);
- if (0 < drop_percent &&
- GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 101) <
drop_percent)
+ if (should_I_drop (queue))
{
LOG (GNUNET_ERROR_TYPE_WARNING, "DD %s (%s %u) on conn %s %s\n",
GC_m2s (queue->type), GC_m2s (queue->payload_type),
Modified: gnunet/src/cadet/test_cadet.c
===================================================================
--- gnunet/src/cadet/test_cadet.c 2015-10-06 12:03:14 UTC (rev 36447)
+++ gnunet/src/cadet/test_cadet.c 2015-10-06 12:03:16 UTC (rev 36448)
@@ -33,7 +33,7 @@
/**
* How many messages to send
*/
-#define TOTAL_PACKETS 5000 /* Cannot exceed 64k! */
+#define TOTAL_PACKETS 200 /* Cannot exceed 64k! */
/**
* How long until we give up on connecting the peers?
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r36448 - gnunet/src/cadet,
gnunet <=