HomeFreeBSD

Make asynchronous connection failures on UNIX sockets fail with ECONNRESET.

Description

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

Details

Provenance
edAuthored on
Reviewer
cem
Differential Revision
D5419: Make asynchronous connection failures on UNIX sockets fail with ECONNRESET.
Parents
rS295973: db(3): Fix aliasing warnings from modern GCC.
Branches
Unknown
Tags
Unknown