(no commit message)
authorMatthias Wachs <wachs@net.in.tum.de>
Fri, 17 Jun 2011 11:53:17 +0000 (11:53 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Fri, 17 Jun 2011 11:53:17 +0000 (11:53 +0000)
src/transport/test_transport_api.c
src/transport/test_transport_api_reliability.c
src/transport/test_transport_api_unreliability.c

index ca9ceaef634884559fd7378505be305711b711f0..966f66fff2f027aa2aa264915b39e6c367286237 100644 (file)
@@ -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, &notify_ready,
                                              &p1);
index 4db329ad61e2f4b804d5f0d8b89ce5196565ad31..3964b43efdcf328cc0fdbcfabc45f7c26381a66b 100644 (file)
@@ -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,
                                            &notify_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,
                                               &notify_ready,
index 2101def806907ba098503054e2f3d570ca7e4e5b..90a53c2b8c91a1ede31631e23250122aac31d6f9 100644 (file)
@@ -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,
                                            &notify_ready,