diff options
Diffstat (limited to 'src/testing/testing_peergroup.c')
-rw-r--r-- | src/testing/testing_peergroup.c | 849 |
1 files changed, 439 insertions, 410 deletions
diff --git a/src/testing/testing_peergroup.c b/src/testing/testing_peergroup.c index fa2173f20..e81e9fad8 100644 --- a/src/testing/testing_peergroup.c +++ b/src/testing/testing_peergroup.c | |||
@@ -166,18 +166,19 @@ struct ProgressMeter | |||
166 | * @return the progress meter | 166 | * @return the progress meter |
167 | */ | 167 | */ |
168 | static struct ProgressMeter * | 168 | static struct ProgressMeter * |
169 | create_meter(unsigned int total, char * start_string, int print) | 169 | create_meter (unsigned int total, char *start_string, int print) |
170 | { | 170 | { |
171 | struct ProgressMeter *ret; | 171 | struct ProgressMeter *ret; |
172 | ret = GNUNET_malloc(sizeof(struct ProgressMeter)); | 172 | |
173 | ret = GNUNET_malloc (sizeof (struct ProgressMeter)); | ||
173 | ret->print = print; | 174 | ret->print = print; |
174 | ret->total = total; | 175 | ret->total = total; |
175 | ret->modnum = total / 4; | 176 | ret->modnum = total / 4; |
176 | ret->dotnum = (total / 50) + 1; | 177 | ret->dotnum = (total / 50) + 1; |
177 | if (start_string != NULL) | 178 | if (start_string != NULL) |
178 | ret->startup_string = GNUNET_strdup(start_string); | 179 | ret->startup_string = GNUNET_strdup (start_string); |
179 | else | 180 | else |
180 | ret->startup_string = GNUNET_strdup(""); | 181 | ret->startup_string = GNUNET_strdup (""); |
181 | 182 | ||
182 | return ret; | 183 | return ret; |
183 | } | 184 | } |
@@ -191,27 +192,27 @@ create_meter(unsigned int total, char * start_string, int print) | |||
191 | * GNUNET_NO if more items expected | 192 | * GNUNET_NO if more items expected |
192 | */ | 193 | */ |
193 | static int | 194 | static int |
194 | update_meter(struct ProgressMeter *meter) | 195 | update_meter (struct ProgressMeter *meter) |
195 | { | 196 | { |
196 | if (meter->print == GNUNET_YES) | 197 | if (meter->print == GNUNET_YES) |
198 | { | ||
199 | if (meter->completed % meter->modnum == 0) | ||
197 | { | 200 | { |
198 | if (meter->completed % meter->modnum == 0) | 201 | if (meter->completed == 0) |
199 | { | 202 | { |
200 | if (meter->completed == 0) | 203 | fprintf (stdout, "%sProgress: [0%%", meter->startup_string); |
201 | { | 204 | } |
202 | fprintf (stdout, "%sProgress: [0%%", meter->startup_string); | 205 | else |
203 | } | 206 | fprintf (stdout, "%d%%", (int) (((float) meter->completed |
204 | else | 207 | / meter->total) * 100)); |
205 | fprintf (stdout, "%d%%", (int) (((float) meter->completed | ||
206 | / meter->total) * 100)); | ||
207 | } | ||
208 | else if (meter->completed % meter->dotnum == 0) | ||
209 | fprintf (stdout, "."); | ||
210 | |||
211 | if (meter->completed + 1 == meter->total) | ||
212 | fprintf (stdout, "%d%%]\n", 100); | ||
213 | fflush (stdout); | ||
214 | } | 208 | } |
209 | else if (meter->completed % meter->dotnum == 0) | ||
210 | fprintf (stdout, "."); | ||
211 | |||
212 | if (meter->completed + 1 == meter->total) | ||
213 | fprintf (stdout, "%d%%]\n", 100); | ||
214 | fflush (stdout); | ||
215 | } | ||
215 | meter->completed++; | 216 | meter->completed++; |
216 | 217 | ||
217 | if (meter->completed == meter->total) | 218 | if (meter->completed == meter->total) |
@@ -228,7 +229,7 @@ update_meter(struct ProgressMeter *meter) | |||
228 | * GNUNET_SYSERR on error | 229 | * GNUNET_SYSERR on error |
229 | */ | 230 | */ |
230 | static int | 231 | static int |
231 | reset_meter(struct ProgressMeter *meter) | 232 | reset_meter (struct ProgressMeter *meter) |
232 | { | 233 | { |
233 | if (meter == NULL) | 234 | if (meter == NULL) |
234 | return GNUNET_SYSERR; | 235 | return GNUNET_SYSERR; |
@@ -243,7 +244,7 @@ reset_meter(struct ProgressMeter *meter) | |||
243 | * @param meter the meter to free | 244 | * @param meter the meter to free |
244 | */ | 245 | */ |
245 | static void | 246 | static void |
246 | free_meter(struct ProgressMeter *meter) | 247 | free_meter (struct ProgressMeter *meter) |
247 | { | 248 | { |
248 | GNUNET_free_non_null (meter->startup_string); | 249 | GNUNET_free_non_null (meter->startup_string); |
249 | GNUNET_free (meter); | 250 | GNUNET_free (meter); |
@@ -256,13 +257,14 @@ free_meter(struct ProgressMeter *meter) | |||
256 | * Check whether peers successfully shut down. | 257 | * Check whether peers successfully shut down. |
257 | */ | 258 | */ |
258 | static void | 259 | static void |
259 | internal_shutdown_callback(void *cls, const char *emsg) | 260 | internal_shutdown_callback (void *cls, const char *emsg) |
260 | { | 261 | { |
261 | struct PeerGroupStartupContext *pg_start_ctx = cls; | 262 | struct PeerGroupStartupContext *pg_start_ctx = cls; |
263 | |||
262 | if (emsg != NULL) | 264 | if (emsg != NULL) |
263 | pg_start_ctx->peergroup_cb(pg_start_ctx->cls, emsg); | 265 | pg_start_ctx->peergroup_cb (pg_start_ctx->cls, emsg); |
264 | else | 266 | else |
265 | pg_start_ctx->peergroup_cb(pg_start_ctx->cls, pg_start_ctx->fail_reason); | 267 | pg_start_ctx->peergroup_cb (pg_start_ctx->cls, pg_start_ctx->fail_reason); |
266 | } | 268 | } |
267 | 269 | ||
268 | /** | 270 | /** |
@@ -271,13 +273,18 @@ internal_shutdown_callback(void *cls, const char *emsg) | |||
271 | * test. | 273 | * test. |
272 | */ | 274 | */ |
273 | static void | 275 | static void |
274 | end_badly(void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | 276 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
275 | { | 277 | { |
276 | struct PeerGroupStartupContext *pg_start_ctx = cls; | 278 | struct PeerGroupStartupContext *pg_start_ctx = cls; |
277 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failing peer group startup with error: `%s'!\n", | 279 | |
280 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
281 | "Failing peer group startup with error: `%s'!\n", | ||
278 | pg_start_ctx->fail_reason); | 282 | pg_start_ctx->fail_reason); |
279 | 283 | ||
280 | GNUNET_TESTING_daemons_stop (pg_start_ctx->pg, GNUNET_TIME_absolute_get_remaining(pg_start_ctx->timeout), &internal_shutdown_callback, pg_start_ctx); | 284 | GNUNET_TESTING_daemons_stop (pg_start_ctx->pg, |
285 | GNUNET_TIME_absolute_get_remaining | ||
286 | (pg_start_ctx->timeout), | ||
287 | &internal_shutdown_callback, pg_start_ctx); | ||
281 | 288 | ||
282 | if (pg_start_ctx->hostkey_meter != NULL) | 289 | if (pg_start_ctx->hostkey_meter != NULL) |
283 | free_meter (pg_start_ctx->hostkey_meter); | 290 | free_meter (pg_start_ctx->hostkey_meter); |
@@ -297,21 +304,22 @@ end_badly(void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
297 | * failure (peers failed to connect). | 304 | * failure (peers failed to connect). |
298 | */ | 305 | */ |
299 | static void | 306 | static void |
300 | internal_topology_callback( | 307 | internal_topology_callback (void *cls, |
301 | void *cls, | 308 | const struct GNUNET_PeerIdentity *first, |
302 | const struct GNUNET_PeerIdentity *first, | 309 | const struct GNUNET_PeerIdentity *second, |
303 | const struct GNUNET_PeerIdentity *second, | 310 | uint32_t distance, |
304 | uint32_t distance, | 311 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, |
305 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, | 312 | const struct GNUNET_CONFIGURATION_Handle |
306 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, | 313 | *second_cfg, |
307 | struct GNUNET_TESTING_Daemon *first_daemon, | 314 | struct GNUNET_TESTING_Daemon *first_daemon, |
308 | struct GNUNET_TESTING_Daemon *second_daemon, | 315 | struct GNUNET_TESTING_Daemon *second_daemon, |
309 | const char *emsg) | 316 | const char *emsg) |
310 | { | 317 | { |
311 | struct PeerGroupStartupContext *pg_start_ctx = cls; | 318 | struct PeerGroupStartupContext *pg_start_ctx = cls; |
312 | char *temp_str; | 319 | char *temp_str; |
313 | char *second_str; | 320 | char *second_str; |
314 | int temp; | 321 | int temp; |
322 | |||
315 | #if TIMING | 323 | #if TIMING |
316 | unsigned long long duration; | 324 | unsigned long long duration; |
317 | unsigned long long total_duration; | 325 | unsigned long long total_duration; |
@@ -325,201 +333,201 @@ internal_topology_callback( | |||
325 | 333 | ||
326 | #if TIMING | 334 | #if TIMING |
327 | if (GNUNET_TIME_absolute_get_difference (connect_last_time, | 335 | if (GNUNET_TIME_absolute_get_difference (connect_last_time, |
328 | GNUNET_TIME_absolute_get ()).rel_value | 336 | GNUNET_TIME_absolute_get |
329 | > GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 337 | ()).rel_value > |
330 | CONN_UPDATE_DURATION).rel_value) | 338 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
331 | { | 339 | CONN_UPDATE_DURATION).rel_value) |
332 | /* Get number of new connections */ | 340 | { |
333 | new_connections = total_connections - previous_connections; | 341 | /* Get number of new connections */ |
334 | 342 | new_connections = total_connections - previous_connections; | |
335 | /* Get number of new FAILED connections */ | 343 | |
336 | new_failed_connections = failed_connections - previous_failed_connections; | 344 | /* Get number of new FAILED connections */ |
337 | 345 | new_failed_connections = failed_connections - previous_failed_connections; | |
338 | /* Get duration in seconds */ | 346 | |
339 | duration | 347 | /* Get duration in seconds */ |
340 | = GNUNET_TIME_absolute_get_difference (connect_last_time, | 348 | duration |
341 | GNUNET_TIME_absolute_get ()).rel_value | 349 | = GNUNET_TIME_absolute_get_difference (connect_last_time, |
342 | / 1000; | 350 | GNUNET_TIME_absolute_get |
343 | total_duration | 351 | ()).rel_value / 1000; |
344 | = GNUNET_TIME_absolute_get_difference (connect_start_time, | 352 | total_duration = |
345 | GNUNET_TIME_absolute_get ()).rel_value | 353 | GNUNET_TIME_absolute_get_difference (connect_start_time, |
346 | / 1000; | 354 | GNUNET_TIME_absolute_get |
347 | 355 | ()).rel_value / 1000; | |
348 | failed_conns_per_sec_recent = (double) new_failed_connections / duration; | 356 | |
349 | failed_conns_per_sec_total = (double) failed_connections / total_duration; | 357 | failed_conns_per_sec_recent = (double) new_failed_connections / duration; |
350 | conns_per_sec_recent = (double) new_connections / duration; | 358 | failed_conns_per_sec_total = (double) failed_connections / total_duration; |
351 | conns_per_sec_total = (double) total_connections / total_duration; | 359 | conns_per_sec_recent = (double) new_connections / duration; |
352 | GNUNET_log ( | 360 | conns_per_sec_total = (double) total_connections / total_duration; |
353 | GNUNET_ERROR_TYPE_WARNING, | 361 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
354 | "Recent: %.2f/s, Total: %.2f/s, Recent failed: %.2f/s, total failed %.2f/s\n", | 362 | "Recent: %.2f/s, Total: %.2f/s, Recent failed: %.2f/s, total failed %.2f/s\n", |
355 | conns_per_sec_recent, CONN_UPDATE_DURATION, | 363 | conns_per_sec_recent, CONN_UPDATE_DURATION, |
356 | conns_per_sec_total, failed_conns_per_sec_recent, | 364 | conns_per_sec_total, failed_conns_per_sec_recent, |
357 | failed_conns_per_sec_total); | 365 | failed_conns_per_sec_total); |
358 | connect_last_time = GNUNET_TIME_absolute_get (); | 366 | connect_last_time = GNUNET_TIME_absolute_get (); |
359 | previous_connections = total_connections; | 367 | previous_connections = total_connections; |
360 | previous_failed_connections = failed_connections; | 368 | previous_failed_connections = failed_connections; |
361 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 369 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
362 | "have %u total_connections, %u failed\n", total_connections, | 370 | "have %u total_connections, %u failed\n", total_connections, |
363 | failed_connections); | 371 | failed_connections); |
364 | } | 372 | } |
365 | #endif | 373 | #endif |
366 | 374 | ||
367 | 375 | ||
368 | if (emsg == NULL) | 376 | if (emsg == NULL) |
369 | { | 377 | { |
370 | pg_start_ctx->total_connections++; | 378 | pg_start_ctx->total_connections++; |
371 | #if VERBOSE > 1 | 379 | #if VERBOSE > 1 |
372 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "connected peer %s to peer %s, distance %u\n", | 380 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
373 | first_daemon->shortname, | 381 | "connected peer %s to peer %s, distance %u\n", |
374 | second_daemon->shortname, | 382 | first_daemon->shortname, second_daemon->shortname, distance); |
375 | distance); | ||
376 | #endif | 383 | #endif |
377 | if (pg_start_ctx->topology_output_file != NULL) | 384 | if (pg_start_ctx->topology_output_file != NULL) |
378 | { | 385 | { |
379 | second_str = GNUNET_strdup(GNUNET_i2s(second)); | 386 | second_str = GNUNET_strdup (GNUNET_i2s (second)); |
380 | temp = GNUNET_asprintf(&temp_str, "\t\"%s\" -- \"%s\"\n", GNUNET_i2s(first), second_str); | 387 | temp = |
381 | GNUNET_free(second_str); | 388 | GNUNET_asprintf (&temp_str, "\t\"%s\" -- \"%s\"\n", |
382 | if (temp > 0) | 389 | GNUNET_i2s (first), second_str); |
383 | GNUNET_DISK_file_write(pg_start_ctx->topology_output_file, temp_str, temp); | 390 | GNUNET_free (second_str); |
384 | GNUNET_free(temp_str); | 391 | if (temp > 0) |
385 | } | 392 | GNUNET_DISK_file_write (pg_start_ctx->topology_output_file, temp_str, |
393 | temp); | ||
394 | GNUNET_free (temp_str); | ||
386 | } | 395 | } |
396 | } | ||
387 | else | 397 | else |
388 | { | 398 | { |
389 | pg_start_ctx->failed_connections++; | 399 | pg_start_ctx->failed_connections++; |
390 | #if VERBOSE | 400 | #if VERBOSE |
391 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to connect peer %s to peer %s with error :\n%s\n", | 401 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
392 | first_daemon->shortname, | 402 | "Failed to connect peer %s to peer %s with error :\n%s\n", |
393 | second_daemon->shortname, emsg); | 403 | first_daemon->shortname, second_daemon->shortname, emsg); |
394 | 404 | ||
395 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to connect peer %s to peer %s with error :\n%s\n", | 405 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
396 | first_daemon->shortname, | 406 | "Failed to connect peer %s to peer %s with error :\n%s\n", |
397 | second_daemon->shortname, emsg); | 407 | first_daemon->shortname, second_daemon->shortname, emsg); |
398 | #endif | 408 | #endif |
399 | } | 409 | } |
400 | 410 | ||
401 | GNUNET_assert(pg_start_ctx->connect_meter != NULL); | 411 | GNUNET_assert (pg_start_ctx->connect_meter != NULL); |
402 | if (pg_start_ctx->connect_cb != NULL) | 412 | if (pg_start_ctx->connect_cb != NULL) |
403 | pg_start_ctx->connect_cb(pg_start_ctx->cls, first, | 413 | pg_start_ctx->connect_cb (pg_start_ctx->cls, first, |
404 | second, | 414 | second, |
405 | distance, | 415 | distance, |
406 | first_cfg, | 416 | first_cfg, |
407 | second_cfg, | 417 | second_cfg, first_daemon, second_daemon, emsg); |
408 | first_daemon, | ||
409 | second_daemon, | ||
410 | emsg); | ||
411 | if (GNUNET_YES == update_meter (pg_start_ctx->connect_meter)) | 418 | if (GNUNET_YES == update_meter (pg_start_ctx->connect_meter)) |
412 | { | 419 | { |
413 | #if VERBOSE | 420 | #if VERBOSE |
414 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 421 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
415 | "Created %d total connections, which is our target number! Starting next phase of testing.\n", | 422 | "Created %d total connections, which is our target number! Starting next phase of testing.\n", |
416 | total_connections); | 423 | total_connections); |
417 | #endif | 424 | #endif |
418 | 425 | ||
419 | #if TIMING | 426 | #if TIMING |
420 | total_duration | 427 | total_duration |
421 | = GNUNET_TIME_absolute_get_difference (connect_start_time, | 428 | = GNUNET_TIME_absolute_get_difference (connect_start_time, |
422 | GNUNET_TIME_absolute_get ()).rel_value | 429 | GNUNET_TIME_absolute_get |
423 | / 1000; | 430 | ()).rel_value / 1000; |
424 | failed_conns_per_sec_total = (double) failed_connections / total_duration; | 431 | failed_conns_per_sec_total = (double) failed_connections / total_duration; |
425 | conns_per_sec_total = (double) total_connections / total_duration; | 432 | conns_per_sec_total = (double) total_connections / total_duration; |
426 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 433 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
427 | "Overall connection info --- Total: %u, Total Failed %u/s\n", | 434 | "Overall connection info --- Total: %u, Total Failed %u/s\n", |
428 | total_connections, failed_connections); | 435 | total_connections, failed_connections); |
429 | GNUNET_log ( | 436 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
430 | GNUNET_ERROR_TYPE_WARNING, | 437 | "Overall connection info --- Total: %.2f/s, Total Failed %.2f/s\n", |
431 | "Overall connection info --- Total: %.2f/s, Total Failed %.2f/s\n", | 438 | conns_per_sec_total, failed_conns_per_sec_total); |
432 | conns_per_sec_total, failed_conns_per_sec_total); | ||
433 | #endif | 439 | #endif |
434 | 440 | ||
435 | GNUNET_assert(pg_start_ctx->die_task != GNUNET_SCHEDULER_NO_TASK); | 441 | GNUNET_assert (pg_start_ctx->die_task != GNUNET_SCHEDULER_NO_TASK); |
436 | GNUNET_SCHEDULER_cancel (pg_start_ctx->die_task); | 442 | GNUNET_SCHEDULER_cancel (pg_start_ctx->die_task); |
437 | 443 | ||
438 | /* Call final callback, signifying that the peer group has been started and connected */ | 444 | /* Call final callback, signifying that the peer group has been started and connected */ |
439 | if (pg_start_ctx->peergroup_cb != NULL) | 445 | if (pg_start_ctx->peergroup_cb != NULL) |
440 | pg_start_ctx->peergroup_cb(pg_start_ctx->cls, NULL); | 446 | pg_start_ctx->peergroup_cb (pg_start_ctx->cls, NULL); |
441 | 447 | ||
442 | if (pg_start_ctx->topology_output_file != NULL) | 448 | if (pg_start_ctx->topology_output_file != NULL) |
443 | { | 449 | { |
444 | temp = GNUNET_asprintf(&temp_str, "}\n"); | 450 | temp = GNUNET_asprintf (&temp_str, "}\n"); |
445 | if (temp > 0) | 451 | if (temp > 0) |
446 | GNUNET_DISK_file_write(pg_start_ctx->topology_output_file, temp_str, temp); | 452 | GNUNET_DISK_file_write (pg_start_ctx->topology_output_file, temp_str, |
447 | GNUNET_free(temp_str); | 453 | temp); |
448 | GNUNET_DISK_file_close(pg_start_ctx->topology_output_file); | 454 | GNUNET_free (temp_str); |
449 | } | 455 | GNUNET_DISK_file_close (pg_start_ctx->topology_output_file); |
450 | } | 456 | } |
457 | } | ||
451 | } | 458 | } |
452 | 459 | ||
453 | static void | 460 | static void |
454 | internal_peers_started_callback(void *cls, const struct GNUNET_PeerIdentity *id, | 461 | internal_peers_started_callback (void *cls, |
455 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 462 | const struct GNUNET_PeerIdentity *id, |
456 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | 463 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
464 | struct GNUNET_TESTING_Daemon *d, | ||
465 | const char *emsg) | ||
457 | { | 466 | { |
458 | struct PeerGroupStartupContext *pg_start_ctx = cls; | 467 | struct PeerGroupStartupContext *pg_start_ctx = cls; |
468 | |||
459 | if (emsg != NULL) | 469 | if (emsg != NULL) |
460 | { | 470 | { |
461 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 471 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
462 | "Failed to start daemon with error: `%s'\n", emsg); | 472 | "Failed to start daemon with error: `%s'\n", emsg); |
463 | return; | 473 | return; |
464 | } | 474 | } |
465 | GNUNET_assert (id != NULL); | 475 | GNUNET_assert (id != NULL); |
466 | 476 | ||
467 | #if VERBOSE > 1 | 477 | #if VERBOSE > 1 |
468 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Started daemon %llu out of %llu\n", | 478 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Started daemon %llu out of %llu\n", |
469 | (num_peers - peers_left) + 1, num_peers); | 479 | (num_peers - peers_left) + 1, num_peers); |
470 | #endif | 480 | #endif |
471 | 481 | ||
472 | pg_start_ctx->peers_left--; | 482 | pg_start_ctx->peers_left--; |
473 | 483 | ||
474 | if (GNUNET_YES == update_meter (pg_start_ctx->peer_start_meter)) | 484 | if (GNUNET_YES == update_meter (pg_start_ctx->peer_start_meter)) |
475 | { | 485 | { |
476 | #if VERBOSE | 486 | #if VERBOSE |
477 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 487 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
478 | "All %d daemons started, now connecting peers!\n", | 488 | "All %d daemons started, now connecting peers!\n", num_peers); |
479 | num_peers); | ||
480 | #endif | 489 | #endif |
481 | GNUNET_assert(pg_start_ctx->die_task != GNUNET_SCHEDULER_NO_TASK); | 490 | GNUNET_assert (pg_start_ctx->die_task != GNUNET_SCHEDULER_NO_TASK); |
482 | GNUNET_SCHEDULER_cancel (pg_start_ctx->die_task); | 491 | GNUNET_SCHEDULER_cancel (pg_start_ctx->die_task); |
492 | |||
493 | pg_start_ctx->expected_connections = UINT_MAX; | ||
494 | if ((pg_start_ctx->pg != NULL) && (pg_start_ctx->peers_left == 0)) | ||
495 | { | ||
496 | pg_start_ctx->connect_start_time = GNUNET_TIME_absolute_get (); | ||
497 | pg_start_ctx->expected_connections | ||
498 | = GNUNET_TESTING_connect_topology (pg_start_ctx->pg, | ||
499 | pg_start_ctx->connect_topology, | ||
500 | pg_start_ctx->connect_topology_option, | ||
501 | pg_start_ctx->connect_topology_option_modifier, | ||
502 | DEFAULT_CONNECT_TIMEOUT, | ||
503 | pg_start_ctx->connect_attempts, | ||
504 | NULL, NULL); | ||
505 | |||
506 | pg_start_ctx->connect_meter | ||
507 | = create_meter (pg_start_ctx->expected_connections, | ||
508 | "Peer connection ", pg_start_ctx->verbose); | ||
509 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
510 | "Have %d expected connections\n", | ||
511 | pg_start_ctx->expected_connections); | ||
512 | } | ||
483 | 513 | ||
484 | pg_start_ctx->expected_connections = UINT_MAX; | 514 | if (pg_start_ctx->expected_connections == 0) |
485 | if ((pg_start_ctx->pg != NULL) && (pg_start_ctx->peers_left == 0)) | 515 | { |
486 | { | 516 | GNUNET_free_non_null (pg_start_ctx->fail_reason); |
487 | pg_start_ctx->connect_start_time = GNUNET_TIME_absolute_get (); | 517 | pg_start_ctx->fail_reason = |
488 | pg_start_ctx->expected_connections | 518 | GNUNET_strdup ("from connect topology (bad return)"); |
489 | = GNUNET_TESTING_connect_topology ( | 519 | pg_start_ctx->die_task = |
490 | pg_start_ctx->pg, | 520 | GNUNET_SCHEDULER_add_now (&end_badly, pg_start_ctx); |
491 | pg_start_ctx->connect_topology, | ||
492 | pg_start_ctx->connect_topology_option, | ||
493 | pg_start_ctx->connect_topology_option_modifier, | ||
494 | DEFAULT_CONNECT_TIMEOUT, | ||
495 | pg_start_ctx->connect_attempts, | ||
496 | NULL, NULL); | ||
497 | |||
498 | pg_start_ctx->connect_meter | ||
499 | = create_meter (pg_start_ctx->expected_connections, | ||
500 | "Peer connection ", pg_start_ctx->verbose); | ||
501 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
502 | "Have %d expected connections\n", | ||
503 | pg_start_ctx->expected_connections); | ||
504 | } | ||
505 | |||
506 | if (pg_start_ctx->expected_connections == 0) | ||
507 | { | ||
508 | GNUNET_free_non_null(pg_start_ctx->fail_reason); | ||
509 | pg_start_ctx->fail_reason = GNUNET_strdup("from connect topology (bad return)"); | ||
510 | pg_start_ctx->die_task | ||
511 | = GNUNET_SCHEDULER_add_now (&end_badly, | ||
512 | pg_start_ctx); | ||
513 | } | ||
514 | |||
515 | GNUNET_free_non_null(pg_start_ctx->fail_reason); | ||
516 | pg_start_ctx->fail_reason = GNUNET_strdup("from connect topology (timeout)"); | ||
517 | pg_start_ctx->die_task | ||
518 | = GNUNET_SCHEDULER_add_delayed ( | ||
519 | GNUNET_TIME_absolute_get_remaining (pg_start_ctx->timeout), | ||
520 | &end_badly, | ||
521 | pg_start_ctx); | ||
522 | } | 521 | } |
522 | |||
523 | GNUNET_free_non_null (pg_start_ctx->fail_reason); | ||
524 | pg_start_ctx->fail_reason = | ||
525 | GNUNET_strdup ("from connect topology (timeout)"); | ||
526 | pg_start_ctx->die_task = | ||
527 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining | ||
528 | (pg_start_ctx->timeout), &end_badly, | ||
529 | pg_start_ctx); | ||
530 | } | ||
523 | } | 531 | } |
524 | 532 | ||
525 | /** | 533 | /** |
@@ -531,56 +539,61 @@ internal_peers_started_callback(void *cls, const struct GNUNET_PeerIdentity *id, | |||
531 | * @param emsg non-null on failure | 539 | * @param emsg non-null on failure |
532 | */ | 540 | */ |
533 | static void | 541 | static void |
534 | internal_hostkey_callback(void *cls, const struct GNUNET_PeerIdentity *id, | 542 | internal_hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id, |
535 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | 543 | struct GNUNET_TESTING_Daemon *d, const char *emsg) |
536 | { | 544 | { |
537 | struct PeerGroupStartupContext *pg_start_ctx = cls; | 545 | struct PeerGroupStartupContext *pg_start_ctx = cls; |
538 | unsigned int create_expected_connections; | 546 | unsigned int create_expected_connections; |
539 | 547 | ||
540 | if (emsg != NULL) | 548 | if (emsg != NULL) |
541 | { | 549 | { |
542 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 550 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
543 | "Hostkey callback received error: %s\n", emsg); | 551 | "Hostkey callback received error: %s\n", emsg); |
544 | } | 552 | } |
545 | 553 | ||
546 | #if VERBOSE > 1 | 554 | #if VERBOSE > 1 |
547 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 555 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
548 | "Hostkey (%d/%d) created for peer `%s'\n", | 556 | "Hostkey (%d/%d) created for peer `%s'\n", |
549 | num_peers - peers_left, num_peers, GNUNET_i2s(id)); | 557 | num_peers - peers_left, num_peers, GNUNET_i2s (id)); |
550 | #endif | 558 | #endif |
551 | 559 | ||
552 | pg_start_ctx->peers_left--; | 560 | pg_start_ctx->peers_left--; |
553 | if (GNUNET_YES == update_meter (pg_start_ctx->hostkey_meter)) | 561 | if (GNUNET_YES == update_meter (pg_start_ctx->hostkey_meter)) |
562 | { | ||
563 | GNUNET_SCHEDULER_cancel (pg_start_ctx->die_task); | ||
564 | /* Set up task in case topology creation doesn't finish | ||
565 | * within a reasonable amount of time */ | ||
566 | pg_start_ctx->die_task = | ||
567 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining | ||
568 | (pg_start_ctx->timeout), &end_badly, | ||
569 | "from create_topology"); | ||
570 | pg_start_ctx->peers_left = pg_start_ctx->total; /* Reset counter */ | ||
571 | create_expected_connections = | ||
572 | GNUNET_TESTING_create_topology (pg_start_ctx->pg, | ||
573 | pg_start_ctx->topology, | ||
574 | pg_start_ctx->restrict_topology, | ||
575 | pg_start_ctx->restrict_transports); | ||
576 | if (create_expected_connections > 0) | ||
577 | { | ||
578 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
579 | "Topology set up, have %u expected connections, now starting peers!\n", | ||
580 | create_expected_connections); | ||
581 | GNUNET_TESTING_daemons_continue_startup (pg_start_ctx->pg); | ||
582 | } | ||
583 | else | ||
554 | { | 584 | { |
555 | GNUNET_SCHEDULER_cancel (pg_start_ctx->die_task); | 585 | GNUNET_SCHEDULER_cancel (pg_start_ctx->die_task); |
556 | /* Set up task in case topology creation doesn't finish | 586 | pg_start_ctx->die_task = GNUNET_SCHEDULER_add_now (&end_badly, |
557 | * within a reasonable amount of time */ | 587 | "from create topology (bad return)"); |
558 | pg_start_ctx->die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining(pg_start_ctx->timeout), | ||
559 | &end_badly, | ||
560 | "from create_topology"); | ||
561 | pg_start_ctx->peers_left = pg_start_ctx->total; /* Reset counter */ | ||
562 | create_expected_connections = GNUNET_TESTING_create_topology (pg_start_ctx->pg, pg_start_ctx->topology, pg_start_ctx->restrict_topology, | ||
563 | pg_start_ctx->restrict_transports); | ||
564 | if (create_expected_connections > 0) | ||
565 | { | ||
566 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
567 | "Topology set up, have %u expected connections, now starting peers!\n", create_expected_connections); | ||
568 | GNUNET_TESTING_daemons_continue_startup (pg_start_ctx->pg); | ||
569 | } | ||
570 | else | ||
571 | { | ||
572 | GNUNET_SCHEDULER_cancel (pg_start_ctx->die_task); | ||
573 | pg_start_ctx->die_task = GNUNET_SCHEDULER_add_now (&end_badly, | ||
574 | "from create topology (bad return)"); | ||
575 | } | ||
576 | |||
577 | GNUNET_SCHEDULER_cancel (pg_start_ctx->die_task); | ||
578 | pg_start_ctx->die_task | ||
579 | = GNUNET_SCHEDULER_add_delayed ( | ||
580 | GNUNET_TIME_absolute_get_remaining(pg_start_ctx->timeout), | ||
581 | &end_badly, | ||
582 | "from continue startup (timeout)"); | ||
583 | } | 588 | } |
589 | |||
590 | GNUNET_SCHEDULER_cancel (pg_start_ctx->die_task); | ||
591 | pg_start_ctx->die_task | ||
592 | = | ||
593 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining | ||
594 | (pg_start_ctx->timeout), &end_badly, | ||
595 | "from continue startup (timeout)"); | ||
596 | } | ||
584 | } | 597 | } |
585 | 598 | ||
586 | 599 | ||
@@ -597,41 +610,42 @@ internal_hostkey_callback(void *cls, const struct GNUNET_PeerIdentity *id, | |||
597 | void | 610 | void |
598 | write_topology_cb (void *cls, | 611 | write_topology_cb (void *cls, |
599 | const struct GNUNET_PeerIdentity *first, | 612 | const struct GNUNET_PeerIdentity *first, |
600 | const struct GNUNET_PeerIdentity *second, | 613 | const struct GNUNET_PeerIdentity *second, const char *emsg) |
601 | const char *emsg) | ||
602 | { | 614 | { |
603 | struct TopologyOutputContext *topo_ctx; | 615 | struct TopologyOutputContext *topo_ctx; |
604 | int temp; | 616 | int temp; |
605 | char *temp_str; | 617 | char *temp_str; |
606 | char *temp_pid2; | 618 | char *temp_pid2; |
607 | 619 | ||
608 | topo_ctx = (struct TopologyOutputContext *)cls; | 620 | topo_ctx = (struct TopologyOutputContext *) cls; |
609 | GNUNET_assert(topo_ctx->file != NULL); | 621 | GNUNET_assert (topo_ctx->file != NULL); |
610 | if ((emsg == NULL) && (first != NULL) && (second != NULL)) | 622 | if ((emsg == NULL) && (first != NULL) && (second != NULL)) |
611 | { | 623 | { |
612 | GNUNET_assert(first != NULL); | 624 | GNUNET_assert (first != NULL); |
613 | GNUNET_assert(second != NULL); | 625 | GNUNET_assert (second != NULL); |
614 | temp_pid2 = GNUNET_strdup(GNUNET_i2s(second)); | 626 | temp_pid2 = GNUNET_strdup (GNUNET_i2s (second)); |
615 | temp = GNUNET_asprintf(&temp_str, "\t\"%s\" -- \"%s\"\n", GNUNET_i2s(first), temp_pid2); | 627 | temp = |
616 | GNUNET_free(temp_pid2); | 628 | GNUNET_asprintf (&temp_str, "\t\"%s\" -- \"%s\"\n", GNUNET_i2s (first), |
617 | GNUNET_DISK_file_write(topo_ctx->file, temp_str, temp); | 629 | temp_pid2); |
618 | } | 630 | GNUNET_free (temp_pid2); |
631 | GNUNET_DISK_file_write (topo_ctx->file, temp_str, temp); | ||
632 | } | ||
619 | else if ((emsg == NULL) && (first == NULL) && (second == NULL)) | 633 | else if ((emsg == NULL) && (first == NULL) && (second == NULL)) |
620 | { | 634 | { |
621 | temp = GNUNET_asprintf(&temp_str, "}\n"); | 635 | temp = GNUNET_asprintf (&temp_str, "}\n"); |
622 | GNUNET_DISK_file_write(topo_ctx->file, temp_str, temp); | 636 | GNUNET_DISK_file_write (topo_ctx->file, temp_str, temp); |
623 | GNUNET_DISK_file_close(topo_ctx->file); | 637 | GNUNET_DISK_file_close (topo_ctx->file); |
624 | topo_ctx->notify_cb(topo_ctx->notify_cb_cls, NULL); | 638 | topo_ctx->notify_cb (topo_ctx->notify_cb_cls, NULL); |
625 | GNUNET_free(topo_ctx); | 639 | GNUNET_free (topo_ctx); |
626 | } | 640 | } |
627 | else | 641 | else |
628 | { | 642 | { |
629 | temp = GNUNET_asprintf(&temp_str, "}\n"); | 643 | temp = GNUNET_asprintf (&temp_str, "}\n"); |
630 | GNUNET_DISK_file_write(topo_ctx->file, temp_str, temp); | 644 | GNUNET_DISK_file_write (topo_ctx->file, temp_str, temp); |
631 | GNUNET_DISK_file_close(topo_ctx->file); | 645 | GNUNET_DISK_file_close (topo_ctx->file); |
632 | topo_ctx->notify_cb(topo_ctx->notify_cb_cls, emsg); | 646 | topo_ctx->notify_cb (topo_ctx->notify_cb_cls, emsg); |
633 | GNUNET_free(topo_ctx); | 647 | GNUNET_free (topo_ctx); |
634 | } | 648 | } |
635 | } | 649 | } |
636 | 650 | ||
637 | /** | 651 | /** |
@@ -644,34 +658,37 @@ write_topology_cb (void *cls, | |||
644 | * | 658 | * |
645 | */ | 659 | */ |
646 | void | 660 | void |
647 | GNUNET_TESTING_peergroup_topology_to_file(struct GNUNET_TESTING_PeerGroup *pg, | 661 | GNUNET_TESTING_peergroup_topology_to_file (struct GNUNET_TESTING_PeerGroup *pg, |
648 | const char *output_filename, | 662 | const char *output_filename, |
649 | GNUNET_TESTING_NotifyCompletion notify_cb, | 663 | GNUNET_TESTING_NotifyCompletion |
650 | void *notify_cb_cls) | 664 | notify_cb, void *notify_cb_cls) |
651 | { | 665 | { |
652 | struct TopologyOutputContext *topo_ctx; | 666 | struct TopologyOutputContext *topo_ctx; |
653 | int temp; | 667 | int temp; |
654 | char *temp_str; | 668 | char *temp_str; |
655 | topo_ctx = GNUNET_malloc(sizeof(struct TopologyOutputContext)); | 669 | |
670 | topo_ctx = GNUNET_malloc (sizeof (struct TopologyOutputContext)); | ||
656 | 671 | ||
657 | topo_ctx->notify_cb = notify_cb; | 672 | topo_ctx->notify_cb = notify_cb; |
658 | topo_ctx->notify_cb_cls = notify_cb_cls; | 673 | topo_ctx->notify_cb_cls = notify_cb_cls; |
659 | topo_ctx->file = GNUNET_DISK_file_open (output_filename, GNUNET_DISK_OPEN_READWRITE | 674 | topo_ctx->file = |
660 | | GNUNET_DISK_OPEN_CREATE, | 675 | GNUNET_DISK_file_open (output_filename, |
661 | GNUNET_DISK_PERM_USER_READ | | 676 | GNUNET_DISK_OPEN_READWRITE | |
662 | GNUNET_DISK_PERM_USER_WRITE); | 677 | GNUNET_DISK_OPEN_CREATE, |
678 | GNUNET_DISK_PERM_USER_READ | | ||
679 | GNUNET_DISK_PERM_USER_WRITE); | ||
663 | if (topo_ctx->file == NULL) | 680 | if (topo_ctx->file == NULL) |
664 | { | 681 | { |
665 | notify_cb (notify_cb_cls, "Failed to open output file!"); | 682 | notify_cb (notify_cb_cls, "Failed to open output file!"); |
666 | GNUNET_free (topo_ctx); | 683 | GNUNET_free (topo_ctx); |
667 | return; | 684 | return; |
668 | } | 685 | } |
669 | 686 | ||
670 | temp = GNUNET_asprintf(&temp_str, "strict graph G {\n"); | 687 | temp = GNUNET_asprintf (&temp_str, "strict graph G {\n"); |
671 | if (temp > 0) | 688 | if (temp > 0) |
672 | GNUNET_DISK_file_write(topo_ctx->file, temp_str, temp); | 689 | GNUNET_DISK_file_write (topo_ctx->file, temp_str, temp); |
673 | GNUNET_free_non_null(temp_str); | 690 | GNUNET_free_non_null (temp_str); |
674 | GNUNET_TESTING_get_topology(pg, &write_topology_cb, topo_ctx); | 691 | GNUNET_TESTING_get_topology (pg, &write_topology_cb, topo_ctx); |
675 | } | 692 | } |
676 | 693 | ||
677 | /** | 694 | /** |
@@ -692,75 +709,80 @@ GNUNET_TESTING_peergroup_topology_to_file(struct GNUNET_TESTING_PeerGroup *pg, | |||
692 | * @return NULL on error, otherwise handle to control peer group | 709 | * @return NULL on error, otherwise handle to control peer group |
693 | */ | 710 | */ |
694 | struct GNUNET_TESTING_PeerGroup * | 711 | struct GNUNET_TESTING_PeerGroup * |
695 | GNUNET_TESTING_peergroup_start(const struct GNUNET_CONFIGURATION_Handle *cfg, | 712 | GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg, |
696 | unsigned int total, | 713 | unsigned int total, |
697 | struct GNUNET_TIME_Relative timeout, | 714 | struct GNUNET_TIME_Relative timeout, |
698 | GNUNET_TESTING_NotifyConnection connect_cb, | 715 | GNUNET_TESTING_NotifyConnection connect_cb, |
699 | GNUNET_TESTING_NotifyCompletion peergroup_cb, | 716 | GNUNET_TESTING_NotifyCompletion peergroup_cb, |
700 | void *peergroup_cls, | 717 | void *peergroup_cls, |
701 | const struct GNUNET_TESTING_Host *hostnames) | 718 | const struct GNUNET_TESTING_Host *hostnames) |
702 | { | 719 | { |
703 | struct PeerGroupStartupContext *pg_start_ctx; | 720 | struct PeerGroupStartupContext *pg_start_ctx; |
704 | unsigned long long temp_config_number; | 721 | unsigned long long temp_config_number; |
705 | char *temp_str; | 722 | char *temp_str; |
706 | int temp; | 723 | int temp; |
707 | GNUNET_assert(total > 0); | ||
708 | GNUNET_assert(cfg != NULL); | ||
709 | 724 | ||
710 | pg_start_ctx = GNUNET_malloc(sizeof(struct PeerGroupStartupContext)); | 725 | GNUNET_assert (total > 0); |
726 | GNUNET_assert (cfg != NULL); | ||
727 | |||
728 | pg_start_ctx = GNUNET_malloc (sizeof (struct PeerGroupStartupContext)); | ||
711 | 729 | ||
712 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "testing", | 730 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "testing", |
713 | "connect_attempts", | 731 | "connect_attempts", |
714 | &pg_start_ctx->connect_attempts)) | 732 | &pg_start_ctx->connect_attempts)) |
715 | { | 733 | { |
716 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", | 734 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", |
717 | "testing", "connect_attempts"); | 735 | "testing", "connect_attempts"); |
718 | GNUNET_free(pg_start_ctx); | 736 | GNUNET_free (pg_start_ctx); |
719 | return NULL; | 737 | return NULL; |
720 | } | 738 | } |
721 | 739 | ||
722 | if (GNUNET_OK | 740 | if (GNUNET_OK |
723 | != GNUNET_CONFIGURATION_get_value_number (cfg, "testing", | 741 | != GNUNET_CONFIGURATION_get_value_number (cfg, "testing", |
724 | "max_outstanding_connections", | 742 | "max_outstanding_connections", |
725 | &pg_start_ctx->max_concurrent_connections)) | 743 | &pg_start_ctx->max_concurrent_connections)) |
726 | { | 744 | { |
727 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", | 745 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", |
728 | "testing", "max_outstanding_connections"); | 746 | "testing", "max_outstanding_connections"); |
729 | GNUNET_free(pg_start_ctx); | 747 | GNUNET_free (pg_start_ctx); |
730 | return NULL; | 748 | return NULL; |
731 | } | 749 | } |
732 | 750 | ||
733 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "testing", | 751 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "testing", |
734 | "max_concurrent_ssh", | 752 | "max_concurrent_ssh", |
735 | &pg_start_ctx->max_concurrent_ssh)) | 753 | &pg_start_ctx->max_concurrent_ssh)) |
736 | { | 754 | { |
737 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", | 755 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", |
738 | "testing", "max_concurrent_ssh"); | 756 | "testing", "max_concurrent_ssh"); |
739 | GNUNET_free(pg_start_ctx); | 757 | GNUNET_free (pg_start_ctx); |
740 | return NULL; | 758 | return NULL; |
741 | } | 759 | } |
742 | 760 | ||
743 | if (GNUNET_SYSERR == (pg_start_ctx->verbose = GNUNET_CONFIGURATION_get_value_yesno (cfg, "testing", | 761 | if (GNUNET_SYSERR == |
744 | "use_progressbars"))) | 762 | (pg_start_ctx->verbose = |
745 | { | 763 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "testing", |
746 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", | 764 | "use_progressbars"))) |
747 | "testing", "use_progressbars"); | 765 | { |
748 | GNUNET_free(pg_start_ctx); | 766 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", |
749 | return NULL; | 767 | "testing", "use_progressbars"); |
750 | } | 768 | GNUNET_free (pg_start_ctx); |
769 | return NULL; | ||
770 | } | ||
751 | 771 | ||
752 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "testing", | 772 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "testing", |
753 | "peergroup_timeout", | 773 | "peergroup_timeout", |
754 | &temp_config_number)) | 774 | &temp_config_number)) |
755 | pg_start_ctx->timeout = GNUNET_TIME_relative_to_absolute(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 775 | pg_start_ctx->timeout = |
756 | temp_config_number)); | 776 | GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply |
777 | (GNUNET_TIME_UNIT_SECONDS, | ||
778 | temp_config_number)); | ||
757 | else | 779 | else |
758 | { | 780 | { |
759 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", | 781 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", |
760 | "testing", "peergroup_timeout"); | 782 | "testing", "peergroup_timeout"); |
761 | GNUNET_free(pg_start_ctx); | 783 | GNUNET_free (pg_start_ctx); |
762 | return NULL; | 784 | return NULL; |
763 | } | 785 | } |
764 | 786 | ||
765 | 787 | ||
766 | /* Read topology related options from the configuration file */ | 788 | /* Read topology related options from the configuration file */ |
@@ -768,102 +790,106 @@ GNUNET_TESTING_peergroup_start(const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
768 | if ((GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", | 790 | if ((GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", |
769 | "topology", | 791 | "topology", |
770 | &temp_str)) | 792 | &temp_str)) |
771 | && (GNUNET_NO == GNUNET_TESTING_topology_get (&pg_start_ctx->topology, temp_str))) | 793 | && (GNUNET_NO == |
772 | { | 794 | GNUNET_TESTING_topology_get (&pg_start_ctx->topology, temp_str))) |
773 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 795 | { |
774 | "Invalid topology `%s' given for section %s option %s\n", | 796 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
775 | temp_str, "TESTING", "TOPOLOGY"); | 797 | "Invalid topology `%s' given for section %s option %s\n", |
776 | pg_start_ctx->topology = GNUNET_TESTING_TOPOLOGY_CLIQUE; /* Defaults to NONE, so set better default here */ | 798 | temp_str, "TESTING", "TOPOLOGY"); |
777 | } | 799 | pg_start_ctx->topology = GNUNET_TESTING_TOPOLOGY_CLIQUE; /* Defaults to NONE, so set better default here */ |
778 | GNUNET_free_non_null(temp_str); | 800 | } |
779 | 801 | GNUNET_free_non_null (temp_str); | |
780 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "topology_output_file", &temp_str)) | 802 | |
803 | if (GNUNET_YES == | ||
804 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", | ||
805 | "topology_output_file", &temp_str)) | ||
806 | { | ||
807 | pg_start_ctx->topology_output_file = | ||
808 | GNUNET_DISK_file_open (temp_str, | ||
809 | GNUNET_DISK_OPEN_READWRITE | | ||
810 | GNUNET_DISK_OPEN_CREATE, | ||
811 | GNUNET_DISK_PERM_USER_READ | | ||
812 | GNUNET_DISK_PERM_USER_WRITE); | ||
813 | if (pg_start_ctx->topology_output_file != NULL) | ||
781 | { | 814 | { |
782 | pg_start_ctx->topology_output_file = GNUNET_DISK_file_open (temp_str, GNUNET_DISK_OPEN_READWRITE | 815 | GNUNET_free (temp_str); |
783 | | GNUNET_DISK_OPEN_CREATE, | 816 | temp = GNUNET_asprintf (&temp_str, "strict graph G {\n"); |
784 | GNUNET_DISK_PERM_USER_READ | | 817 | if (temp > 0) |
785 | GNUNET_DISK_PERM_USER_WRITE); | 818 | GNUNET_DISK_file_write (pg_start_ctx->topology_output_file, temp_str, |
786 | if (pg_start_ctx->topology_output_file != NULL) | 819 | temp); |
787 | { | ||
788 | GNUNET_free(temp_str); | ||
789 | temp = GNUNET_asprintf(&temp_str, "strict graph G {\n"); | ||
790 | if (temp > 0) | ||
791 | GNUNET_DISK_file_write(pg_start_ctx->topology_output_file, temp_str, temp); | ||
792 | } | ||
793 | GNUNET_free(temp_str); | ||
794 | } | 820 | } |
821 | GNUNET_free (temp_str); | ||
822 | } | ||
795 | 823 | ||
796 | if (GNUNET_OK | 824 | if (GNUNET_OK |
797 | != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "percentage", | 825 | != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "percentage", |
798 | &temp_str)) | 826 | &temp_str)) |
799 | pg_start_ctx->topology_percentage = 0.5; | 827 | pg_start_ctx->topology_percentage = 0.5; |
800 | else | 828 | else |
801 | { | 829 | { |
802 | pg_start_ctx->topology_percentage = atof (temp_str); | 830 | pg_start_ctx->topology_percentage = atof (temp_str); |
803 | GNUNET_free(temp_str); | 831 | GNUNET_free (temp_str); |
804 | } | 832 | } |
805 | 833 | ||
806 | if (GNUNET_OK | 834 | if (GNUNET_OK |
807 | != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "probability", | 835 | != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "probability", |
808 | &temp_str)) | 836 | &temp_str)) |
809 | pg_start_ctx->topology_probability = 0.5; | 837 | pg_start_ctx->topology_probability = 0.5; |
810 | else | 838 | else |
811 | { | 839 | { |
812 | pg_start_ctx->topology_probability = atof (temp_str); | 840 | pg_start_ctx->topology_probability = atof (temp_str); |
813 | GNUNET_free(temp_str); | 841 | GNUNET_free (temp_str); |
814 | } | 842 | } |
815 | 843 | ||
816 | if ((GNUNET_YES | 844 | if ((GNUNET_YES |
817 | == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", | 845 | == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", |
818 | "connect_topology", | 846 | "connect_topology", |
819 | &temp_str)) | 847 | &temp_str)) |
820 | && (GNUNET_NO == GNUNET_TESTING_topology_get (&pg_start_ctx->connect_topology, | 848 | && (GNUNET_NO == |
821 | temp_str))) | 849 | GNUNET_TESTING_topology_get (&pg_start_ctx->connect_topology, |
822 | { | 850 | temp_str))) |
823 | GNUNET_log ( | 851 | { |
824 | GNUNET_ERROR_TYPE_WARNING, | 852 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
825 | "Invalid connect topology `%s' given for section %s option %s\n", | 853 | "Invalid connect topology `%s' given for section %s option %s\n", |
826 | temp_str, "TESTING", "CONNECT_TOPOLOGY"); | 854 | temp_str, "TESTING", "CONNECT_TOPOLOGY"); |
827 | } | 855 | } |
828 | GNUNET_free_non_null(temp_str); | 856 | GNUNET_free_non_null (temp_str); |
829 | 857 | ||
830 | if ((GNUNET_YES | 858 | if ((GNUNET_YES |
831 | == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", | 859 | == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", |
832 | "connect_topology_option", | 860 | "connect_topology_option", |
833 | &temp_str)) | 861 | &temp_str)) |
834 | && (GNUNET_NO | 862 | && (GNUNET_NO |
835 | == GNUNET_TESTING_topology_option_get (&pg_start_ctx->connect_topology_option, | 863 | == |
836 | temp_str))) | 864 | GNUNET_TESTING_topology_option_get |
837 | { | 865 | (&pg_start_ctx->connect_topology_option, temp_str))) |
838 | GNUNET_log ( | 866 | { |
839 | GNUNET_ERROR_TYPE_WARNING, | 867 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
840 | "Invalid connect topology option `%s' given for section %s option %s\n", | 868 | "Invalid connect topology option `%s' given for section %s option %s\n", |
841 | temp_str, "TESTING", | 869 | temp_str, "TESTING", "CONNECT_TOPOLOGY_OPTION"); |
842 | "CONNECT_TOPOLOGY_OPTION"); | 870 | pg_start_ctx->connect_topology_option = GNUNET_TESTING_TOPOLOGY_OPTION_ALL; /* Defaults to NONE, set to ALL */ |
843 | pg_start_ctx->connect_topology_option = GNUNET_TESTING_TOPOLOGY_OPTION_ALL; /* Defaults to NONE, set to ALL */ | 871 | } |
844 | } | 872 | GNUNET_free_non_null (temp_str); |
845 | GNUNET_free_non_null(temp_str); | ||
846 | 873 | ||
847 | if (GNUNET_YES | 874 | if (GNUNET_YES |
848 | == GNUNET_CONFIGURATION_get_value_string (cfg, | 875 | == GNUNET_CONFIGURATION_get_value_string (cfg, |
849 | "testing", | 876 | "testing", |
850 | "connect_topology_option_modifier", | 877 | "connect_topology_option_modifier", |
851 | &temp_str)) | 878 | &temp_str)) |
879 | { | ||
880 | if (sscanf (temp_str, "%lf", | ||
881 | &pg_start_ctx->connect_topology_option_modifier) != 1) | ||
852 | { | 882 | { |
853 | if (sscanf (temp_str, "%lf", | 883 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
854 | &pg_start_ctx->connect_topology_option_modifier) != 1) | 884 | _ |
855 | { | 885 | ("Invalid value `%s' for option `%s' in section `%s': expected float\n"), |
856 | GNUNET_log ( | 886 | temp_str, "connect_topology_option_modifier", "TESTING"); |
857 | GNUNET_ERROR_TYPE_WARNING, | ||
858 | _("Invalid value `%s' for option `%s' in section `%s': expected float\n"), | ||
859 | temp_str, | ||
860 | "connect_topology_option_modifier", "TESTING"); | ||
861 | GNUNET_free (temp_str); | ||
862 | GNUNET_free(pg_start_ctx); | ||
863 | return NULL; | ||
864 | } | ||
865 | GNUNET_free (temp_str); | 887 | GNUNET_free (temp_str); |
888 | GNUNET_free (pg_start_ctx); | ||
889 | return NULL; | ||
866 | } | 890 | } |
891 | GNUNET_free (temp_str); | ||
892 | } | ||
867 | 893 | ||
868 | if (GNUNET_YES | 894 | if (GNUNET_YES |
869 | != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", | 895 | != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", |
@@ -873,18 +899,19 @@ GNUNET_TESTING_peergroup_start(const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
873 | 899 | ||
874 | pg_start_ctx->restrict_topology = GNUNET_TESTING_TOPOLOGY_NONE; | 900 | pg_start_ctx->restrict_topology = GNUNET_TESTING_TOPOLOGY_NONE; |
875 | if ((GNUNET_YES | 901 | if ((GNUNET_YES |
876 | == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", | 902 | == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", |
877 | "blacklist_topology", | 903 | "blacklist_topology", |
878 | &temp_str)) | 904 | &temp_str)) |
879 | && (GNUNET_NO == GNUNET_TESTING_topology_get (&pg_start_ctx->restrict_topology, | 905 | && (GNUNET_NO == |
880 | temp_str))) | 906 | GNUNET_TESTING_topology_get (&pg_start_ctx->restrict_topology, |
881 | { | 907 | temp_str))) |
882 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 908 | { |
883 | "Invalid topology `%s' given for section %s option %s\n", | 909 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
884 | temp_str, "TESTING", "BLACKLIST_TOPOLOGY"); | 910 | "Invalid topology `%s' given for section %s option %s\n", |
885 | } | 911 | temp_str, "TESTING", "BLACKLIST_TOPOLOGY"); |
886 | 912 | } | |
887 | GNUNET_free_non_null(temp_str); | 913 | |
914 | GNUNET_free_non_null (temp_str); | ||
888 | 915 | ||
889 | pg_start_ctx->cfg = cfg; | 916 | pg_start_ctx->cfg = cfg; |
890 | pg_start_ctx->total = total; | 917 | pg_start_ctx->total = total; |
@@ -893,28 +920,30 @@ GNUNET_TESTING_peergroup_start(const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
893 | pg_start_ctx->peergroup_cb = peergroup_cb; | 920 | pg_start_ctx->peergroup_cb = peergroup_cb; |
894 | pg_start_ctx->cls = peergroup_cls; | 921 | pg_start_ctx->cls = peergroup_cls; |
895 | pg_start_ctx->hostnames = hostnames; | 922 | pg_start_ctx->hostnames = hostnames; |
896 | pg_start_ctx->hostkey_meter = create_meter (pg_start_ctx->peers_left, "Hostkeys created ", pg_start_ctx->verbose); | 923 | pg_start_ctx->hostkey_meter = |
897 | pg_start_ctx->peer_start_meter = create_meter (pg_start_ctx->peers_left, "Peers started ", pg_start_ctx->verbose); | 924 | create_meter (pg_start_ctx->peers_left, "Hostkeys created ", |
925 | pg_start_ctx->verbose); | ||
926 | pg_start_ctx->peer_start_meter = | ||
927 | create_meter (pg_start_ctx->peers_left, "Peers started ", | ||
928 | pg_start_ctx->verbose); | ||
898 | /* Make compilers happy */ | 929 | /* Make compilers happy */ |
899 | reset_meter(pg_start_ctx->peer_start_meter); | 930 | reset_meter (pg_start_ctx->peer_start_meter); |
900 | pg_start_ctx->die_task | 931 | pg_start_ctx->die_task |
901 | = GNUNET_SCHEDULER_add_delayed ( | 932 | = |
902 | GNUNET_TIME_absolute_get_remaining ( | 933 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining |
903 | pg_start_ctx->timeout), | 934 | (pg_start_ctx->timeout), &end_badly, |
904 | &end_badly, | 935 | "didn't generate all hostkeys within allowed startup time!"); |
905 | "didn't generate all hostkeys within allowed startup time!"); | ||
906 | 936 | ||
907 | pg_start_ctx->pg | 937 | pg_start_ctx->pg |
908 | = GNUNET_TESTING_daemons_start ( | 938 | = GNUNET_TESTING_daemons_start (pg_start_ctx->cfg, |
909 | pg_start_ctx->cfg, | ||
910 | pg_start_ctx->peers_left, | 939 | pg_start_ctx->peers_left, |
911 | pg_start_ctx->max_concurrent_connections, | 940 | pg_start_ctx->max_concurrent_connections, |
912 | pg_start_ctx->max_concurrent_ssh, | 941 | pg_start_ctx->max_concurrent_ssh, |
913 | GNUNET_TIME_absolute_get_remaining(pg_start_ctx->timeout), | 942 | GNUNET_TIME_absolute_get_remaining |
943 | (pg_start_ctx->timeout), | ||
914 | &internal_hostkey_callback, pg_start_ctx, | 944 | &internal_hostkey_callback, pg_start_ctx, |
915 | &internal_peers_started_callback, | 945 | &internal_peers_started_callback, |
916 | pg_start_ctx, | 946 | pg_start_ctx, &internal_topology_callback, |
917 | &internal_topology_callback, | ||
918 | pg_start_ctx, pg_start_ctx->hostnames); | 947 | pg_start_ctx, pg_start_ctx->hostnames); |
919 | 948 | ||
920 | return pg_start_ctx->pg; | 949 | return pg_start_ctx->pg; |