aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-06-17 11:53:17 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-06-17 11:53:17 +0000
commit976473839da8f1978ea31015339858927d0bdbd2 (patch)
tree4892e35713222a1849c3442713d5cdaab04f4b36 /src/transport
parentea8801774f9dcc2bbe7c7f61c4686d80b7e4d365 (diff)
downloadgnunet-976473839da8f1978ea31015339858927d0bdbd2.tar.gz
gnunet-976473839da8f1978ea31015339858927d0bdbd2.zip
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/test_transport_api.c15
-rw-r--r--src/transport/test_transport_api_reliability.c16
-rw-r--r--src/transport/test_transport_api_unreliability.c18
3 files changed, 45 insertions, 4 deletions
diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c
index ca9ceaef6..966f66fff 100644
--- a/src/transport/test_transport_api.c
+++ b/src/transport/test_transport_api.c
@@ -89,6 +89,8 @@ static char * cert_file_p1;
89static char * key_file_p2; 89static char * key_file_p2;
90static char * cert_file_p2; 90static char * cert_file_p2;
91 91
92struct GNUNET_TRANSPORT_TransmitHandle * th;
93
92#if VERBOSE 94#if VERBOSE
93#define OKPP do { ok++; fprintf (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0) 95#define OKPP do { ok++; fprintf (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0)
94#else 96#else
@@ -103,6 +105,10 @@ end ()
103 GNUNET_SCHEDULER_cancel (die_task); 105 GNUNET_SCHEDULER_cancel (die_task);
104 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 106 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
105 "Disconnecting from transports!\n"); 107 "Disconnecting from transports!\n");
108 if (th != NULL)
109 GNUNET_TRANSPORT_notify_transmit_ready_cancel(th);
110 th = NULL;
111
106 GNUNET_TRANSPORT_disconnect (p1.th); 112 GNUNET_TRANSPORT_disconnect (p1.th);
107 GNUNET_TRANSPORT_disconnect (p2.th); 113 GNUNET_TRANSPORT_disconnect (p2.th);
108 die_task = GNUNET_SCHEDULER_NO_TASK; 114 die_task = GNUNET_SCHEDULER_NO_TASK;
@@ -130,6 +136,11 @@ end_badly ()
130{ 136{
131 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n"); 137 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n");
132 GNUNET_break (0); 138 GNUNET_break (0);
139
140 if (th != NULL)
141 GNUNET_TRANSPORT_notify_transmit_ready_cancel(th);
142 th = NULL;
143
133 GNUNET_TRANSPORT_disconnect (p1.th); 144 GNUNET_TRANSPORT_disconnect (p1.th);
134 GNUNET_TRANSPORT_disconnect (p2.th); 145 GNUNET_TRANSPORT_disconnect (p2.th);
135 if (GNUNET_SCHEDULER_NO_TASK != tct) 146 if (GNUNET_SCHEDULER_NO_TASK != tct)
@@ -167,6 +178,8 @@ notify_ready (void *cls, size_t size, void *buf)
167 struct PeerContext *p = cls; 178 struct PeerContext *p = cls;
168 struct GNUNET_MessageHeader *hdr; 179 struct GNUNET_MessageHeader *hdr;
169 180
181 th = NULL;
182
170 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 183 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
171 "Transmitting message with %u bytes to peer %s\n", 184 "Transmitting message with %u bytes to peer %s\n",
172 sizeof (struct GNUNET_MessageHeader), 185 sizeof (struct GNUNET_MessageHeader),
@@ -244,7 +257,7 @@ notify_connect (void *cls,
244 GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1); 257 GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
245 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT_TRANSMIT, 258 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT_TRANSMIT,
246 &end_badly, NULL); 259 &end_badly, NULL);
247 GNUNET_TRANSPORT_notify_transmit_ready (p1.th, 260 th = GNUNET_TRANSPORT_notify_transmit_ready (p1.th,
248 &p2.id, 261 &p2.id,
249 256, 0, TIMEOUT, &notify_ready, 262 256, 0, TIMEOUT, &notify_ready,
250 &p1); 263 &p1);
diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c
index 4db329ad6..3964b43ef 100644
--- a/src/transport/test_transport_api_reliability.c
+++ b/src/transport/test_transport_api_reliability.c
@@ -88,6 +88,8 @@ static GNUNET_SCHEDULER_TaskIdentifier die_task;
88 88
89static GNUNET_SCHEDULER_TaskIdentifier tct; 89static GNUNET_SCHEDULER_TaskIdentifier tct;
90 90
91struct GNUNET_TRANSPORT_TransmitHandle * th_p2;
92
91static char * key_file_p1; 93static char * key_file_p1;
92static char * cert_file_p1; 94static char * cert_file_p1;
93 95
@@ -117,6 +119,11 @@ end ()
117#if VERBOSE 119#if VERBOSE
118 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n"); 120 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n");
119#endif 121#endif
122
123 if (th_p2 != NULL)
124 GNUNET_TRANSPORT_notify_transmit_ready_cancel(th_p2);
125 th_p2 = NULL;
126
120 GNUNET_TRANSPORT_disconnect (p1.th); 127 GNUNET_TRANSPORT_disconnect (p1.th);
121 GNUNET_TRANSPORT_disconnect (p2.th); 128 GNUNET_TRANSPORT_disconnect (p2.th);
122#if VERBOSE 129#if VERBOSE
@@ -160,6 +167,10 @@ end_badly (void *cls,
160 msg_scheduled, 167 msg_scheduled,
161 msg_recv, 168 msg_recv,
162 msg_recv_expected); 169 msg_recv_expected);
170 if (th_p2 != NULL)
171 GNUNET_TRANSPORT_notify_transmit_ready_cancel(th_p2);
172 th_p2 = NULL;
173
163 GNUNET_break (0); 174 GNUNET_break (0);
164 GNUNET_TRANSPORT_disconnect (p1.th); 175 GNUNET_TRANSPORT_disconnect (p1.th);
165 GNUNET_TRANSPORT_disconnect (p2.th); 176 GNUNET_TRANSPORT_disconnect (p2.th);
@@ -281,6 +292,7 @@ notify_ready (void *cls, size_t size, void *buf)
281 ok = 42; 292 ok = 42;
282 return 0; 293 return 0;
283 } 294 }
295 th_p2 = NULL;
284 ret = 0; 296 ret = 0;
285 s = get_size (n); 297 s = get_size (n);
286 GNUNET_assert (size >= s); 298 GNUNET_assert (size >= s);
@@ -313,7 +325,7 @@ notify_ready (void *cls, size_t size, void *buf)
313 while (size - ret >= s); 325 while (size - ret >= s);
314 if (n < TOTAL_MSGS) 326 if (n < TOTAL_MSGS)
315 { 327 {
316 GNUNET_TRANSPORT_notify_transmit_ready (p2.th, 328 th_p2 = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
317 &p1.id, 329 &p1.id,
318 s, 0, TIMEOUT, 330 s, 0, TIMEOUT,
319 &notify_ready, 331 &notify_ready,
@@ -415,7 +427,7 @@ notify_connect (void *cls,
415 GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1); 427 GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
416 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 428 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
417 &end_badly, NULL); 429 &end_badly, NULL);
418 GNUNET_TRANSPORT_notify_transmit_ready (p2.th, 430 th_p2 = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
419 &p1.id, 431 &p1.id,
420 get_size (0), 0, TIMEOUT, 432 get_size (0), 0, TIMEOUT,
421 &notify_ready, 433 &notify_ready,
diff --git a/src/transport/test_transport_api_unreliability.c b/src/transport/test_transport_api_unreliability.c
index 2101def80..90a53c2b8 100644
--- a/src/transport/test_transport_api_unreliability.c
+++ b/src/transport/test_transport_api_unreliability.c
@@ -91,6 +91,8 @@ static GNUNET_SCHEDULER_TaskIdentifier die_task;
91 91
92static GNUNET_SCHEDULER_TaskIdentifier tct; 92static GNUNET_SCHEDULER_TaskIdentifier tct;
93 93
94struct GNUNET_TRANSPORT_TransmitHandle * th_p2;
95
94static char *key_file_p1; 96static char *key_file_p1;
95static char *cert_file_p1; 97static char *cert_file_p1;
96 98
@@ -167,6 +169,10 @@ end ()
167#if VERBOSE 169#if VERBOSE
168 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n"); 170 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n");
169#endif 171#endif
172 if (th_p2 != NULL)
173 GNUNET_TRANSPORT_notify_transmit_ready_cancel(th_p2);
174 th_p2 = NULL;
175
170 GNUNET_TRANSPORT_disconnect (p1.th); 176 GNUNET_TRANSPORT_disconnect (p1.th);
171 GNUNET_TRANSPORT_disconnect (p2.th); 177 GNUNET_TRANSPORT_disconnect (p2.th);
172#if VERBOSE 178#if VERBOSE
@@ -205,6 +211,9 @@ end_unreliably ()
205#if VERBOSE 211#if VERBOSE
206 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n"); 212 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n");
207#endif 213#endif
214 if (th_p2 != NULL)
215 GNUNET_TRANSPORT_notify_transmit_ready_cancel(th_p2);
216
208 GNUNET_TRANSPORT_disconnect (p1.th); 217 GNUNET_TRANSPORT_disconnect (p1.th);
209 GNUNET_TRANSPORT_disconnect (p2.th); 218 GNUNET_TRANSPORT_disconnect (p2.th);
210#if VERBOSE 219#if VERBOSE
@@ -253,6 +262,11 @@ end_badly (void *cls,
253 msg_recv, 262 msg_recv,
254 msg_recv_expected); 263 msg_recv_expected);
255 GNUNET_break (0); 264 GNUNET_break (0);
265
266 if (th_p2 != NULL)
267 GNUNET_TRANSPORT_notify_transmit_ready_cancel(th_p2);
268 th_p2 = NULL;
269
256 GNUNET_TRANSPORT_disconnect (p1.th); 270 GNUNET_TRANSPORT_disconnect (p1.th);
257 GNUNET_TRANSPORT_disconnect (p2.th); 271 GNUNET_TRANSPORT_disconnect (p2.th);
258 272
@@ -361,6 +375,8 @@ notify_ready (void *cls, size_t size, void *buf)
361 unsigned int s; 375 unsigned int s;
362 unsigned int ret; 376 unsigned int ret;
363 377
378 th_p2 = NULL;
379
364 if (buf == NULL) 380 if (buf == NULL)
365 { 381 {
366 GNUNET_break (0); 382 GNUNET_break (0);
@@ -399,7 +415,7 @@ notify_ready (void *cls, size_t size, void *buf)
399 while (size - ret >= s); 415 while (size - ret >= s);
400 if (n < TOTAL_MSGS) 416 if (n < TOTAL_MSGS)
401 { 417 {
402 GNUNET_TRANSPORT_notify_transmit_ready (p2.th, 418 th_p2 = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
403 &p1.id, 419 &p1.id,
404 s, 0, TIMEOUT, 420 s, 0, TIMEOUT,
405 &notify_ready, 421 &notify_ready,