aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_transport_api_bidirectional_connect.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/test_transport_api_bidirectional_connect.c')
-rw-r--r--src/transport/test_transport_api_bidirectional_connect.c58
1 files changed, 24 insertions, 34 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
65static GNUNET_SCHEDULER_TaskIdentifier send_task; 61static GNUNET_SCHEDULER_TaskIdentifier send_task;
66 62
67struct PeerContext *p1; 63static struct PeerContext *p1;
68 64
69struct PeerContext *p2; 65static struct PeerContext *p2;
70 66
71static GNUNET_TRANSPORT_TESTING_ConnectRequest cc1; 67static GNUNET_TRANSPORT_TESTING_ConnectRequest cc1;
72static GNUNET_TRANSPORT_TESTING_ConnectRequest cc2; 68static GNUNET_TRANSPORT_TESTING_ConnectRequest cc2;
73 69
74struct GNUNET_TRANSPORT_TransmitHandle *th; 70static struct GNUNET_TRANSPORT_TransmitHandle *th;
75
76struct GNUNET_TRANSPORT_TESTING_handle *tth;
77 71
78char *cfg_file_p1; 72static struct GNUNET_TRANSPORT_TESTING_handle *tth;
79 73
80char *cfg_file_p2; 74static char *cfg_file_p1;
81 75
82#if VERBOSE 76static 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
89static void 79static 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
109end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 101end_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
273static void 269static void
274testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) 270testing_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
296void 292
293static void
297start_cb (struct PeerContext *p, void *cls) 294start_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);