summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-09-06 08:25:03 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-09-06 08:25:03 -0600
commit70d21b8c25966310cf3fc123092f10f297e8a653 (patch)
tree2999033d5609b272adf855f07fbf528f04cffe53
parente93f724725d6fcab54560cba0972ff56ce3c4619 (diff)
downloadpx4-nuttx-70d21b8c25966310cf3fc123092f10f297e8a653.tar.gz
px4-nuttx-70d21b8c25966310cf3fc123092f10f297e8a653.tar.bz2
px4-nuttx-70d21b8c25966310cf3fc123092f10f297e8a653.zip
Networking: Fix race condition that can cause missing loss-of-connection events. From Max Holtzberg
-rw-r--r--nuttx/ChangeLog3
-rw-r--r--nuttx/net/net_monitor.c11
2 files changed, 14 insertions, 0 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index c49f6bea8..6acf9db80 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -5502,4 +5502,7 @@
changes made to pl2303, but untested (2013-9-5).
* arch/arm/src/sama5/sam_udphs.c: The high-speed device side driver
is now functional (although more testing is always needed) (2013-9-5).
+ * net/net_monitor.c: Fixes a race condition where a loss of connection
+ may not be detected when the connection is lost before it has been
+ accepted (from Max Holtzberg) (2013-9-6).
diff --git a/nuttx/net/net_monitor.c b/nuttx/net/net_monitor.c
index 1eeb4bd27..12907fa42 100644
--- a/nuttx/net/net_monitor.c
+++ b/nuttx/net/net_monitor.c
@@ -132,6 +132,17 @@ int net_startmonitor(FAR struct socket *psock)
conn->connection_private = (void*)psock;
conn->connection_event = connection_event;
+
+ /* Check if the connection has already been closed before any callbacks have
+ * been registered. (Maybe the connection is lost before accept has registered
+ * the monitoring callback.)
+ */
+
+ if (conn->tcpstateflags == UIP_CLOSED)
+ {
+ connection_event(conn, UIP_CLOSE);
+ }
+
return OK;
}