Fix leak in socket close

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@394 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2007-11-21 23:29:14 +00:00
parent b54499d254
commit 7d1031cc71
5 changed files with 26 additions and 10 deletions

View File

@ -233,4 +233,5 @@
* Add strcat() and strncat() * Add strcat() and strncat()
* Integrated uIP micro webserver * Integrated uIP micro webserver
* Corrected a serious bug in TCP queue management * Corrected a serious bug in TCP queue management
* Fix leak in socket close logic

View File

@ -358,14 +358,24 @@ is available that be used to build a NuttX-compatible arm-elf toolchain.</blockq
53272 428 3568 57268 dfb4 nuttx 53272 428 3568 57268 dfb4 nuttx
</pre> </pre>
<p><b>DM320 (ARM9)</b> <p><b>DM320 (ARM9)</b>
This build for the ARM9 target includes a signficant subset of OS This build for the ARM9 target includes a significant subset of OS
features, ethernet driver and full TCP/IP, UDP and (minimal) ICMP features, a filesystem, Ethernet driver, full TCP/IP, UDP and (minimal)
stacks (via uIP). (11/8/07) ICMP stacks (via uIP) and a small network test application: (11/8/07,
configuration netconfig, examples/nettest)
</p> </p>
<pre> <pre>
text data bss dec hex filename text data bss dec hex filename
49472 296 3972 53740 d1ec nuttx 49472 296 3972 53740 d1ec nuttx
</pre> </pre>
<p>
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)
</p>
<pre>
text data bss dec hex filename
52040 72 4148 56260 dbc4 nuttx
</pre>
<p><b>87C52</b> <p><b>87C52</b>
A reduced functionality OS test for the 8052 target requires only A reduced functionality OS test for the 8052 target requires only
about 18-19Kb: about 18-19Kb:
@ -694,6 +704,7 @@ Other memory:
* Add strcat() and strncat() * Add strcat() and strncat()
* Integrated uIP micro webserver * Integrated uIP micro webserver
* Corrected a serious bug in TCP queue management * Corrected a serious bug in TCP queue management
* Fix leak in socket close logic
</pre></ul> </pre></ul>
<table width ="100%"> <table width ="100%">

3
TODO
View File

@ -31,8 +31,9 @@ o C++ Support
o Network o Network
- Did not implement send() and sendto() timeouts. Option is setable via setsockopt, - Did not implement send() and sendto() timeouts. Option is setable via setsockopt,
but is not implemented. 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() Need to be re-written to use listen() and accept()
- uIP's netutils/webserver does not work reliably
- Should implement SOCK_RAW - Should implement SOCK_RAW
- accept() and recvfrom() need to return connection address - accept() and recvfrom() need to return connection address
- Performance Improvements (uIP is not very fast): - Performance Improvements (uIP is not very fast):

View File

@ -79,12 +79,16 @@ int net_close(int sockfd)
goto errout; 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) switch (psock->s_type)
{ {
case SOCK_STREAM: case SOCK_STREAM:
uip_tcpfree(psock->s_conn); {
struct uip_conn *conn = psock->s_conn;
uip_unlisten(conn);
uip_tcpfree(conn);
}
break; break;
#ifdef CONFIG_NET_UDP #ifdef CONFIG_NET_UDP
@ -97,11 +101,9 @@ int net_close(int sockfd)
goto errout; goto errout;
} }
/* Save the protocol type */ /* Then release the socket structure containing the connection */
psock->s_type = 0;
psock->s_conn = NULL;
sockfd_release(sockfd);
return OK; return OK;
errout: errout:

View File

@ -45,6 +45,7 @@
#include <assert.h> #include <assert.h>
#include <sched.h> #include <sched.h>
#include <errno.h> #include <errno.h>
#include <debug.h>
#include <net/uip/uip.h> #include <net/uip/uip.h>
#include <nuttx/net.h> #include <nuttx/net.h>