summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-01-29 16:30:47 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-01-29 16:30:47 -0600
commit64e60fcc1ed09b7ab23c96e4a3e117c6182f31be (patch)
tree4ddb19d2e0cbb08f8d263ff90585498c7e5a2f18 /nuttx
parent578c9bb8c39f9e917c303aeabe4375f84838ca7d (diff)
downloadpx4-nuttx-64e60fcc1ed09b7ab23c96e4a3e117c6182f31be.tar.gz
px4-nuttx-64e60fcc1ed09b7ab23c96e4a3e117c6182f31be.tar.bz2
px4-nuttx-64e60fcc1ed09b7ab23c96e4a3e117c6182f31be.zip
Networking: Fix a major TCP bug introduced with commit e71c09ce9777ff732cb60bd07fb43d85522f79d6. Some connection logic was reorder -- setting the socket got moved BEFORE the point where the check was made if the socket was already connected. The resulting behavior was odd: Telnet would connect, but then when you exit and reconnect, it would fail to connect. But then if try again, it would connect okay. So the symptom was connect-fail-connect-fail-...
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/net/socket/accept.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/nuttx/net/socket/accept.c b/nuttx/net/socket/accept.c
index e73f77228..3f8204b36 100644
--- a/nuttx/net/socket/accept.c
+++ b/nuttx/net/socket/accept.c
@@ -185,7 +185,7 @@ int accept(int sockfd, FAR struct sockaddr *addr, FAR socklen_t *addrlen)
if (addr)
{
- /* If an address is provided, then the lenght must also be provided. */
+ /* If an address is provided, then the length must also be provided. */
DEBUGASSERT(addrlen);
@@ -258,8 +258,6 @@ int accept(int sockfd, FAR struct sockaddr *addr, FAR socklen_t *addrlen)
pnewsock->s_domain = psock->s_domain;
pnewsock->s_type = SOCK_STREAM;
- pnewsock->s_flags |= _SF_CONNECTED;
- pnewsock->s_flags &= ~_SF_CLOSED;
/* Perform the correct accept operation for this address domain */
@@ -306,6 +304,10 @@ int accept(int sockfd, FAR struct sockaddr *addr, FAR socklen_t *addrlen)
}
#endif /* CONFIG_NET_TCP */
+ /* Mark the socket as connected. */
+
+ pnewsock->s_flags |= _SF_CONNECTED;
+ pnewsock->s_flags &= ~_SF_CLOSED;
return newfd;
errout_with_socket: