From 976473839da8f1978ea31015339858927d0bdbd2 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Fri, 17 Jun 2011 11:53:17 +0000 Subject: [PATCH] --- src/transport/test_transport_api.c | 15 ++++++++++++++- src/transport/test_transport_api_reliability.c | 16 ++++++++++++++-- .../test_transport_api_unreliability.c | 18 +++++++++++++++++- 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; static char * key_file_p2; static char * cert_file_p2; +struct GNUNET_TRANSPORT_TransmitHandle * th; + #if VERBOSE #define OKPP do { ok++; fprintf (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0) #else @@ -103,6 +105,10 @@ end () GNUNET_SCHEDULER_cancel (die_task); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n"); + if (th != NULL) + GNUNET_TRANSPORT_notify_transmit_ready_cancel(th); + th = NULL; + GNUNET_TRANSPORT_disconnect (p1.th); GNUNET_TRANSPORT_disconnect (p2.th); die_task = GNUNET_SCHEDULER_NO_TASK; @@ -130,6 +136,11 @@ end_badly () { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n"); GNUNET_break (0); + + if (th != NULL) + GNUNET_TRANSPORT_notify_transmit_ready_cancel(th); + th = NULL; + GNUNET_TRANSPORT_disconnect (p1.th); GNUNET_TRANSPORT_disconnect (p2.th); if (GNUNET_SCHEDULER_NO_TASK != tct) @@ -167,6 +178,8 @@ notify_ready (void *cls, size_t size, void *buf) struct PeerContext *p = cls; struct GNUNET_MessageHeader *hdr; + th = NULL; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting message with %u bytes to peer %s\n", sizeof (struct GNUNET_MessageHeader), @@ -244,7 +257,7 @@ notify_connect (void *cls, GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1); die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT_TRANSMIT, &end_badly, NULL); - GNUNET_TRANSPORT_notify_transmit_ready (p1.th, + th = GNUNET_TRANSPORT_notify_transmit_ready (p1.th, &p2.id, 256, 0, TIMEOUT, ¬ify_ready, &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; static GNUNET_SCHEDULER_TaskIdentifier tct; +struct GNUNET_TRANSPORT_TransmitHandle * th_p2; + static char * key_file_p1; static char * cert_file_p1; @@ -117,6 +119,11 @@ end () #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n"); #endif + + if (th_p2 != NULL) + GNUNET_TRANSPORT_notify_transmit_ready_cancel(th_p2); + th_p2 = NULL; + GNUNET_TRANSPORT_disconnect (p1.th); GNUNET_TRANSPORT_disconnect (p2.th); #if VERBOSE @@ -160,6 +167,10 @@ end_badly (void *cls, msg_scheduled, msg_recv, msg_recv_expected); + if (th_p2 != NULL) + GNUNET_TRANSPORT_notify_transmit_ready_cancel(th_p2); + th_p2 = NULL; + GNUNET_break (0); GNUNET_TRANSPORT_disconnect (p1.th); GNUNET_TRANSPORT_disconnect (p2.th); @@ -281,6 +292,7 @@ notify_ready (void *cls, size_t size, void *buf) ok = 42; return 0; } + th_p2 = NULL; ret = 0; s = get_size (n); GNUNET_assert (size >= s); @@ -313,7 +325,7 @@ notify_ready (void *cls, size_t size, void *buf) while (size - ret >= s); if (n < TOTAL_MSGS) { - GNUNET_TRANSPORT_notify_transmit_ready (p2.th, + th_p2 = GNUNET_TRANSPORT_notify_transmit_ready (p2.th, &p1.id, s, 0, TIMEOUT, ¬ify_ready, @@ -415,7 +427,7 @@ notify_connect (void *cls, GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1); die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); - GNUNET_TRANSPORT_notify_transmit_ready (p2.th, + th_p2 = GNUNET_TRANSPORT_notify_transmit_ready (p2.th, &p1.id, get_size (0), 0, TIMEOUT, ¬ify_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; static GNUNET_SCHEDULER_TaskIdentifier tct; +struct GNUNET_TRANSPORT_TransmitHandle * th_p2; + static char *key_file_p1; static char *cert_file_p1; @@ -167,6 +169,10 @@ end () #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n"); #endif + if (th_p2 != NULL) + GNUNET_TRANSPORT_notify_transmit_ready_cancel(th_p2); + th_p2 = NULL; + GNUNET_TRANSPORT_disconnect (p1.th); GNUNET_TRANSPORT_disconnect (p2.th); #if VERBOSE @@ -205,6 +211,9 @@ end_unreliably () #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n"); #endif + if (th_p2 != NULL) + GNUNET_TRANSPORT_notify_transmit_ready_cancel(th_p2); + GNUNET_TRANSPORT_disconnect (p1.th); GNUNET_TRANSPORT_disconnect (p2.th); #if VERBOSE @@ -253,6 +262,11 @@ end_badly (void *cls, msg_recv, msg_recv_expected); GNUNET_break (0); + + if (th_p2 != NULL) + GNUNET_TRANSPORT_notify_transmit_ready_cancel(th_p2); + th_p2 = NULL; + GNUNET_TRANSPORT_disconnect (p1.th); GNUNET_TRANSPORT_disconnect (p2.th); @@ -361,6 +375,8 @@ notify_ready (void *cls, size_t size, void *buf) unsigned int s; unsigned int ret; + th_p2 = NULL; + if (buf == NULL) { GNUNET_break (0); @@ -399,7 +415,7 @@ notify_ready (void *cls, size_t size, void *buf) while (size - ret >= s); if (n < TOTAL_MSGS) { - GNUNET_TRANSPORT_notify_transmit_ready (p2.th, + th_p2 = GNUNET_TRANSPORT_notify_transmit_ready (p2.th, &p1.id, s, 0, TIMEOUT, ¬ify_ready, -- 2.25.1