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-...
This commit is contained in:
parent
ebf1e121b5
commit
7f95e4fb2c
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue