From 9612b1fff77dc50e797f23b587321c90ceffe953 Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Fri, 14 Aug 2015 19:45:44 +0200 Subject: erts: Fix uds socket handling for os x OS X is very strict in what it requires of you and also gives strange error codes for some errors. In this commit we remap EMSGSIZE to EMFILE and also precisely tune the amount of data we send on the socket so that we can recv only that data. If we try to recv more, recvmsg fails with EPIPE if the remote end has been closed. --- erts/emulator/sys/unix/sys_uds.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/erts/emulator/sys/unix/sys_uds.c b/erts/emulator/sys/unix/sys_uds.c index daebcb307b..015d0346a1 100644 --- a/erts/emulator/sys/unix/sys_uds.c +++ b/erts/emulator/sys/unix/sys_uds.c @@ -38,6 +38,14 @@ sys_uds_readv(int fd, struct iovec *iov, size_t iov_len, msg.msg_controllen = sizeof(ancillary_buff); if((res = recvmsg(fd, &msg, flags)) < 0) { +#if defined(__APPLE__) && defined(__MACH__) && !defined(__DARWIN__) + /* When some OS X versions run out of fd's + they give EMSGSIZE instead of EMFILE. + We remap this as we want the correct + error to appear for the user */ + if (errno == EMSGSIZE) + errno = EMFILE; +#endif return res; } -- cgit v1.2.3