diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-01-14 18:19:43 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-01-14 18:19:43 -0600 |
commit | 687245d6898eac03302b3f023090cb54c9e284c9 (patch) | |
tree | 21b2f25b085295af846b31fe49c5e755f6790f1a | |
parent | f2587c00c50e212ac9f045a7d80cbfe38ebc0d7b (diff) | |
download | nuttx-687245d6898eac03302b3f023090cb54c9e284c9.tar.gz nuttx-687245d6898eac03302b3f023090cb54c9e284c9.tar.bz2 nuttx-687245d6898eac03302b3f023090cb54c9e284c9.zip |
If write buffering is enabled, then it is necessary to release the write buffer resources (callback structure) when the socket is closed
-rw-r--r-- | apps/netutils/telnetd/telnetd_driver.c | 14 | ||||
-rw-r--r-- | nuttx/ChangeLog | 9 | ||||
-rw-r--r-- | nuttx/net/net_close.c | 16 |
3 files changed, 31 insertions, 8 deletions
diff --git a/apps/netutils/telnetd/telnetd_driver.c b/apps/netutils/telnetd/telnetd_driver.c index 13d1e00e4..7f87b8c70 100644 --- a/apps/netutils/telnetd/telnetd_driver.c +++ b/apps/netutils/telnetd/telnetd_driver.c @@ -215,7 +215,7 @@ static void telnetd_getchar(FAR struct telnetd_dev_s *priv, uint8_t ch, * Name: telnetd_receive * * Description: - * Process a received telenet buffer + * Process a received Telnet buffer * ****************************************************************************/ @@ -500,12 +500,20 @@ static int telnetd_close(FAR struct file *filep) } else { - /* Unregister the character driver */ + /* Un-register the character driver */ ret = unregister_driver(devpath); if (ret < 0) { - nlldbg("Failed to unregister the driver %s: %d\n", devpath, ret); + /* NOTE: a return value of -EBUSY is not an error, it simply + * means that the Telnet driver is busy now and cannot be + * registered now because there are other sessions using the + * connection. The driver will be properly unregistered when + * the final session terminates. + */ + + nlldbg("Failed to unregister the driver %s: %d\n", + devpath, ret); } free(devpath); diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 68640e5a3..13d4bb777 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -6436,6 +6436,9 @@ in the PX4 GIT repository. * fs/fat/fs_fat32.c: A correction to FAT cluster allocation from Tridge via Lorenz Meier (2014-1-14). - * net/net_clone.c: Need to clone fields for TCP write buffering - as well (2014-1-14). - + * net/net_clone.c: If CONFIG_NET_TCP_WRITE_BUFFERS is selected, + then the socket-related write buffering information must copied + with the other cloned socket data (2014-1-14). + * net/net_close.c: If CONFIG_NET_TCP_WRITE_BUFFERS is selected, + then it is necessary to free the write buffere callback structure + when the socket is closed (2014-1-14). diff --git a/nuttx/net/net_close.c b/nuttx/net/net_close.c index 0d8a0cac1..7bec9237c 100644 --- a/nuttx/net/net_close.c +++ b/nuttx/net/net_close.c @@ -285,9 +285,21 @@ static inline int netclose_disconnect(FAR struct socket *psock) flags = uip_lock(); conn = (struct uip_conn*)psock->s_conn; - /* There shouldn't be any callbacks registered */ + /* If we have a semi-permanent write buffer callback in place, then + * release it now. + */ + +#ifdef CONFIG_NET_TCP_WRITE_BUFFERS + if (psock->s_sndcb) + { + uip_tcpcallbackfree(conn, psock->s_sndcb); + psock->s_sndcb = NULL; + } +#endif + + /* There shouldn't be any callbacks registered. */ - DEBUGASSERT(conn->list == NULL); + DEBUGASSERT(conn && conn->list == NULL); /* Check for the case where the host beat us and disconnected first */ |