diff options
author | Jonathan Lemon <jlemon@FreeBSD.org> | 2001-02-24 18:37:26 +0000 |
---|---|---|
committer | Jonathan Lemon <jlemon@FreeBSD.org> | 2001-02-24 18:37:26 +0000 |
commit | 15e6a9638906570121159b1b38f2a1e880e9b7c4 (patch) | |
tree | 34fc983d875ea70b59a302dce919773825e7172f | |
parent | 9fe3e875bd36653358c5e13c17314fa9c09ad6df (diff) | |
download | src-15e6a9638906570121159b1b38f2a1e880e9b7c4.tar.gz src-15e6a9638906570121159b1b38f2a1e880e9b7c4.zip |
MFC: have accept return ECONNABORTED for sockets which are now gone.
Notes
Notes:
svn path=/stable/4/; revision=72983
-rw-r--r-- | sys/kern/uipc_socket.c | 7 | ||||
-rw-r--r-- | sys/kern/uipc_syscalls.c | 15 |
2 files changed, 16 insertions, 6 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 4c75b6ad500e..dda845c8e880 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -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); } diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index 8c2a8b3a1762..6421d9d77a1a 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -283,7 +283,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) @@ -307,6 +319,7 @@ gotnoname: error = copyout((caddr_t)&namelen, (caddr_t)uap->anamelen, sizeof (*uap->anamelen)); } +noconnection: if (sa) FREE(sa, M_SONAME); |