aboutsummaryrefslogtreecommitdiff
path: root/src/dht
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2011-02-17 13:29:47 +0000
committerNathan S. Evans <evans@in.tum.de>2011-02-17 13:29:47 +0000
commit0d95267569574f8381791e913e0ac6abf6d1e38b (patch)
treeae5ef862764bcb1a8dafb49fb927d42bd98323bf /src/dht
parentfe87e6648752f01771f571ef6dc7cae7de4ae66e (diff)
downloadgnunet-0d95267569574f8381791e913e0ac6abf6d1e38b.tar.gz
gnunet-0d95267569574f8381791e913e0ac6abf6d1e38b.zip
Allow testing connection process to be stopped when asked.
Diffstat (limited to 'src/dht')
-rw-r--r--src/dht/gnunet-dht-driver.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/dht/gnunet-dht-driver.c b/src/dht/gnunet-dht-driver.c
index 14c119ff9..07cbf7981 100644
--- a/src/dht/gnunet-dht-driver.c
+++ b/src/dht/gnunet-dht-driver.c
@@ -716,6 +716,11 @@ static unsigned int total_connections;
716static unsigned int previous_connections; 716static unsigned int previous_connections;
717 717
718/** 718/**
719 * For counting failed connections during some duration.
720 */
721static unsigned int previous_failed_connections;
722
723/**
719 * Global used to count how many failed connections we have 724 * Global used to count how many failed connections we have
720 * been notified about (how many times has topology_callback 725 * been notified about (how many times has topology_callback
721 * been called with failure?) 726 * been called with failure?)
@@ -2597,8 +2602,11 @@ topology_callback (void *cls,
2597 unsigned long long duration; 2602 unsigned long long duration;
2598 unsigned long long total_duration; 2603 unsigned long long total_duration;
2599 unsigned int new_connections; 2604 unsigned int new_connections;
2605 unsigned int new_failed_connections;
2600 float conns_per_sec_recent; 2606 float conns_per_sec_recent;
2601 float conns_per_sec_total; 2607 float conns_per_sec_total;
2608 float failed_conns_per_sec_recent;
2609 float failed_conns_per_sec_total;
2602 2610
2603#if ONLY_TESTING 2611#if ONLY_TESTING
2604 if (repeat_connect_mode == GNUNET_YES) 2612 if (repeat_connect_mode == GNUNET_YES)
@@ -2615,26 +2623,40 @@ topology_callback (void *cls,
2615 repeat_connect_peer1 = NULL; 2623 repeat_connect_peer1 = NULL;
2616 repeat_connect_peer2 = NULL; 2624 repeat_connect_peer2 = NULL;
2617 repeat_connect_mode = GNUNET_NO; 2625 repeat_connect_mode = GNUNET_NO;
2626 GNUNET_TESTING_resume_connections(pg);
2627 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Resuming normal connection mode, debug connection was successful!\n");
2618 } 2628 }
2619 } 2629 }
2620 } 2630 }
2621#endif 2631#endif
2622 2632
2633
2634
2623 if (GNUNET_TIME_absolute_get_difference (connect_last_time, 2635 if (GNUNET_TIME_absolute_get_difference (connect_last_time,
2624 GNUNET_TIME_absolute_get()).rel_value > GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, CONN_UPDATE_DURATION).rel_value) 2636 GNUNET_TIME_absolute_get()).rel_value > GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, CONN_UPDATE_DURATION).rel_value)
2625 { 2637 {
2626 /* Get number of new connections */ 2638 /* Get number of new connections */
2627 new_connections = total_connections - previous_connections; 2639 new_connections = total_connections - previous_connections;
2640
2641 /* Get number of new FAILED connections */
2642 new_failed_connections = failed_connections - previous_failed_connections;
2643
2628 /* Get duration in seconds */ 2644 /* Get duration in seconds */
2629 duration = GNUNET_TIME_absolute_get_difference (connect_last_time, 2645 duration = GNUNET_TIME_absolute_get_difference (connect_last_time,
2630 GNUNET_TIME_absolute_get()).rel_value / 1000; 2646 GNUNET_TIME_absolute_get()).rel_value / 1000;
2631 total_duration = GNUNET_TIME_absolute_get_difference (connect_start_time, 2647 total_duration = GNUNET_TIME_absolute_get_difference (connect_start_time,
2632 GNUNET_TIME_absolute_get()).rel_value / 1000; 2648 GNUNET_TIME_absolute_get()).rel_value / 1000;
2649
2650 failed_conns_per_sec_recent = (float)new_failed_connections / duration;
2651 failed_conns_per_sec_total = (float)failed_connections / total_duration;
2633 conns_per_sec_recent = (float)new_connections / duration; 2652 conns_per_sec_recent = (float)new_connections / duration;
2634 conns_per_sec_total = (float)total_connections / total_duration; 2653 conns_per_sec_total = (float)total_connections / total_duration;
2635 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); 2654 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Recent: %f/s, Total: %f/s, Recent failed: %f/s, total failed %f/s\n",
2655 conns_per_sec_recent, CONN_UPDATE_DURATION, conns_per_sec_total,
2656 failed_conns_per_sec_recent, failed_conns_per_sec_total);
2636 connect_last_time = GNUNET_TIME_absolute_get(); 2657 connect_last_time = GNUNET_TIME_absolute_get();
2637 previous_connections = total_connections; 2658 previous_connections = total_connections;
2659 previous_failed_connections = failed_connections;
2638 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "have %u total_connections\n", total_connections); 2660 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "have %u total_connections\n", total_connections);
2639#if ONLY_TESTING 2661#if ONLY_TESTING
2640 /* These conditions likely mean we've entered the death spiral of doom */ 2662 /* These conditions likely mean we've entered the death spiral of doom */
@@ -2645,11 +2667,12 @@ topology_callback (void *cls,
2645 (repeat_connect_mode == GNUNET_NO)) 2667 (repeat_connect_mode == GNUNET_NO))
2646 { 2668 {
2647 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Entering repeat connection attempt mode!\n"); 2669 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Entering repeat connection attempt mode!\n");
2648
2649 repeat_connect_peer1 = first_daemon; 2670 repeat_connect_peer1 = first_daemon;
2650 repeat_connect_peer2 = second_daemon; 2671 repeat_connect_peer2 = second_daemon;
2651 repeat_connect_mode = GNUNET_YES; 2672 repeat_connect_mode = GNUNET_YES;
2652 repeat_connect_task = GNUNET_SCHEDULER_add_now(&repeat_connect, NULL); 2673 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Stopping NEW connections from being scheduled!\n");
2674 GNUNET_TESTING_stop_connections(pg);
2675 repeat_connect_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 60), &repeat_connect, NULL);
2653 } 2676 }
2654 2677
2655#endif 2678#endif
@@ -2667,10 +2690,11 @@ topology_callback (void *cls,
2667 else 2690 else
2668 { 2691 {
2669 failed_connections++; 2692 failed_connections++;
2693#if VERBOSE
2670 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to connect peer %s to peer %s with error :\n%s\n", 2694 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to connect peer %s to peer %s with error :\n%s\n",
2671 first_daemon->shortname, 2695 first_daemon->shortname,
2672 second_daemon->shortname, emsg); 2696 second_daemon->shortname, emsg);
2673#if VERBOSE 2697
2674 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to connect peer %s to peer %s with error :\n%s\n", 2698 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to connect peer %s to peer %s with error :\n%s\n",
2675 first_daemon->shortname, 2699 first_daemon->shortname,
2676 second_daemon->shortname, emsg); 2700 second_daemon->shortname, emsg);