summaryrefslogtreecommitdiff
path: root/nuttx/net/net_close.c
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-01-14 18:19:43 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-01-14 18:19:43 -0600
commit687245d6898eac03302b3f023090cb54c9e284c9 (patch)
tree21b2f25b085295af846b31fe49c5e755f6790f1a /nuttx/net/net_close.c
parentf2587c00c50e212ac9f045a7d80cbfe38ebc0d7b (diff)
downloadpx4-nuttx-687245d6898eac03302b3f023090cb54c9e284c9.tar.gz
px4-nuttx-687245d6898eac03302b3f023090cb54c9e284c9.tar.bz2
px4-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
Diffstat (limited to 'nuttx/net/net_close.c')
-rw-r--r--nuttx/net/net_close.c16
1 files changed, 14 insertions, 2 deletions
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 */