diff options
author | ed <ed@FreeBSD.org> | 2016-02-24 17:10:32 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2016-02-24 17:10:32 +0000 |
commit | 0151167359a8bc3b31532df14e6ab1281ebda3e9 (patch) | |
tree | 090208b8347417bc76f46c157cf0d2bb5a3d124b | |
parent | b41bc87bfc60d65d12dd07c2f6a2ee4dfe06c6e7 (diff) | |
download | FreeBSD-src-0151167359a8bc3b31532df14e6ab1281ebda3e9.zip FreeBSD-src-0151167359a8bc3b31532df14e6ab1281ebda3e9.tar.gz |
Make asynchronous connection failures on UNIX sockets fail with ECONNRESET.
While making CloudABI work well on Linux, I discovered that I had a
FreeBSD-ism in one of my unit tests. The test did the following:
- Create UNIX socket 1, bind it, make it listen.
- Create UNIX socket 2, connect it to UNIX socket 1.
- Close UNIX socket 1.
- Obtain SO_ERROR from socket 2.
On FreeBSD this returns ECONNABORTED, while on Linux it returns
ECONNRESET. I dug through some of the relevant specifications[1] and it
looks like Linux is all right here. ECONNABORTED should only be returned
when the local connection (socket 2) is aborted; not the peer (socket 1).
It is of course slightly misleading: the function in which we set this
error is called uipc_abort(), but keep in mind that we're aborting the
peer, thus resetting the local socket.
[1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/connect.html
Reviewed by: cem
Sponsored by: Nuxi, the Netherlands
Differential Revision: https://reviews.freebsd.org/D5419
-rw-r--r-- | sys/kern/uipc_usrreq.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index e455b10..609151d 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -354,7 +354,7 @@ uipc_abort(struct socket *so) unp2 = unp->unp_conn; if (unp2 != NULL) { UNP_PCB_LOCK(unp2); - unp_drop(unp2, ECONNABORTED); + unp_drop(unp2, ECONNRESET); UNP_PCB_UNLOCK(unp2); } UNP_PCB_UNLOCK(unp); |