Skip to content
Snippets Groups Projects
Commit 7f95e4fb authored by Gregory Nutt's avatar Gregory Nutt
Browse files

Networking: Fix a major TCP bug introduced with commit...

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-...
parent ebf1e121
No related branches found
No related tags found
No related merge requests found
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment