[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r14440 - in gnunet/src: dht include testing
From: |
gnunet |
Subject: |
[GNUnet-SVN] r14440 - in gnunet/src: dht include testing |
Date: |
Thu, 17 Feb 2011 14:29:47 +0100 |
Author: nevans
Date: 2011-02-17 14:29:47 +0100 (Thu, 17 Feb 2011)
New Revision: 14440
Modified:
gnunet/src/dht/gnunet-dht-driver.c
gnunet/src/include/gnunet_testing_lib.h
gnunet/src/testing/testing_group.c
Log:
Allow testing connection process to be stopped when asked.
Modified: gnunet/src/dht/gnunet-dht-driver.c
===================================================================
--- gnunet/src/dht/gnunet-dht-driver.c 2011-02-17 12:00:53 UTC (rev 14439)
+++ gnunet/src/dht/gnunet-dht-driver.c 2011-02-17 13:29:47 UTC (rev 14440)
@@ -716,6 +716,11 @@
static unsigned int previous_connections;
/**
+ * For counting failed connections during some duration.
+ */
+static unsigned int previous_failed_connections;
+
+/**
* Global used to count how many failed connections we have
* been notified about (how many times has topology_callback
* been called with failure?)
@@ -2597,8 +2602,11 @@
unsigned long long duration;
unsigned long long total_duration;
unsigned int new_connections;
+ unsigned int new_failed_connections;
float conns_per_sec_recent;
float conns_per_sec_total;
+ float failed_conns_per_sec_recent;
+ float failed_conns_per_sec_total;
#if ONLY_TESTING
if (repeat_connect_mode == GNUNET_YES)
@@ -2615,26 +2623,40 @@
repeat_connect_peer1 = NULL;
repeat_connect_peer2 = NULL;
repeat_connect_mode = GNUNET_NO;
+ GNUNET_TESTING_resume_connections(pg);
+ GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Resuming normal
connection mode, debug connection was successful!\n");
}
}
}
#endif
+
+
if (GNUNET_TIME_absolute_get_difference (connect_last_time,
GNUNET_TIME_absolute_get()).rel_value >
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS,
CONN_UPDATE_DURATION).rel_value)
{
/* Get number of new connections */
new_connections = total_connections - previous_connections;
+
+ /* Get number of new FAILED connections */
+ new_failed_connections = failed_connections -
previous_failed_connections;
+
/* Get duration in seconds */
duration = GNUNET_TIME_absolute_get_difference (connect_last_time,
GNUNET_TIME_absolute_get()).rel_value / 1000;
total_duration = GNUNET_TIME_absolute_get_difference (connect_start_time,
GNUNET_TIME_absolute_get()).rel_value / 1000;
+
+ failed_conns_per_sec_recent = (float)new_failed_connections / duration;
+ failed_conns_per_sec_total = (float)failed_connections / total_duration;
conns_per_sec_recent = (float)new_connections / duration;
conns_per_sec_total = (float)total_connections / total_duration;
- GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Conns/sec in last %d seconds: %f,
Conns/sec for entire duration: %f\n", CONN_UPDATE_DURATION,
(float)new_connections / duration, (float)total_connections / total_duration);
+ GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Recent: %f/s, Total: %f/s, Recent
failed: %f/s, total failed %f/s\n",
+ conns_per_sec_recent, CONN_UPDATE_DURATION,
conns_per_sec_total,
+ failed_conns_per_sec_recent, failed_conns_per_sec_total);
connect_last_time = GNUNET_TIME_absolute_get();
previous_connections = total_connections;
+ previous_failed_connections = failed_connections;
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "have %u total_connections\n",
total_connections);
#if ONLY_TESTING
/* These conditions likely mean we've entered the death spiral of doom */
@@ -2645,11 +2667,12 @@
(repeat_connect_mode == GNUNET_NO))
{
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Entering repeat connection
attempt mode!\n");
-
repeat_connect_peer1 = first_daemon;
repeat_connect_peer2 = second_daemon;
repeat_connect_mode = GNUNET_YES;
- repeat_connect_task = GNUNET_SCHEDULER_add_now(&repeat_connect,
NULL);
+ GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Stopping NEW connections from
being scheduled!\n");
+ GNUNET_TESTING_stop_connections(pg);
+ repeat_connect_task =
GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS,
60), &repeat_connect, NULL);
}
#endif
@@ -2667,10 +2690,11 @@
else
{
failed_connections++;
+#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to connect peer %s to
peer %s with error :\n%s\n",
first_daemon->shortname,
second_daemon->shortname, emsg);
-#if VERBOSE
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to connect peer %s to peer
%s with error :\n%s\n",
first_daemon->shortname,
second_daemon->shortname, emsg);
Modified: gnunet/src/include/gnunet_testing_lib.h
===================================================================
--- gnunet/src/include/gnunet_testing_lib.h 2011-02-17 12:00:53 UTC (rev
14439)
+++ gnunet/src/include/gnunet_testing_lib.h 2011-02-17 13:29:47 UTC (rev
14440)
@@ -889,6 +889,20 @@
GNUNET_TESTING_NotifyTopology cb, void *cls);
/**
+ * Stop the connection process temporarily.
+ *
+ * @param pg the peer group to stop connecting
+ */
+void GNUNET_TESTING_stop_connections(struct GNUNET_TESTING_PeerGroup *pg);
+
+/**
+ * Resume the connection process.
+ *
+ * @param pg the peer group to resume connecting
+ */
+void GNUNET_TESTING_resume_connections(struct GNUNET_TESTING_PeerGroup *pg);
+
+/**
* There are many ways to connect peers that are supported by this function.
* To connect peers in the same topology that was created via the
* GNUNET_TESTING_create_topology, the topology variable must be set to
Modified: gnunet/src/testing/testing_group.c
===================================================================
--- gnunet/src/testing/testing_group.c 2011-02-17 12:00:53 UTC (rev 14439)
+++ gnunet/src/testing/testing_group.c 2011-02-17 13:29:47 UTC (rev 14440)
@@ -702,6 +702,11 @@
* ssh connections per peer.
*/
struct OutstandingSSH *ssh_tail;
+
+ /**
+ * Stop scheduling peers connecting.
+ */
+ unsigned int stop_connects;
};
struct UpdateContext
@@ -2904,8 +2909,9 @@
random_peer = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK,
pg->total);
connection_iter = pg->peers[random_peer].connect_peers_head;
+#if DEBUG_TESTING
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Scheduling connection between %d and
%d\n", random_peer, connection_iter->index);
-
+#endif
connect_context = GNUNET_malloc (sizeof (struct ConnectContext));
connect_context->first = pg->peers[random_peer].daemon;
connect_context->second = pg->peers[connection_iter->index].daemon;
@@ -2967,7 +2973,7 @@
if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
return;
- if (pg->outstanding_connects > pg->max_outstanding_connections)
+ if ((pg->outstanding_connects > pg->max_outstanding_connections) ||
(pg->stop_connects == GNUNET_YES))
{
#if VERBOSE_TESTING > 2
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -4443,6 +4449,26 @@
}
/**
+ * Stop the connection process temporarily.
+ *
+ * @param pg the peer group to stop connecting
+ */
+void GNUNET_TESTING_stop_connections(struct GNUNET_TESTING_PeerGroup *pg)
+{
+ pg->stop_connects = GNUNET_YES;
+}
+
+/**
+ * Resume the connection process temporarily.
+ *
+ * @param pg the peer group to resume connecting
+ */
+void GNUNET_TESTING_resume_connections(struct GNUNET_TESTING_PeerGroup *pg)
+{
+ pg->stop_connects = GNUNET_NO;
+}
+
+/**
* There are many ways to connect peers that are supported by this function.
* To connect peers in the same topology that was created via the
* GNUNET_TESTING_create_topology, the topology variable must be set to
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r14440 - in gnunet/src: dht include testing,
gnunet <=