gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r34463 - gnunet/src/nat


From: gnunet
Subject: [GNUnet-SVN] r34463 - gnunet/src/nat
Date: Mon, 1 Dec 2014 10:57:57 +0100

Author: grothoff
Date: 2014-12-01 10:57:57 +0100 (Mon, 01 Dec 2014)
New Revision: 34463

Modified:
   gnunet/src/nat/nat_test.c
   gnunet/src/nat/test_nat_test.c
Log:
-fix nat test timeout/termination issue

Modified: gnunet/src/nat/nat_test.c
===================================================================
--- gnunet/src/nat/nat_test.c   2014-11-30 21:00:06 UTC (rev 34462)
+++ gnunet/src/nat/nat_test.c   2014-12-01 09:57:57 UTC (rev 34463)
@@ -440,8 +440,10 @@
   nh->status = GNUNET_NAT_ERROR_SUCCESS;
   if (0 == bnd_port)
   {
-    nh->nat =
-        GNUNET_NAT_register (cfg, is_tcp, 0, 0, NULL, NULL, &addr_cb,
+    nh->nat 
+      = GNUNET_NAT_register (cfg, is_tcp, 0, 0, 
+                            NULL, NULL,
+                            &addr_cb,
                              &reversal_cb, nh);
   }
   else

Modified: gnunet/src/nat/test_nat_test.c
===================================================================
--- gnunet/src/nat/test_nat_test.c      2014-11-30 21:00:06 UTC (rev 34462)
+++ gnunet/src/nat/test_nat_test.c      2014-12-01 09:57:57 UTC (rev 34463)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2009, 2011 Christian Grothoff (and other contributing authors)
+     (C) 2009, 2011, 2014 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -17,10 +17,7 @@
      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      Boston, MA 02111-1307, USA.
 */
-
 /**
- * Testcase for the NAT testing code.
- *
  * @file nat/test_nat_test.c
  * @brief Testcase for NAT testing functions
  * @author Christian Grothoff
@@ -39,6 +36,9 @@
 
 static struct GNUNET_NAT_Test *tst;
 
+static GNUNET_SCHEDULER_TaskIdentifier tsk;
+
+
 static void
 report_result (void *cls,
                 enum GNUNET_NAT_StatusCode aret)
@@ -51,9 +51,26 @@
              "NAT test reported error %d\n", aret);
   else
     ret = 0;
+  GNUNET_NAT_test_stop (tst);
+  tst = NULL;
+  GNUNET_SCHEDULER_cancel (tsk);
+  tsk = GNUNET_SCHEDULER_NO_TASK;
 }
 
 
+static void
+failed_timeout (void *cls,
+               const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  tsk = GNUNET_SCHEDULER_NO_TASK;
+  fprintf (stderr,
+          "NAT test failed to terminate on timeout\n");
+  ret = 2;
+  GNUNET_NAT_test_stop (tst);
+  tst = NULL;
+}
+
+
 /**
  * Main function run with scheduler.
  */
@@ -65,6 +82,11 @@
       GNUNET_NAT_test_start (cfg, GNUNET_YES, 1285, 1285, TIMEOUT,
                              &report_result,
                              NULL);
+  tsk = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (TIMEOUT,
+                                                                    2),
+                                     &failed_timeout,
+                                     NULL);
+  
 }
 
 
@@ -104,7 +126,9 @@
                                  "-c", "test_nat_test_data.conf",
                                  "12345", NULL);
   GNUNET_assert (NULL != gns);
-  GNUNET_PROGRAM_run (3, argv_prog, "test-nat-test", "nohelp", options, &run,
+  GNUNET_PROGRAM_run (3, argv_prog,
+                     "test-nat-test", "nohelp", 
+                     options, &run,
                       NULL);
   GNUNET_break (0 == GNUNET_OS_process_kill (gns, GNUNET_TERM_SIG));
   GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (gns));




reply via email to

[Prev in Thread] Current Thread [Next in Thread]