Return ECONNABORTED from accept if connection is closed while on the

listen queue, as well as the current behavior of a zero-length sockaddr.

Obtained from: KAME
Reviewed by: -net
This commit is contained in:
Jonathan Lemon 2001-02-14 02:09:11 +00:00
parent cd8148eeb6
commit 2fd7d53d36
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=72471
2 changed files with 16 additions and 6 deletions

View File

@ -365,11 +365,8 @@ soaccept(so, nam)
so->so_state &= ~SS_NOFDREF;
if ((so->so_state & SS_ISDISCONNECTED) == 0)
error = (*so->so_proto->pr_usrreqs->pru_accept)(so, nam);
else {
if (nam)
*nam = 0;
error = 0;
}
else
error = ECONNABORTED;
splx(s);
return (error);
}

View File

@ -290,7 +290,19 @@ accept1(p, uap, compat)
nfp->f_ops = &socketops;
nfp->f_type = DTYPE_SOCKET;
sa = 0;
(void) soaccept(so, &sa);
error = soaccept(so, &sa);
if (error) {
/*
* return a namelen of zero for older code which might
* ignore the return value from accept.
*/
if (uap->name != NULL) {
namelen = 0;
(void) copyout((caddr_t)&namelen,
(caddr_t)uap->anamelen, sizeof(*uap->anamelen));
}
goto noconnection;
}
if (sa == NULL) {
namelen = 0;
if (uap->name)
@ -314,6 +326,7 @@ accept1(p, uap, compat)
error = copyout((caddr_t)&namelen,
(caddr_t)uap->anamelen, sizeof (*uap->anamelen));
}
noconnection:
if (sa)
FREE(sa, M_SONAME);