diff options
author | Nathan S. Evans <evans@in.tum.de> | 2011-01-31 18:37:40 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2011-01-31 18:37:40 +0000 |
commit | b956a89cf9ad37967e03bb9d4b5fc67f496378da (patch) | |
tree | b99c3ea8619439510d5a6f973c5d5999601f205d /src/testing/testing_group.c | |
parent | bfc8770d09eabc6a94370e25d66f41bf30da030d (diff) | |
download | gnunet-b956a89cf9ad37967e03bb9d4b5fc67f496378da.tar.gz gnunet-b956a89cf9ad37967e03bb9d4b5fc67f496378da.zip |
bart fix for my crappy code
Diffstat (limited to 'src/testing/testing_group.c')
-rw-r--r-- | src/testing/testing_group.c | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index af17d27c7..6505ebc4c 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c | |||
@@ -55,6 +55,9 @@ | |||
55 | 55 | ||
56 | #define MAX_OUTSTANDING_CONNECTIONS 200 | 56 | #define MAX_OUTSTANDING_CONNECTIONS 200 |
57 | 57 | ||
58 | /* Maximum time to delay connect attempt */ | ||
59 | #define MAX_CONNECT_DELAY 300 | ||
60 | |||
58 | #define MAX_CONCURRENT_HOSTKEYS 500 | 61 | #define MAX_CONCURRENT_HOSTKEYS 500 |
59 | 62 | ||
60 | #define MAX_CONCURRENT_STARTING 200 | 63 | #define MAX_CONCURRENT_STARTING 200 |
@@ -696,6 +699,11 @@ struct ConnectContext | |||
696 | * Higher level topology connection context. | 699 | * Higher level topology connection context. |
697 | */ | 700 | */ |
698 | struct ConnectTopologyContext *ct_ctx; | 701 | struct ConnectTopologyContext *ct_ctx; |
702 | |||
703 | /** | ||
704 | * Whether this connection has been accounted for in the schedule_connect call. | ||
705 | */ | ||
706 | int counted; | ||
699 | }; | 707 | }; |
700 | 708 | ||
701 | struct UnblacklistContext | 709 | struct UnblacklistContext |
@@ -835,6 +843,13 @@ uid_from_hash (const GNUNET_HashCode * hash, uint32_t * uid) | |||
835 | static int outstanding_connects; | 843 | static int outstanding_connects; |
836 | 844 | ||
837 | /** | 845 | /** |
846 | * Number of connects we have scheduled at the same | ||
847 | * time, the more we already have scheduled the longer | ||
848 | * we should wait before calling schedule_connect again. | ||
849 | */ | ||
850 | static int outstanding_scheduled_connects; | ||
851 | |||
852 | /** | ||
838 | * Get a topology from a string input. | 853 | * Get a topology from a string input. |
839 | * | 854 | * |
840 | * @param topology where to write the retrieved topology | 855 | * @param topology where to write the retrieved topology |
@@ -1819,7 +1834,11 @@ create_small_world (struct GNUNET_TESTING_PeerGroup *pg, | |||
1819 | connect_attempts += proc (pg, i, nodeToConnect, list); | 1834 | connect_attempts += proc (pg, i, nodeToConnect, list); |
1820 | 1835 | ||
1821 | if (i < cols) | 1836 | if (i < cols) |
1822 | nodeToConnect = (rows * cols) - cols + i; | 1837 | { |
1838 | nodeToConnect = (rows * cols) - cols + i; | ||
1839 | if (nodeToConnect >= pg->total) | ||
1840 | nodeToConnect -= cols; | ||
1841 | } | ||
1823 | else | 1842 | else |
1824 | nodeToConnect = i - cols; | 1843 | nodeToConnect = i - cols; |
1825 | 1844 | ||
@@ -2014,7 +2033,11 @@ create_2d_torus (struct GNUNET_TESTING_PeerGroup *pg, | |||
2014 | 2033 | ||
2015 | /* Second connect to the node immediately above */ | 2034 | /* Second connect to the node immediately above */ |
2016 | if (i < cols) | 2035 | if (i < cols) |
2017 | nodeToConnect = (rows * cols) - cols + i; | 2036 | { |
2037 | nodeToConnect = (rows * cols) - cols + i; | ||
2038 | if (nodeToConnect >= pg->total) | ||
2039 | nodeToConnect -= cols; | ||
2040 | } | ||
2018 | else | 2041 | else |
2019 | nodeToConnect = i - cols; | 2042 | nodeToConnect = i - cols; |
2020 | 2043 | ||
@@ -2826,8 +2849,14 @@ schedule_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2826 | _ | 2849 | _ |
2827 | ("Delaying connect, we have too many outstanding connections!\n")); | 2850 | ("Delaying connect, we have too many outstanding connections!\n")); |
2828 | #endif | 2851 | #endif |
2829 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 2852 | if (GNUNET_NO == connect_context->counted) |
2830 | (GNUNET_TIME_UNIT_MILLISECONDS, 100), | 2853 | { |
2854 | connect_context->counted = GNUNET_YES; | ||
2855 | outstanding_scheduled_connects++; | ||
2856 | } | ||
2857 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add (GNUNET_TIME_relative_multiply | ||
2858 | (GNUNET_TIME_UNIT_MILLISECONDS, 100), GNUNET_TIME_relative_multiply | ||
2859 | (GNUNET_TIME_UNIT_MILLISECONDS, outstanding_scheduled_connects * 2)), | ||
2831 | &schedule_connect, connect_context); | 2860 | &schedule_connect, connect_context); |
2832 | } | 2861 | } |
2833 | else | 2862 | else |
@@ -2838,6 +2867,7 @@ schedule_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2838 | outstanding_connects); | 2867 | outstanding_connects); |
2839 | #endif | 2868 | #endif |
2840 | outstanding_connects++; | 2869 | outstanding_connects++; |
2870 | outstanding_scheduled_connects--; | ||
2841 | GNUNET_TESTING_daemons_connect (connect_context->first, | 2871 | GNUNET_TESTING_daemons_connect (connect_context->first, |
2842 | connect_context->second, | 2872 | connect_context->second, |
2843 | CONNECT_TIMEOUT, | 2873 | CONNECT_TIMEOUT, |
@@ -3012,7 +3042,14 @@ connect_topology (struct GNUNET_TESTING_PeerGroup *pg, | |||
3012 | connect_context->first = pg->peers[pg_iter].daemon; | 3042 | connect_context->first = pg->peers[pg_iter].daemon; |
3013 | connect_context->second = pg->peers[connection_iter->index].daemon; | 3043 | connect_context->second = pg->peers[connection_iter->index].daemon; |
3014 | connect_context->ct_ctx = ct_ctx; | 3044 | connect_context->ct_ctx = ct_ctx; |
3015 | GNUNET_SCHEDULER_add_now (&schedule_connect, connect_context); | 3045 | if (total < MAX_OUTSTANDING_CONNECTIONS) |
3046 | { | ||
3047 | GNUNET_SCHEDULER_add_now (&schedule_connect, connect_context); | ||
3048 | } | ||
3049 | else | ||
3050 | { | ||
3051 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 1000 * (total / MAX_OUTSTANDING_CONNECTIONS)), &schedule_connect, connect_context); | ||
3052 | } | ||
3016 | connection_iter = connection_iter->next; | 3053 | connection_iter = connection_iter->next; |
3017 | total++; | 3054 | total++; |
3018 | } | 3055 | } |