From 7d1031cc71009772ae0a4974b96f136cca4783de Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 21 Nov 2007 23:29:14 +0000 Subject: [PATCH] Fix leak in socket close git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@394 42af7a65-404d-4744-a932-0658087f49c3 --- ChangeLog | 1 + Documentation/NuttX.html | 17 ++++++++++++++--- TODO | 3 ++- net/net-close.c | 14 ++++++++------ net/net-sockets.c | 1 + 5 files changed, 26 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6543fbad91..cab2ef2036 100644 --- a/ChangeLog +++ b/ChangeLog @@ -233,4 +233,5 @@ * Add strcat() and strncat() * Integrated uIP micro webserver * Corrected a serious bug in TCP queue management + * Fix leak in socket close logic diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html index 2bee653cd0..870918360e 100644 --- a/Documentation/NuttX.html +++ b/Documentation/NuttX.html @@ -358,14 +358,24 @@ is available that be used to build a NuttX-compatible arm-elf toolchain.

DM320 (ARM9) - This build for the ARM9 target includes a signficant subset of OS - features, ethernet driver and full TCP/IP, UDP and (minimal) ICMP - stacks (via uIP). (11/8/07) + This build for the ARM9 target includes a significant subset of OS + features, a filesystem, Ethernet driver, full TCP/IP, UDP and (minimal) + ICMP stacks (via uIP) and a small network test application: (11/8/07, + configuration netconfig, examples/nettest)

    text    data     bss     dec     hex filename
   49472     296    3972   53740    d1ec nuttx
 
+

+ Another build for the ARM9 target includes a minimal OS feature + set, Ethernet driver, full TCP/IP and (minimal) ICMP stacks, and + a small webserver: (11/20/07, configuration uipconfig, examples/uip) +

+
+   text    data     bss     dec     hex filename
+  52040      72    4148   56260    dbc4 nuttx
+

87C52 A reduced functionality OS test for the 8052 target requires only about 18-19Kb: @@ -694,6 +704,7 @@ Other memory: * Add strcat() and strncat() * Integrated uIP micro webserver * Corrected a serious bug in TCP queue management + * Fix leak in socket close logic diff --git a/TODO b/TODO index 48f4896722..0b8220e004 100644 --- a/TODO +++ b/TODO @@ -31,8 +31,9 @@ o C++ Support o Network - Did not implement send() and sendto() timeouts. Option is setable via setsockopt, but is not implemented. -- netutils/telnetd (and maybe others) are seriously broken. +- uIP's netutils/telnetd (and maybe others) are seriously broken. Need to be re-written to use listen() and accept() +- uIP's netutils/webserver does not work reliably - Should implement SOCK_RAW - accept() and recvfrom() need to return connection address - Performance Improvements (uIP is not very fast): diff --git a/net/net-close.c b/net/net-close.c index ca28b510bd..c06e635d1c 100644 --- a/net/net-close.c +++ b/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/net/net-sockets.c b/net/net-sockets.c index 98f9413bdb..8be75def2a 100644 --- a/net/net-sockets.c +++ b/net/net-sockets.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include