diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-05-06 18:59:37 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-05-06 18:59:37 +0000 |
commit | 778572120eb274c1e2b64b998b18bcea508d746c (patch) | |
tree | 727eefcf2d414308542975fe65c61603a5875d44 /src | |
parent | 57aab79c1d1b7036018eca127501632e85c4b37b (diff) | |
download | gnunet-778572120eb274c1e2b64b998b18bcea508d746c.tar.gz gnunet-778572120eb274c1e2b64b998b18bcea508d746c.zip |
-fixing #2309
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/test_transport_api_bidirectional_connect.c | 58 | ||||
-rw-r--r-- | src/transport/transport-testing.c | 29 |
2 files changed, 33 insertions, 54 deletions
diff --git a/src/transport/test_transport_api_bidirectional_connect.c b/src/transport/test_transport_api_bidirectional_connect.c index 604554c51..2c4eeab3c 100644 --- a/src/transport/test_transport_api_bidirectional_connect.c +++ b/src/transport/test_transport_api_bidirectional_connect.c | |||
@@ -35,10 +35,6 @@ | |||
35 | #include "transport.h" | 35 | #include "transport.h" |
36 | #include "transport-testing.h" | 36 | #include "transport-testing.h" |
37 | 37 | ||
38 | #define VERBOSE GNUNET_NO | ||
39 | #define VERBOSE_ARM GNUNET_NO | ||
40 | |||
41 | #define START_ARM GNUNET_YES | ||
42 | 38 | ||
43 | /** | 39 | /** |
44 | * How long until we give up on transmitting the message? | 40 | * How long until we give up on transmitting the message? |
@@ -64,26 +60,20 @@ static GNUNET_SCHEDULER_TaskIdentifier die_task; | |||
64 | 60 | ||
65 | static GNUNET_SCHEDULER_TaskIdentifier send_task; | 61 | static GNUNET_SCHEDULER_TaskIdentifier send_task; |
66 | 62 | ||
67 | struct PeerContext *p1; | 63 | static struct PeerContext *p1; |
68 | 64 | ||
69 | struct PeerContext *p2; | 65 | static struct PeerContext *p2; |
70 | 66 | ||
71 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc1; | 67 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc1; |
72 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc2; | 68 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc2; |
73 | 69 | ||
74 | struct GNUNET_TRANSPORT_TransmitHandle *th; | 70 | static struct GNUNET_TRANSPORT_TransmitHandle *th; |
75 | |||
76 | struct GNUNET_TRANSPORT_TESTING_handle *tth; | ||
77 | 71 | ||
78 | char *cfg_file_p1; | 72 | static struct GNUNET_TRANSPORT_TESTING_handle *tth; |
79 | 73 | ||
80 | char *cfg_file_p2; | 74 | static char *cfg_file_p1; |
81 | 75 | ||
82 | #if VERBOSE | 76 | static char *cfg_file_p2; |
83 | #define OKPP do { ok++; FPRINTF (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0) | ||
84 | #else | ||
85 | #define OKPP do { ok++; } while (0) | ||
86 | #endif | ||
87 | 77 | ||
88 | 78 | ||
89 | static void | 79 | static void |
@@ -97,9 +87,11 @@ end () | |||
97 | if (die_task != GNUNET_SCHEDULER_NO_TASK) | 87 | if (die_task != GNUNET_SCHEDULER_NO_TASK) |
98 | GNUNET_SCHEDULER_cancel (die_task); | 88 | GNUNET_SCHEDULER_cancel (die_task); |
99 | 89 | ||
100 | if (th != NULL) | 90 | if (NULL != th) |
91 | { | ||
101 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | 92 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); |
102 | th = NULL; | 93 | th = NULL; |
94 | } | ||
103 | 95 | ||
104 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); | 96 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); |
105 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); | 97 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); |
@@ -109,24 +101,27 @@ static void | |||
109 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 101 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
110 | { | 102 | { |
111 | die_task = GNUNET_SCHEDULER_NO_TASK; | 103 | die_task = GNUNET_SCHEDULER_NO_TASK; |
112 | |||
113 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Fail! Stopping peers\n"); | 104 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Fail! Stopping peers\n"); |
114 | |||
115 | |||
116 | if (send_task != GNUNET_SCHEDULER_NO_TASK) | 105 | if (send_task != GNUNET_SCHEDULER_NO_TASK) |
117 | GNUNET_SCHEDULER_cancel (send_task); | 106 | GNUNET_SCHEDULER_cancel (send_task); |
118 | 107 | ||
119 | if (cc2 != NULL) | 108 | if (NULL != cc2) |
120 | { | 109 | { |
121 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n")); | 110 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n")); |
122 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc2); | 111 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc2); |
123 | cc2 = NULL; | 112 | cc2 = NULL; |
124 | } | 113 | } |
125 | 114 | if (NULL != cc1) | |
126 | if (th != NULL) | 115 | { |
116 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n")); | ||
117 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc1); | ||
118 | cc1 = NULL; | ||
119 | } | ||
120 | if (NULL != th) | ||
121 | { | ||
127 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | 122 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); |
128 | th = NULL; | 123 | th = NULL; |
129 | 124 | } | |
130 | if (p1 != NULL) | 125 | if (p1 != NULL) |
131 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); | 126 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); |
132 | if (p2 != NULL) | 127 | if (p2 != NULL) |
@@ -270,6 +265,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
270 | th = NULL; | 265 | th = NULL; |
271 | } | 266 | } |
272 | 267 | ||
268 | |||
273 | static void | 269 | static void |
274 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | 270 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) |
275 | { | 271 | { |
@@ -293,7 +289,8 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | |||
293 | send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL); | 289 | send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL); |
294 | } | 290 | } |
295 | 291 | ||
296 | void | 292 | |
293 | static void | ||
297 | start_cb (struct PeerContext *p, void *cls) | 294 | start_cb (struct PeerContext *p, void *cls) |
298 | { | 295 | { |
299 | static int started; | 296 | static int started; |
@@ -353,9 +350,6 @@ check () | |||
353 | static char *const argv[] = { "test-transport-api", | 350 | static char *const argv[] = { "test-transport-api", |
354 | "-c", | 351 | "-c", |
355 | "test_transport_api_data.conf", | 352 | "test_transport_api_data.conf", |
356 | #if VERBOSE | ||
357 | "-L", "DEBUG", | ||
358 | #endif | ||
359 | NULL | 353 | NULL |
360 | }; | 354 | }; |
361 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | 355 | static struct GNUNET_GETOPT_CommandLineOption options[] = { |
@@ -382,11 +376,7 @@ main (int argc, char *argv[]) | |||
382 | GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); | 376 | GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); |
383 | 377 | ||
384 | GNUNET_log_setup (test_name, | 378 | GNUNET_log_setup (test_name, |
385 | #if VERBOSE | ||
386 | "DEBUG", | ||
387 | #else | ||
388 | "WARNING", | 379 | "WARNING", |
389 | #endif | ||
390 | NULL); | 380 | NULL); |
391 | 381 | ||
392 | GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source); | 382 | GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source); |
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c index 4e11f2c78..ec0800842 100644 --- a/src/transport/transport-testing.c +++ b/src/transport/transport-testing.c | |||
@@ -455,14 +455,13 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, | |||
455 | struct PeerContext *p) | 455 | struct PeerContext *p) |
456 | { | 456 | { |
457 | GNUNET_assert (p != NULL); | 457 | GNUNET_assert (p != NULL); |
458 | |||
459 | if (p->ghh != NULL) | 458 | if (p->ghh != NULL) |
459 | { | ||
460 | GNUNET_TRANSPORT_get_hello_cancel (p->ghh); | 460 | GNUNET_TRANSPORT_get_hello_cancel (p->ghh); |
461 | p->ghh = NULL; | 461 | p->ghh = NULL; |
462 | 462 | } | |
463 | if (p->th != NULL) | 463 | if (p->th != NULL) |
464 | GNUNET_TRANSPORT_disconnect (p->th); | 464 | GNUNET_TRANSPORT_disconnect (p->th); |
465 | |||
466 | if (NULL != p->arm_proc) | 465 | if (NULL != p->arm_proc) |
467 | { | 466 | { |
468 | if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) | 467 | if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) |
@@ -471,35 +470,31 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, | |||
471 | GNUNET_OS_process_close (p->arm_proc); | 470 | GNUNET_OS_process_close (p->arm_proc); |
472 | p->arm_proc = NULL; | 471 | p->arm_proc = NULL; |
473 | } | 472 | } |
474 | |||
475 | if (p->hostkeyfile != NULL) | 473 | if (p->hostkeyfile != NULL) |
476 | { | 474 | { |
477 | GNUNET_DISK_directory_remove (p->hostkeyfile); | 475 | GNUNET_DISK_directory_remove (p->hostkeyfile); |
478 | GNUNET_free (p->hostkeyfile); | 476 | GNUNET_free (p->hostkeyfile); |
479 | } | 477 | } |
480 | |||
481 | if (p->servicehome != NULL) | 478 | if (p->servicehome != NULL) |
482 | { | 479 | { |
483 | GNUNET_DISK_directory_remove (p->servicehome); | 480 | GNUNET_DISK_directory_remove (p->servicehome); |
484 | GNUNET_free (p->servicehome); | 481 | GNUNET_free (p->servicehome); |
485 | } | 482 | } |
486 | |||
487 | if (p->hello != NULL) | 483 | if (p->hello != NULL) |
484 | { | ||
488 | GNUNET_free (p->hello); | 485 | GNUNET_free (p->hello); |
489 | p->hello = NULL; | 486 | p->hello = NULL; |
490 | 487 | } | |
491 | if (p->cfg != NULL) | 488 | if (p->cfg != NULL) |
489 | { | ||
492 | GNUNET_CONFIGURATION_destroy (p->cfg); | 490 | GNUNET_CONFIGURATION_destroy (p->cfg); |
493 | p->cfg = NULL; | 491 | p->cfg = NULL; |
494 | 492 | } | |
495 | GNUNET_CONTAINER_DLL_remove (tth->p_head, tth->p_tail, p); | 493 | GNUNET_CONTAINER_DLL_remove (tth->p_head, tth->p_tail, p); |
496 | |||
497 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | 494 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", |
498 | "Peer %u (`%s') stopped \n", p->no, | 495 | "Peer %u (`%s') stopped \n", p->no, |
499 | GNUNET_i2s (&p->id)); | 496 | GNUNET_i2s (&p->id)); |
500 | |||
501 | GNUNET_free (p); | 497 | GNUNET_free (p); |
502 | p = NULL; | ||
503 | } | 498 | } |
504 | 499 | ||
505 | 500 | ||
@@ -529,24 +524,18 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle * | |||
529 | 524 | ||
530 | GNUNET_assert (p1 != NULL); | 525 | GNUNET_assert (p1 != NULL); |
531 | GNUNET_assert (p2 != NULL); | 526 | GNUNET_assert (p2 != NULL); |
532 | |||
533 | cc->p1 = p1; | 527 | cc->p1 = p1; |
534 | cc->p2 = p2; | 528 | cc->p2 = p2; |
535 | |||
536 | cc->cb = cb; | 529 | cc->cb = cb; |
537 | if (cls != NULL) | 530 | if (cls != NULL) |
538 | cc->cb_cls = cls; | 531 | cc->cb_cls = cls; |
539 | else | 532 | else |
540 | cc->cb_cls = cc; | 533 | cc->cb_cls = cc; |
541 | |||
542 | cc->th_p1 = p1->th; | 534 | cc->th_p1 = p1->th; |
543 | cc->th_p2 = p2->th; | 535 | cc->th_p2 = p2->th; |
544 | |||
545 | GNUNET_assert (cc->th_p1 != NULL); | 536 | GNUNET_assert (cc->th_p1 != NULL); |
546 | GNUNET_assert (cc->th_p2 != NULL); | 537 | GNUNET_assert (cc->th_p2 != NULL); |
547 | |||
548 | GNUNET_CONTAINER_DLL_insert (tth->cc_head, tth->cc_tail, cc); | 538 | GNUNET_CONTAINER_DLL_insert (tth->cc_head, tth->cc_tail, cc); |
549 | |||
550 | cc->tct = GNUNET_SCHEDULER_add_now (&try_connect, cc); | 539 | cc->tct = GNUNET_SCHEDULER_add_now (&try_connect, cc); |
551 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | 540 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", |
552 | "New connect request %X\n", cc); | 541 | "New connect request %X\n", cc); |