gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r29314 - in gnunet/src: include util


From: gnunet
Subject: [GNUnet-SVN] r29314 - in gnunet/src: include util
Date: Mon, 16 Sep 2013 15:19:52 +0200

Author: grothoff
Date: 2013-09-16 15:19:52 +0200 (Mon, 16 Sep 2013)
New Revision: 29314

Modified:
   gnunet/src/include/gnunet_network_lib.h
   gnunet/src/util/connection.c
   gnunet/src/util/network.c
Log:
add GNUNET_NETWORK_socket_free_memory_only_ API to allow getting raw FD and 
releasing struct without leaking 'addr' member

Modified: gnunet/src/include/gnunet_network_lib.h
===================================================================
--- gnunet/src/include/gnunet_network_lib.h     2013-09-16 13:12:15 UTC (rev 
29313)
+++ gnunet/src/include/gnunet_network_lib.h     2013-09-16 13:19:52 UTC (rev 
29314)
@@ -156,13 +156,22 @@
  * Close a socket.
  *
  * @param desc socket to close
- * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
  */
 int
 GNUNET_NETWORK_socket_close (struct GNUNET_NETWORK_Handle *desc);
 
 
 /**
+ * Only free memory of a socket, keep the file descriptor untouched.
+ *
+ * @param desc socket
+ */
+void
+GNUNET_NETWORK_socket_free_memory_only_ (struct GNUNET_NETWORK_Handle *desc);
+
+
+/**
  * Connect a socket to some remote address.
  *
  * @param desc socket to connect

Modified: gnunet/src/util/connection.c
===================================================================
--- gnunet/src/util/connection.c        2013-09-16 13:12:15 UTC (rev 29313)
+++ gnunet/src/util/connection.c        2013-09-16 13:19:52 UTC (rev 29314)
@@ -1001,8 +1001,10 @@
     if (GNUNET_YES != connection->persist)
       GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close 
(connection->sock));
     else
-      GNUNET_free (connection->sock); /* at least no memory leak (we 
deliberately
-                                      * leak the socket in this special case) 
... */
+    {
+      GNUNET_NETWORK_socket_free_memory_only_ (connection->sock); /* at least 
no memory leak (we deliberately
+                                                                  * leak the 
socket in this special case) ... */
+    }
   }
   GNUNET_free_non_null (connection->addr);
   GNUNET_free_non_null (connection->hostname);

Modified: gnunet/src/util/network.c
===================================================================
--- gnunet/src/util/network.c   2013-09-16 13:12:15 UTC (rev 29313)
+++ gnunet/src/util/network.c   2013-09-16 13:19:52 UTC (rev 29314)
@@ -473,9 +473,21 @@
   }
 #endif
 #endif
+  GNUNET_NETWORK_socket_free_memory_only_ (desc);
+  return (ret == 0) ? GNUNET_OK : GNUNET_SYSERR;
+}
+
+
+/**
+ * Only free memory of a socket, keep the file descriptor untouched.
+ *
+ * @param desc socket
+ */
+void
+GNUNET_NETWORK_socket_free_memory_only_ (struct GNUNET_NETWORK_Handle *desc)
+{
   GNUNET_free_non_null (desc->addr);
   GNUNET_free (desc);
-  return (ret == 0) ? GNUNET_OK : GNUNET_SYSERR;
 }
 
 




reply via email to

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