summaryrefslogtreecommitdiff
path: root/nuttx/net
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-06-02 07:48:05 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-06-02 07:48:05 -0600
commitd053fe603702149e4d552045b65060ffce872e62 (patch)
tree1536c127af7b79d6496a8c85ea9ed3d71ce4d523 /nuttx/net
parente911365abab2e8999fb41dc5b97531c0049b6392 (diff)
downloadpx4-nuttx-d053fe603702149e4d552045b65060ffce872e62.tar.gz
px4-nuttx-d053fe603702149e4d552045b65060ffce872e62.tar.bz2
px4-nuttx-d053fe603702149e4d552045b65060ffce872e62.zip
NET: Improvements to TCP connection fallback logic; Not needed with SO_LINGER. From Max Holtzberg
Diffstat (limited to 'nuttx/net')
-rw-r--r--nuttx/net/uip/uip_tcpconn.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/nuttx/net/uip/uip_tcpconn.c b/nuttx/net/uip/uip_tcpconn.c
index 2a2ce2a54..212b78632 100644
--- a/nuttx/net/uip/uip_tcpconn.c
+++ b/nuttx/net/uip/uip_tcpconn.c
@@ -217,6 +217,7 @@ struct uip_conn *uip_tcpalloc(void)
conn = (struct uip_conn *)dq_remfirst(&g_free_tcp_connections);
+#ifndef CONFIG_NET_SOLINGER
/* Is the free list empty? */
if (!conn)
@@ -224,7 +225,7 @@ struct uip_conn *uip_tcpalloc(void)
/* As a fall-back, check for connection structures which can be stalled.
*
* Search the active connection list for the oldest connection
- * that is in the UIP_TIME_WAIT or UIP_FIN_WAIT_1 state.
+ * that is about to be closed anyway.
*/
FAR struct uip_conn *tmp =
@@ -234,13 +235,17 @@ struct uip_conn *uip_tcpalloc(void)
{
nllvdbg("conn: %p state: %02x\n", tmp, tmp->tcpstateflags);
- /* Is this connection in a state we can sacrifice.
- * REVISIT: maybe UIP_FIN_WAIT_1 is too harsh? There should be a
- * higher priority for UIP_TIME_WAIT
+ /* Is this connection in a state we can sacrifice. */
+
+ /* REVISIT: maybe we could check for SO_LINGER but it's buried
+ * in the socket layer.
*/
- if (tmp->tcpstateflags == UIP_TIME_WAIT ||
- tmp->tcpstateflags == UIP_FIN_WAIT_1)
+ if (tmp->tcpstateflags == UIP_CLOSING ||
+ tmp->tcpstateflags == UIP_FIN_WAIT_1 ||
+ tmp->tcpstateflags == UIP_FIN_WAIT_2 ||
+ tmp->tcpstateflags == UIP_TIME_WAIT ||
+ tmp->tcpstateflags == UIP_LAST_ACK)
{
/* Yes.. Is it the oldest one we have seen so far? */
@@ -269,6 +274,11 @@ struct uip_conn *uip_tcpalloc(void)
*
* REVISIT: Could there be any higher level, socket interface
* that needs to be informed that we did this to them?
+ *
+ * Actually yes. When CONFIG_NET_SOLINGER is enabled there is a
+ * pending callback in netclose_disconnect waiting for getting
+ * woken up. Otherwise there's the callback too, but no one is
+ * waiting for it.
*/
uip_tcpfree(conn);
@@ -278,6 +288,7 @@ struct uip_conn *uip_tcpalloc(void)
conn = (struct uip_conn *)dq_remfirst(&g_free_tcp_connections);
}
}
+#endif
uip_unlock(flags);