gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r34330 - in gnunet/src: include nat


From: gnunet
Subject: [GNUnet-SVN] r34330 - in gnunet/src: include nat
Date: Fri, 3 Oct 2014 22:48:59 +0200

Author: grothoff
Date: 2014-10-03 22:48:58 +0200 (Fri, 03 Oct 2014)
New Revision: 34330

Modified:
   gnunet/src/include/gnunet_nat_lib.h
   gnunet/src/nat/nat_test.c
Log:
-set socket to NULL on close to avoid double-close, do not cleanup on timeout, 
leave that to app

Modified: gnunet/src/include/gnunet_nat_lib.h
===================================================================
--- gnunet/src/include/gnunet_nat_lib.h 2014-10-03 18:59:15 UTC (rev 34329)
+++ gnunet/src/include/gnunet_nat_lib.h 2014-10-03 20:48:58 UTC (rev 34330)
@@ -73,120 +73,120 @@
 /**
  * Error Types for the NAT subsystem (which can then later be 
converted/resolved to a string)
  */
-enum GNUNET_NAT_StatusCode 
+enum GNUNET_NAT_StatusCode
 {
   /**
    * Just the default
    */
   GNUNET_NAT_ERROR_SUCCESS = GNUNET_OK,
-  
+
   /**
    * IPC Failure
    */
   GNUNET_NAT_ERROR_IPC_FAILURE,
-  
+
   /**
    * Failure in network subsystem, check permissions
    */
   GNUNET_NAT_ERROR_INTERNAL_NETWORK_ERROR,
-  
+
   /**
    * test timed out
    */
   GNUNET_NAT_ERROR_TIMEOUT,
-  
+
   /**
    * detected that we are offline
    */
   GNUNET_NAT_ERROR_NOT_ONLINE,
-  
+
   /**
    * `upnpc` command not found
    */
   GNUNET_NAT_ERROR_UPNPC_NOT_FOUND,
-  
+
   /**
    * Failed to run `upnpc` command
    */
   GNUNET_NAT_ERROR_UPNPC_FAILED,
-  
+
   /**
    * `upnpc' command took too long, process killed
    */
   GNUNET_NAT_ERROR_UPNPC_TIMEOUT,
-  
+
   /**
    * `upnpc' command failed to establish port mapping
    */
   GNUNET_NAT_ERROR_UPNPC_PORTMAP_FAILED,
-  
+
   /**
    * `external-ip' command not found
    */
   GNUNET_NAT_ERROR_EXTERNAL_IP_UTILITY_NOT_FOUND,
-  
+
   /**
    * Failed to run `external-ip` command
    */
   GNUNET_NAT_ERROR_EXTERNAL_IP_UTILITY_FAILED,
-  
+
   /**
    * `external-ip' command output invalid
    */
   GNUNET_NAT_ERROR_EXTERNAL_IP_UTILITY_OUTPUT_INVALID,
-  
+
   /**
    * "no valid address was returned by `external-ip'"
    */
   GNUNET_NAT_ERROR_EXTERNAL_IP_ADDRESS_INVALID,
-  
+
   /**
    * Could not determine interface with internal/local network address
    */
   GNUNET_NAT_ERROR_NO_VALID_IF_IP_COMBO,
-          
+
   /**
    * No working gnunet-helper-nat-server found
    */
   GNUNET_NAT_ERROR_HELPER_NAT_SERVER_NOT_FOUND,
-  
+
   /**
    * NAT test could not be initialized
    */
   GNUNET_NAT_ERROR_NAT_TEST_START_FAILED,
-  
+
   /**
    * NAT test timeout
    */
   GNUNET_NAT_ERROR_NAT_TEST_TIMEOUT,
-  
+
   /**
    * NAT test failed to initiate
    */
   GNUNET_NAT_ERROR_NAT_REGISTER_FAILED,
-  
+
   /**
-   * 
+   *
    */
   GNUNET_NAT_ERROR_HELPER_NAT_CLIENT_NOT_FOUND,
-  
-  
+
   /**
-   * 
+   *
    */
   GNUNET_NAT_ERROR_
 };
 
 
 /**
- * Converts enum GNUNET_NAT_StatusCode to string
- * 
+ * Converts `enum GNUNET_NAT_StatusCode` to string
+ *
  * @param err error code to resolve to a string
  * @return point to a static string containing the error code
  */
 const char *
 GNUNET_NAT_status2string (enum GNUNET_NAT_StatusCode err);
 
+
 /**
  * Attempt to enable port redirection and detect public IP address
  * contacting UPnP or NAT-PMP routers on the local network. Use addr
@@ -289,7 +289,8 @@
  * @param bnd_port port to bind to, 0 for connection reversal
  * @param adv_port externally advertised port to use
  * @param timeout delay after which the test should be aborted
- * @param report function to call with the result of the test
+ * @param report function to call with the result of the test;
+ *               you still must call #GNUNET_NAT_test_stop().
  * @param report_cls closure for @a report
  * @return handle to cancel NAT test
  */

Modified: gnunet/src/nat/nat_test.c
===================================================================
--- gnunet/src/nat/nat_test.c   2014-10-03 18:59:15 UTC (rev 34329)
+++ gnunet/src/nat/nat_test.c   2014-10-03 20:48:58 UTC (rev 34330)
@@ -391,7 +391,6 @@
               (GNUNET_NAT_ERROR_SUCCESS == nh->status)
               ? GNUNET_NAT_ERROR_TIMEOUT
               : nh->status);
-  GNUNET_NAT_test_stop (nh);
 }
 
 
@@ -462,7 +461,10 @@
                   GNUNET_a2s ((const struct sockaddr *) &sa, sizeof (sa)),
                   STRERROR (errno));
       if (NULL != nh->lsock)
+      {
         GNUNET_NETWORK_socket_close (nh->lsock);
+        nh->lsock = NULL;
+      }
       nh->status = GNUNET_NAT_ERROR_INTERNAL_NETWORK_ERROR;
       nh->ttask = GNUNET_SCHEDULER_add_now (&do_timeout, nh);
       return nh;




reply via email to

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