When re-connecting already connected datagram socket ensure to clean
up its pending error state, which may be set in some rare conditions resulting in connect() syscall returning that bogus error and making application believe that attempt to change association has failed, while it has not in fact. There is sockets/reconnect regression test which excersises this bug. MFC after: 2 weeks
This commit is contained in:
parent
da2fa15981
commit
fdf84ec4c6
@ -517,10 +517,19 @@ soconnect(so, nam, td)
|
||||
*/
|
||||
if (so->so_state & (SS_ISCONNECTED|SS_ISCONNECTING) &&
|
||||
((so->so_proto->pr_flags & PR_CONNREQUIRED) ||
|
||||
(error = sodisconnect(so))))
|
||||
(error = sodisconnect(so)))) {
|
||||
error = EISCONN;
|
||||
else
|
||||
} else {
|
||||
SOCK_LOCK(so);
|
||||
/*
|
||||
* Prevent accumulated error from previous connection
|
||||
* from biting us.
|
||||
*/
|
||||
so->so_error = 0;
|
||||
SOCK_UNLOCK(so);
|
||||
error = (*so->so_proto->pr_usrreqs->pru_connect)(so, nam, td);
|
||||
}
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user