summaryrefslogtreecommitdiff
path: root/nuttx/net
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-11-21 23:29:14 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-11-21 23:29:14 +0000
commit7a8e90a29697e9e19ba4c27236be2061f8c6b734 (patch)
treeb7a6cc62181646f0718234dbbddd1b7a01701850 /nuttx/net
parentfcc35e8419c3dbf653c304886a827b52efdab402 (diff)
downloadpx4-nuttx-7a8e90a29697e9e19ba4c27236be2061f8c6b734.tar.gz
px4-nuttx-7a8e90a29697e9e19ba4c27236be2061f8c6b734.tar.bz2
px4-nuttx-7a8e90a29697e9e19ba4c27236be2061f8c6b734.zip
Fix leak in socket close
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@394 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/net')
-rw-r--r--nuttx/net/net-close.c14
-rw-r--r--nuttx/net/net-sockets.c1
2 files changed, 9 insertions, 6 deletions
diff --git a/nuttx/net/net-close.c b/nuttx/net/net-close.c
index ca28b510b..c06e635d1 100644
--- a/nuttx/net/net-close.c
+++ b/nuttx/net/net-close.c
@@ -79,12 +79,16 @@ int net_close(int sockfd)
goto errout;
}
- /* Perform the close depending on the protocol type */
+ /* Perform uIP side of the close depending on the protocol type */
switch (psock->s_type)
{
case SOCK_STREAM:
- uip_tcpfree(psock->s_conn);
+ {
+ struct uip_conn *conn = psock->s_conn;
+ uip_unlisten(conn);
+ uip_tcpfree(conn);
+ }
break;
#ifdef CONFIG_NET_UDP
@@ -97,11 +101,9 @@ int net_close(int sockfd)
goto errout;
}
- /* Save the protocol type */
-
- psock->s_type = 0;
- psock->s_conn = NULL;
+ /* Then release the socket structure containing the connection */
+ sockfd_release(sockfd);
return OK;
errout:
diff --git a/nuttx/net/net-sockets.c b/nuttx/net/net-sockets.c
index 98f9413bd..8be75def2 100644
--- a/nuttx/net/net-sockets.c
+++ b/nuttx/net/net-sockets.c
@@ -45,6 +45,7 @@
#include <assert.h>
#include <sched.h>
#include <errno.h>
+#include <debug.h>
#include <net/uip/uip.h>
#include <nuttx/net.h>