diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-07-23 14:37:37 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-07-23 14:37:37 +0000 |
commit | 49fb611b2c5c7e438318356a675d8da99e52d739 (patch) | |
tree | 752c5ea5de6647dc8ee7df0712e8aa876f12800b /src/nse/test_nse_multipeer.c | |
parent | fdd29c5663f10fadca628793e72ef9d56a9d2fe6 (diff) | |
download | gnunet-49fb611b2c5c7e438318356a675d8da99e52d739.tar.gz gnunet-49fb611b2c5c7e438318356a675d8da99e52d739.zip |
fixes
Diffstat (limited to 'src/nse/test_nse_multipeer.c')
-rw-r--r-- | src/nse/test_nse_multipeer.c | 62 |
1 files changed, 42 insertions, 20 deletions
diff --git a/src/nse/test_nse_multipeer.c b/src/nse/test_nse_multipeer.c index 2f538b62c..bfd7741b1 100644 --- a/src/nse/test_nse_multipeer.c +++ b/src/nse/test_nse_multipeer.c | |||
@@ -66,13 +66,15 @@ static struct GNUNET_TESTING_PeerGroup *pg; | |||
66 | /** | 66 | /** |
67 | * Check whether peers successfully shut down. | 67 | * Check whether peers successfully shut down. |
68 | */ | 68 | */ |
69 | void | 69 | static void |
70 | shutdown_callback (void *cls, const char *emsg) | 70 | shutdown_callback (void *cls, const char *emsg) |
71 | { | 71 | { |
72 | if (emsg != NULL) | 72 | if (emsg != NULL) |
73 | { | 73 | { |
74 | #if VERBOSE | 74 | #if VERBOSE |
75 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown of peers failed!\n"); | 75 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
76 | "Shutdown of peers failed: %s!\n", | ||
77 | emsg); | ||
76 | #endif | 78 | #endif |
77 | if (ok == 0) | 79 | if (ok == 0) |
78 | ok = 666; | 80 | ok = 666; |
@@ -119,9 +121,17 @@ static void | |||
119 | handle_estimate (void *cls, double estimate, double std_dev) | 121 | handle_estimate (void *cls, double estimate, double std_dev) |
120 | { | 122 | { |
121 | struct NSEPeer *peer = cls; | 123 | struct NSEPeer *peer = cls; |
122 | fprintf(stderr, "Received network size estimate from peer %s. Size: %f std.dev. %f\n", GNUNET_i2s(&peer->daemon->id), estimate, std_dev); | 124 | |
125 | fprintf (stderr, | ||
126 | "Received network size estimate from peer %s. logSize: %f std.dev. %f (%f/%u)\n", | ||
127 | GNUNET_i2s(&peer->daemon->id), | ||
128 | estimate, | ||
129 | std_dev, | ||
130 | GNUNET_NSE_log_estimate_to_n (estimate), | ||
131 | num_peers); | ||
123 | } | 132 | } |
124 | 133 | ||
134 | |||
125 | static void | 135 | static void |
126 | connect_nse_service (void *cls, | 136 | connect_nse_service (void *cls, |
127 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 137 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -135,13 +145,15 @@ connect_nse_service (void *cls, | |||
135 | { | 145 | { |
136 | current_peer = GNUNET_malloc(sizeof(struct NSEPeer)); | 146 | current_peer = GNUNET_malloc(sizeof(struct NSEPeer)); |
137 | current_peer->daemon = GNUNET_TESTING_daemon_get(pg, i); | 147 | current_peer->daemon = GNUNET_TESTING_daemon_get(pg, i); |
138 | current_peer->nse_handle = GNUNET_NSE_connect (current_peer->daemon->cfg, &handle_estimate, current_peer); | 148 | current_peer->nse_handle = GNUNET_NSE_connect (current_peer->daemon->cfg, |
149 | &handle_estimate, | ||
150 | current_peer); | ||
139 | GNUNET_assert(current_peer->nse_handle != NULL); | 151 | GNUNET_assert(current_peer->nse_handle != NULL); |
140 | |||
141 | GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, current_peer); | 152 | GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, current_peer); |
142 | } | 153 | } |
143 | } | 154 | } |
144 | 155 | ||
156 | |||
145 | static void | 157 | static void |
146 | my_cb (void *cls, | 158 | my_cb (void *cls, |
147 | const char *emsg) | 159 | const char *emsg) |
@@ -159,13 +171,15 @@ my_cb (void *cls, | |||
159 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 171 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
160 | "Peer Group started successfully, connecting to NSE service for each peer!\n"); | 172 | "Peer Group started successfully, connecting to NSE service for each peer!\n"); |
161 | #endif | 173 | #endif |
162 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Have %u connections\n", total_connections); | 174 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
175 | "Have %u connections\n", total_connections); | ||
163 | 176 | ||
164 | GNUNET_SCHEDULER_add_now(&connect_nse_service, NULL); | 177 | GNUNET_SCHEDULER_add_now(&connect_nse_service, NULL); |
165 | } | 178 | } |
166 | 179 | ||
180 | |||
167 | /** | 181 | /** |
168 | * Prototype of a function that will be called whenever | 182 | * Function that will be called whenever |
169 | * two daemons are connected by the testing library. | 183 | * two daemons are connected by the testing library. |
170 | * | 184 | * |
171 | * @param cls closure | 185 | * @param cls closure |
@@ -178,15 +192,16 @@ my_cb (void *cls, | |||
178 | * @param second_daemon handle for the second daemon | 192 | * @param second_daemon handle for the second daemon |
179 | * @param emsg error message (NULL on success) | 193 | * @param emsg error message (NULL on success) |
180 | */ | 194 | */ |
181 | void connect_cb (void *cls, | 195 | static void |
182 | const struct GNUNET_PeerIdentity *first, | 196 | connect_cb (void *cls, |
183 | const struct GNUNET_PeerIdentity *second, | 197 | const struct GNUNET_PeerIdentity *first, |
184 | uint32_t distance, | 198 | const struct GNUNET_PeerIdentity *second, |
185 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, | 199 | uint32_t distance, |
186 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, | 200 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, |
187 | struct GNUNET_TESTING_Daemon *first_daemon, | 201 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, |
188 | struct GNUNET_TESTING_Daemon *second_daemon, | 202 | struct GNUNET_TESTING_Daemon *first_daemon, |
189 | const char *emsg) | 203 | struct GNUNET_TESTING_Daemon *second_daemon, |
204 | const char *emsg) | ||
190 | { | 205 | { |
191 | char *second_id; | 206 | char *second_id; |
192 | 207 | ||
@@ -207,16 +222,22 @@ run (void *cls, | |||
207 | { | 222 | { |
208 | struct GNUNET_CONFIGURATION_Handle *testing_cfg; | 223 | struct GNUNET_CONFIGURATION_Handle *testing_cfg; |
209 | unsigned long long total_peers; | 224 | unsigned long long total_peers; |
225 | |||
210 | ok = 1; | 226 | ok = 1; |
211 | testing_cfg = GNUNET_CONFIGURATION_create(); | 227 | testing_cfg = GNUNET_CONFIGURATION_create(); |
212 | GNUNET_assert(GNUNET_OK == GNUNET_CONFIGURATION_load(testing_cfg, cfgfile)); | 228 | GNUNET_assert(GNUNET_OK == GNUNET_CONFIGURATION_load(testing_cfg, cfgfile)); |
229 | |||
213 | #if VERBOSE | 230 | #if VERBOSE |
214 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n"); | 231 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n"); |
215 | GNUNET_CONFIGURATION_set_value_string (testing_cfg, "testing", | 232 | GNUNET_CONFIGURATION_set_value_string (testing_cfg, |
216 | "use_progressbars", | 233 | "testing", |
217 | "YES"); | 234 | "use_progressbars", |
235 | "YES"); | ||
218 | #endif | 236 | #endif |
219 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, "testing", "num_peers", &total_peers)) | 237 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, |
238 | "testing", | ||
239 | "num_peers", | ||
240 | &total_peers)) | ||
220 | total_peers = NUM_PEERS; | 241 | total_peers = NUM_PEERS; |
221 | 242 | ||
222 | peers_left = total_peers; | 243 | peers_left = total_peers; |
@@ -231,6 +252,7 @@ run (void *cls, | |||
231 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &shutdown_task, NULL); | 252 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &shutdown_task, NULL); |
232 | } | 253 | } |
233 | 254 | ||
255 | |||
234 | static int | 256 | static int |
235 | check () | 257 | check () |
236 | { | 258 | { |