diff options
Diffstat (limited to 'src/testing/testing.c')
-rw-r--r-- | src/testing/testing.c | 186 |
1 files changed, 126 insertions, 60 deletions
diff --git a/src/testing/testing.c b/src/testing/testing.c index 3406355c5..5d465e05f 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -85,7 +85,7 @@ struct GNUNET_TESTING_Daemon | |||
85 | /** | 85 | /** |
86 | * Our configuration. | 86 | * Our configuration. |
87 | */ | 87 | */ |
88 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 88 | struct GNUNET_CONFIGURATION_Handle *cfg; |
89 | 89 | ||
90 | /** | 90 | /** |
91 | * Host to run GNUnet on. | 91 | * Host to run GNUnet on. |
@@ -202,10 +202,11 @@ testing_init (void *cls, | |||
202 | d->cb = NULL; | 202 | d->cb = NULL; |
203 | if (server == NULL) | 203 | if (server == NULL) |
204 | { | 204 | { |
205 | cb (d->cb_cls, NULL, d->cfg, d, | ||
206 | _("Failed to connect to core service\n")); | ||
207 | if (GNUNET_YES == d->dead) | 205 | if (GNUNET_YES == d->dead) |
208 | GNUNET_TESTING_daemon_stop (d, d->dead_cb, d->dead_cb_cls); | 206 | GNUNET_TESTING_daemon_stop (d, d->dead_cb, d->dead_cb_cls); |
207 | else if (NULL != cb) | ||
208 | cb (d->cb_cls, NULL, d->cfg, d, | ||
209 | _("Failed to connect to core service\n")); | ||
209 | return; | 210 | return; |
210 | } | 211 | } |
211 | #if DEBUG_TESTING | 212 | #if DEBUG_TESTING |
@@ -216,7 +217,7 @@ testing_init (void *cls, | |||
216 | d->id = *my_identity; | 217 | d->id = *my_identity; |
217 | if (GNUNET_YES == d->dead) | 218 | if (GNUNET_YES == d->dead) |
218 | GNUNET_TESTING_daemon_stop (d, d->dead_cb, d->dead_cb_cls); | 219 | GNUNET_TESTING_daemon_stop (d, d->dead_cb, d->dead_cb_cls); |
219 | else | 220 | else if (NULL != cb) |
220 | cb (d->cb_cls, my_identity, d->cfg, d, NULL); | 221 | cb (d->cb_cls, my_identity, d->cfg, d, NULL); |
221 | d->server = server; | 222 | d->server = server; |
222 | } | 223 | } |
@@ -240,6 +241,11 @@ start_fsm (void *cls, | |||
240 | unsigned long code; | 241 | unsigned long code; |
241 | char *dst; | 242 | char *dst; |
242 | 243 | ||
244 | #if DEBUG_TESTING | ||
245 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
246 | "Peer FSM is in phase %u.\n", | ||
247 | d->phase); | ||
248 | #endif | ||
243 | d->task = GNUNET_SCHEDULER_NO_TASK; | 249 | d->task = GNUNET_SCHEDULER_NO_TASK; |
244 | switch (d->phase) | 250 | switch (d->phase) |
245 | { | 251 | { |
@@ -255,11 +261,12 @@ start_fsm (void *cls, | |||
255 | { | 261 | { |
256 | cb = d->cb; | 262 | cb = d->cb; |
257 | d->cb = NULL; | 263 | d->cb = NULL; |
258 | cb (d->cb_cls, | 264 | if (NULL != cb) |
259 | NULL, | 265 | cb (d->cb_cls, |
260 | d->cfg, | 266 | NULL, |
261 | d, | 267 | d->cfg, |
262 | _("`scp' does not seem to terminate.\n")); | 268 | d, |
269 | _("`scp' does not seem to terminate.\n")); | ||
263 | return; | 270 | return; |
264 | } | 271 | } |
265 | /* wait some more */ | 272 | /* wait some more */ |
@@ -278,11 +285,12 @@ start_fsm (void *cls, | |||
278 | { | 285 | { |
279 | cb = d->cb; | 286 | cb = d->cb; |
280 | d->cb = NULL; | 287 | d->cb = NULL; |
281 | cb (d->cb_cls, | 288 | if (NULL != cb) |
282 | NULL, | 289 | cb (d->cb_cls, |
283 | d->cfg, | 290 | NULL, |
284 | d, | 291 | d->cfg, |
285 | _("`scp' did not complete cleanly.\n")); | 292 | d, |
293 | _("`scp' did not complete cleanly.\n")); | ||
286 | return; | 294 | return; |
287 | } | 295 | } |
288 | #if DEBUG_TESTING | 296 | #if DEBUG_TESTING |
@@ -299,7 +307,11 @@ start_fsm (void *cls, | |||
299 | "gnunet-service-arm", | 307 | "gnunet-service-arm", |
300 | "-c", | 308 | "-c", |
301 | d->cfgfile, | 309 | d->cfgfile, |
310 | #if DEBUG_TESTING | ||
311 | "-L", "DEBUG", | ||
312 | #else | ||
302 | "-d", | 313 | "-d", |
314 | #endif | ||
303 | NULL); | 315 | NULL); |
304 | } | 316 | } |
305 | else | 317 | else |
@@ -328,16 +340,31 @@ start_fsm (void *cls, | |||
328 | (NULL == d->hostname) ? "gnunet-service-arm" : "ssh"); | 340 | (NULL == d->hostname) ? "gnunet-service-arm" : "ssh"); |
329 | cb = d->cb; | 341 | cb = d->cb; |
330 | d->cb = NULL; | 342 | d->cb = NULL; |
331 | cb (d->cb_cls, | 343 | if (NULL != cb) |
332 | NULL, | 344 | cb (d->cb_cls, |
333 | d->cfg, | 345 | NULL, |
334 | d, | 346 | d->cfg, |
335 | (NULL == d->hostname) | 347 | d, |
336 | ? _("Failed to start `gnunet-service-arm' process.\n") | 348 | (NULL == d->hostname) |
337 | : _("Failed to start `ssh' process.\n")); | 349 | ? _("Failed to start `gnunet-service-arm' process.\n") |
350 | : _("Failed to start `ssh' process.\n")); | ||
338 | } | 351 | } |
352 | #if DEBUG_TESTING | ||
353 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
354 | "Started `%s', waiting for `%s' to be up.\n", | ||
355 | "gnunet-service-arm", | ||
356 | "gnunet-service-core"); | ||
357 | #endif | ||
339 | d->phase = SP_START_ARMING; | 358 | d->phase = SP_START_ARMING; |
340 | d->wait_runs = 0; | 359 | d->wait_runs = 0; |
360 | d->task | ||
361 | = GNUNET_SCHEDULER_add_delayed (d->sched, | ||
362 | GNUNET_NO, | ||
363 | GNUNET_SCHEDULER_PRIORITY_KEEP, | ||
364 | GNUNET_SCHEDULER_NO_TASK, | ||
365 | GNUNET_CONSTANTS_EXEC_WAIT, | ||
366 | &start_fsm, | ||
367 | d); | ||
341 | break; | 368 | break; |
342 | case SP_START_ARMING: | 369 | case SP_START_ARMING: |
343 | if (GNUNET_OK != | 370 | if (GNUNET_OK != |
@@ -350,13 +377,14 @@ start_fsm (void *cls, | |||
350 | { | 377 | { |
351 | cb = d->cb; | 378 | cb = d->cb; |
352 | d->cb = NULL; | 379 | d->cb = NULL; |
353 | cb (d->cb_cls, | 380 | if (NULL != cb) |
354 | NULL, | 381 | cb (d->cb_cls, |
355 | d->cfg, | 382 | NULL, |
356 | d, | 383 | d->cfg, |
357 | (NULL == d->hostname) | 384 | d, |
358 | ? _("`gnunet-service-arm' does not seem to terminate.\n") | 385 | (NULL == d->hostname) |
359 | : _("`ssh' does not seem to terminate.\n")); | 386 | ? _("`gnunet-service-arm' does not seem to terminate.\n") |
387 | : _("`ssh' does not seem to terminate.\n")); | ||
360 | return; | 388 | return; |
361 | } | 389 | } |
362 | /* wait some more */ | 390 | /* wait some more */ |
@@ -424,18 +452,24 @@ start_fsm (void *cls, | |||
424 | if ( (type != GNUNET_OS_PROCESS_EXITED) || | 452 | if ( (type != GNUNET_OS_PROCESS_EXITED) || |
425 | (code != 0) ) | 453 | (code != 0) ) |
426 | { | 454 | { |
427 | d->dead_cb (d->dead_cb_cls, | 455 | if (NULL != d->dead_cb) |
428 | _("`sshp' did not complete cleanly.\n")); | 456 | d->dead_cb (d->dead_cb_cls, |
457 | _("`ssh' did not complete cleanly.\n")); | ||
429 | GNUNET_free (d->cfgfile); | 458 | GNUNET_free (d->cfgfile); |
430 | GNUNET_free_non_null (d->hostname); | 459 | GNUNET_free_non_null (d->hostname); |
431 | GNUNET_free_non_null (d->username); | 460 | GNUNET_free_non_null (d->username); |
432 | GNUNET_free (d); | 461 | GNUNET_free (d); |
433 | return; | 462 | return; |
434 | } | 463 | } |
464 | #if DEBUG_TESTING | ||
465 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
466 | "Peer shutdown complete.\n"); | ||
467 | #endif | ||
435 | GNUNET_free (d->cfgfile); | 468 | GNUNET_free (d->cfgfile); |
436 | GNUNET_free_non_null (d->hostname); | 469 | GNUNET_free_non_null (d->hostname); |
437 | GNUNET_free_non_null (d->username); | 470 | GNUNET_free_non_null (d->username); |
438 | d->dead_cb (d->dead_cb_cls, NULL); | 471 | if (NULL != d->dead_cb) |
472 | d->dead_cb (d->dead_cb_cls, NULL); | ||
439 | GNUNET_free (d); | 473 | GNUNET_free (d); |
440 | break; | 474 | break; |
441 | case SP_CONFIG_UPDATE: | 475 | case SP_CONFIG_UPDATE: |
@@ -450,11 +484,12 @@ start_fsm (void *cls, | |||
450 | { | 484 | { |
451 | cb = d->cb; | 485 | cb = d->cb; |
452 | d->cb = NULL; | 486 | d->cb = NULL; |
453 | cb (d->cb_cls, | 487 | if (NULL != cb) |
454 | NULL, | 488 | cb (d->cb_cls, |
455 | d->cfg, | 489 | NULL, |
456 | d, | 490 | d->cfg, |
457 | _("`scp' does not seem to terminate.\n")); | 491 | d, |
492 | _("`scp' does not seem to terminate.\n")); | ||
458 | return; | 493 | return; |
459 | } | 494 | } |
460 | /* wait some more */ | 495 | /* wait some more */ |
@@ -471,15 +506,17 @@ start_fsm (void *cls, | |||
471 | if ( (type != GNUNET_OS_PROCESS_EXITED) || | 506 | if ( (type != GNUNET_OS_PROCESS_EXITED) || |
472 | (code != 0) ) | 507 | (code != 0) ) |
473 | { | 508 | { |
474 | d->update_cb (d->update_cb_cls, | 509 | if (NULL != d->update_cb) |
475 | _("`scp' did not complete cleanly.\n")); | 510 | d->update_cb (d->update_cb_cls, |
511 | _("`scp' did not complete cleanly.\n")); | ||
476 | return; | 512 | return; |
477 | } | 513 | } |
478 | #if DEBUG_TESTING | 514 | #if DEBUG_TESTING |
479 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 515 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
480 | "Successfully copied configuration file.\n"); | 516 | "Successfully copied configuration file.\n"); |
481 | #endif | 517 | #endif |
482 | d->update_cb (d->update_cb_cls, NULL); | 518 | if (NULL != d->update_cb) |
519 | d->update_cb (d->update_cb_cls, NULL); | ||
483 | d->phase = SP_START_DONE; | 520 | d->phase = SP_START_DONE; |
484 | break; | 521 | break; |
485 | } | 522 | } |
@@ -502,7 +539,7 @@ start_fsm (void *cls, | |||
502 | */ | 539 | */ |
503 | struct GNUNET_TESTING_Daemon * | 540 | struct GNUNET_TESTING_Daemon * |
504 | GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched, | 541 | GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched, |
505 | struct GNUNET_CONFIGURATION_Handle *cfg, | 542 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
506 | const char *hostname, | 543 | const char *hostname, |
507 | GNUNET_TESTING_NotifyDaemonRunning cb, | 544 | GNUNET_TESTING_NotifyDaemonRunning cb, |
508 | void *cb_cls) | 545 | void *cb_cls) |
@@ -513,9 +550,13 @@ GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched, | |||
513 | 550 | ||
514 | ret = GNUNET_malloc (sizeof(struct GNUNET_TESTING_Daemon)); | 551 | ret = GNUNET_malloc (sizeof(struct GNUNET_TESTING_Daemon)); |
515 | ret->sched = sched; | 552 | ret->sched = sched; |
516 | ret->cfg = cfg; | ||
517 | ret->hostname = (hostname == NULL) ? NULL : GNUNET_strdup (hostname); | 553 | ret->hostname = (hostname == NULL) ? NULL : GNUNET_strdup (hostname); |
518 | ret->cfgfile = GNUNET_DISK_mktemp ("gnunet-testing-config"); | 554 | ret->cfgfile = GNUNET_DISK_mktemp ("gnunet-testing-config"); |
555 | #if DEBUG_TESTING | ||
556 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
557 | "Setting up peer with configuration file `%s'.\n", | ||
558 | ret->cfgfile); | ||
559 | #endif | ||
519 | if (NULL == ret->cfgfile) | 560 | if (NULL == ret->cfgfile) |
520 | { | 561 | { |
521 | GNUNET_free_non_null (ret->hostname); | 562 | GNUNET_free_non_null (ret->hostname); |
@@ -524,15 +565,21 @@ GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched, | |||
524 | } | 565 | } |
525 | ret->cb = cb; | 566 | ret->cb = cb; |
526 | ret->cb_cls = cb_cls; | 567 | ret->cb_cls = cb_cls; |
568 | ret->cfg = GNUNET_CONFIGURATION_dup (cfg); | ||
569 | GNUNET_CONFIGURATION_set_value_string (ret->cfg, | ||
570 | "PATHS", | ||
571 | "DEFAULTCONFIG", | ||
572 | ret->cfgfile); | ||
527 | /* 1) write configuration to temporary file */ | 573 | /* 1) write configuration to temporary file */ |
528 | if (GNUNET_OK != | 574 | if (GNUNET_OK != |
529 | GNUNET_CONFIGURATION_write (cfg, | 575 | GNUNET_CONFIGURATION_write (ret->cfg, |
530 | ret->cfgfile)) | 576 | ret->cfgfile)) |
531 | { | 577 | { |
532 | if (0 != UNLINK (ret->cfgfile)) | 578 | if (0 != UNLINK (ret->cfgfile)) |
533 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | 579 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, |
534 | "unlink", | 580 | "unlink", |
535 | ret->cfgfile); | 581 | ret->cfgfile); |
582 | GNUNET_CONFIGURATION_destroy (ret->cfg); | ||
536 | GNUNET_free_non_null (ret->hostname); | 583 | GNUNET_free_non_null (ret->hostname); |
537 | GNUNET_free (ret->cfgfile); | 584 | GNUNET_free (ret->cfgfile); |
538 | GNUNET_free (ret); | 585 | GNUNET_free (ret); |
@@ -581,6 +628,7 @@ GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched, | |||
581 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | 628 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, |
582 | "unlink", | 629 | "unlink", |
583 | ret->cfgfile); | 630 | ret->cfgfile); |
631 | GNUNET_CONFIGURATION_destroy (ret->cfg); | ||
584 | GNUNET_free_non_null (ret->hostname); | 632 | GNUNET_free_non_null (ret->hostname); |
585 | GNUNET_free_non_null (ret->username); | 633 | GNUNET_free_non_null (ret->username); |
586 | GNUNET_free (ret->cfgfile); | 634 | GNUNET_free (ret->cfgfile); |
@@ -589,7 +637,7 @@ GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched, | |||
589 | } | 637 | } |
590 | ret->task | 638 | ret->task |
591 | = GNUNET_SCHEDULER_add_delayed (sched, | 639 | = GNUNET_SCHEDULER_add_delayed (sched, |
592 | GNUNET_NO, | 640 | GNUNET_YES, |
593 | GNUNET_SCHEDULER_PRIORITY_KEEP, | 641 | GNUNET_SCHEDULER_PRIORITY_KEEP, |
594 | GNUNET_SCHEDULER_NO_TASK, | 642 | GNUNET_SCHEDULER_NO_TASK, |
595 | GNUNET_CONSTANTS_EXEC_WAIT, | 643 | GNUNET_CONSTANTS_EXEC_WAIT, |
@@ -597,6 +645,10 @@ GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched, | |||
597 | ret); | 645 | ret); |
598 | return ret; | 646 | return ret; |
599 | } | 647 | } |
648 | #if DEBUG_TESTING | ||
649 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
650 | "No need to copy configuration file since we are running locally.\n"); | ||
651 | #endif | ||
600 | ret->phase = SP_COPIED; | 652 | ret->phase = SP_COPIED; |
601 | GNUNET_SCHEDULER_add_continuation (sched, | 653 | GNUNET_SCHEDULER_add_continuation (sched, |
602 | GNUNET_NO, | 654 | GNUNET_NO, |
@@ -687,7 +739,7 @@ void GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, | |||
687 | d->dead_cb_cls = cb_cls; | 739 | d->dead_cb_cls = cb_cls; |
688 | d->task | 740 | d->task |
689 | = GNUNET_SCHEDULER_add_delayed (d->sched, | 741 | = GNUNET_SCHEDULER_add_delayed (d->sched, |
690 | GNUNET_NO, | 742 | GNUNET_YES, |
691 | GNUNET_SCHEDULER_PRIORITY_KEEP, | 743 | GNUNET_SCHEDULER_PRIORITY_KEEP, |
692 | GNUNET_SCHEDULER_NO_TASK, | 744 | GNUNET_SCHEDULER_NO_TASK, |
693 | GNUNET_CONSTANTS_EXEC_WAIT, | 745 | GNUNET_CONSTANTS_EXEC_WAIT, |
@@ -695,11 +747,13 @@ void GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, | |||
695 | d); | 747 | d); |
696 | return; | 748 | return; |
697 | } | 749 | } |
750 | GNUNET_CONFIGURATION_destroy (d->cfg); | ||
698 | GNUNET_free (d->cfgfile); | 751 | GNUNET_free (d->cfgfile); |
699 | GNUNET_free_non_null (d->hostname); | 752 | GNUNET_free_non_null (d->hostname); |
700 | GNUNET_free_non_null (d->username); | 753 | GNUNET_free_non_null (d->username); |
701 | GNUNET_free (d); | 754 | GNUNET_free (d); |
702 | cb (cb_cls, NULL); | 755 | if (NULL != cb) |
756 | cb (cb_cls, NULL); | ||
703 | } | 757 | } |
704 | 758 | ||
705 | 759 | ||
@@ -720,8 +774,9 @@ void GNUNET_TESTING_daemon_reconfigure (struct GNUNET_TESTING_Daemon *d, | |||
720 | 774 | ||
721 | if (d->phase != SP_START_DONE) | 775 | if (d->phase != SP_START_DONE) |
722 | { | 776 | { |
723 | cb (cb_cls, | 777 | if (NULL != cb) |
724 | _("Peer not yet running, can not change configuration at this point.")); | 778 | cb (cb_cls, |
779 | _("Peer not yet running, can not change configuration at this point.")); | ||
725 | return; | 780 | return; |
726 | } | 781 | } |
727 | 782 | ||
@@ -730,7 +785,8 @@ void GNUNET_TESTING_daemon_reconfigure (struct GNUNET_TESTING_Daemon *d, | |||
730 | GNUNET_CONFIGURATION_write (cfg, | 785 | GNUNET_CONFIGURATION_write (cfg, |
731 | d->cfgfile)) | 786 | d->cfgfile)) |
732 | { | 787 | { |
733 | cb (cb_cls, | 788 | if (NULL != cb) |
789 | cb (cb_cls, | ||
734 | _("Failed to write new configuration to disk.")); | 790 | _("Failed to write new configuration to disk.")); |
735 | return; | 791 | return; |
736 | } | 792 | } |
@@ -739,7 +795,8 @@ void GNUNET_TESTING_daemon_reconfigure (struct GNUNET_TESTING_Daemon *d, | |||
739 | if (NULL == d->hostname) | 795 | if (NULL == d->hostname) |
740 | { | 796 | { |
741 | /* signal success */ | 797 | /* signal success */ |
742 | cb (cb_cls, NULL); | 798 | if (NULL != cb) |
799 | cb (cb_cls, NULL); | ||
743 | return; | 800 | return; |
744 | } | 801 | } |
745 | d->phase = SP_CONFIG_UPDATE; | 802 | d->phase = SP_CONFIG_UPDATE; |
@@ -765,8 +822,9 @@ void GNUNET_TESTING_daemon_reconfigure (struct GNUNET_TESTING_Daemon *d, | |||
765 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 822 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
766 | _("Could not start `%s' process to copy configuration file.\n"), | 823 | _("Could not start `%s' process to copy configuration file.\n"), |
767 | "scp"); | 824 | "scp"); |
768 | cb (cb_cls, | 825 | if (NULL != cb) |
769 | _("Failed to copy new configuration to remote machine.")); | 826 | cb (cb_cls, |
827 | _("Failed to copy new configuration to remote machine.")); | ||
770 | d->phase = SP_START_DONE; | 828 | d->phase = SP_START_DONE; |
771 | return; | 829 | return; |
772 | } | 830 | } |
@@ -802,10 +860,14 @@ static size_t | |||
802 | transmit_ready (void *cls, size_t size, void *buf) | 860 | transmit_ready (void *cls, size_t size, void *buf) |
803 | { | 861 | { |
804 | struct ConnectContext *ctx = cls; | 862 | struct ConnectContext *ctx = cls; |
805 | if (buf == NULL) | 863 | |
806 | ctx->cb (ctx->cb_cls, _("Peers failed to connect")); | 864 | if (NULL != ctx->cb) |
807 | else | 865 | { |
808 | ctx->cb (ctx->cb_cls, NULL); | 866 | if (buf == NULL) |
867 | ctx->cb (ctx->cb_cls, _("Peers failed to connect")); | ||
868 | else | ||
869 | ctx->cb (ctx->cb_cls, NULL); | ||
870 | } | ||
809 | GNUNET_free (ctx); | 871 | GNUNET_free (ctx); |
810 | return 0; | 872 | return 0; |
811 | } | 873 | } |
@@ -831,8 +893,9 @@ process_hello (void *cls, | |||
831 | if (peer == NULL) | 893 | if (peer == NULL) |
832 | { | 894 | { |
833 | /* signal error */ | 895 | /* signal error */ |
834 | ctx->cb (ctx->cb_cls, | 896 | if (NULL != ctx->cb) |
835 | _("Failed to receive `HELLO' from peer\n")); | 897 | ctx->cb (ctx->cb_cls, |
898 | _("Failed to receive `HELLO' from peer\n")); | ||
836 | GNUNET_TRANSPORT_disconnect (ctx->d1th); | 899 | GNUNET_TRANSPORT_disconnect (ctx->d1th); |
837 | GNUNET_TRANSPORT_disconnect (ctx->d2th); | 900 | GNUNET_TRANSPORT_disconnect (ctx->d2th); |
838 | GNUNET_free (ctx); | 901 | GNUNET_free (ctx); |
@@ -873,7 +936,8 @@ void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, | |||
873 | if ( (d1->server == NULL) || | 936 | if ( (d1->server == NULL) || |
874 | (d2->server == NULL) ) | 937 | (d2->server == NULL) ) |
875 | { | 938 | { |
876 | cb (cb_cls, _("Peers are not fully running yet, can not connect!\n")); | 939 | if (NULL != cb) |
940 | cb (cb_cls, _("Peers are not fully running yet, can not connect!\n")); | ||
877 | return; | 941 | return; |
878 | } | 942 | } |
879 | ctx = GNUNET_malloc (sizeof(struct ConnectContext)); | 943 | ctx = GNUNET_malloc (sizeof(struct ConnectContext)); |
@@ -886,7 +950,8 @@ void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, | |||
886 | if (ctx->d1th == NULL) | 950 | if (ctx->d1th == NULL) |
887 | { | 951 | { |
888 | GNUNET_free (ctx); | 952 | GNUNET_free (ctx); |
889 | cb (cb_cls, _("Failed to connect to transport service!\n")); | 953 | if (NULL != cb) |
954 | cb (cb_cls, _("Failed to connect to transport service!\n")); | ||
890 | return; | 955 | return; |
891 | } | 956 | } |
892 | ctx->d2th = GNUNET_TRANSPORT_connect (d2->sched, d2->cfg, d2, NULL, NULL, NULL); | 957 | ctx->d2th = GNUNET_TRANSPORT_connect (d2->sched, d2->cfg, d2, NULL, NULL, NULL); |
@@ -894,7 +959,8 @@ void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, | |||
894 | { | 959 | { |
895 | GNUNET_TRANSPORT_disconnect (ctx->d1th); | 960 | GNUNET_TRANSPORT_disconnect (ctx->d1th); |
896 | GNUNET_free (ctx); | 961 | GNUNET_free (ctx); |
897 | cb (cb_cls, _("Failed to connect to transport service!\n")); | 962 | if (NULL != cb) |
963 | cb (cb_cls, _("Failed to connect to transport service!\n")); | ||
898 | return; | 964 | return; |
899 | } | 965 | } |
900 | GNUNET_TRANSPORT_get_hello (ctx->d1th, | 966 | GNUNET_TRANSPORT_get_hello (ctx->d1th, |