aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/sys/unix/sys_uds.c
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2018-06-12 15:25:38 +0200
committerLukas Larsson <[email protected]>2018-07-30 16:02:33 +0200
commit48bbcab1b0d51ed19ab5676aa712e976bc76ee97 (patch)
treee6615bba09431e96d532fb3b35d4e5e65159e22e /erts/emulator/sys/unix/sys_uds.c
parentafdea8a790903c4500185cf0459b23acf4bde062 (diff)
downloadotp-48bbcab1b0d51ed19ab5676aa712e976bc76ee97.tar.gz
otp-48bbcab1b0d51ed19ab5676aa712e976bc76ee97.tar.bz2
otp-48bbcab1b0d51ed19ab5676aa712e976bc76ee97.zip
erts: Handle EMFILE errors in forker_driver for write
Before this change, if a write to the uds failed due to EMFILE to ETOOMANYREFS the entire vm would crash. This change makes it so that an SIGCHLD is simulated to that the error is propagated to the user instead of terminating the VM.
Diffstat (limited to 'erts/emulator/sys/unix/sys_uds.c')
-rw-r--r--erts/emulator/sys/unix/sys_uds.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/erts/emulator/sys/unix/sys_uds.c b/erts/emulator/sys/unix/sys_uds.c
index c328fd00bb..39a4866065 100644
--- a/erts/emulator/sys/unix/sys_uds.c
+++ b/erts/emulator/sys/unix/sys_uds.c
@@ -132,7 +132,7 @@ sys_uds_writev(int fd, struct iovec *iov, size_t iov_len,
struct msghdr msg;
struct cmsghdr *cmsg = NULL;
- int res, i;
+ int res, i, error;
/* initialize socket message */
memset(&msg, 0, sizeof(struct msghdr));
@@ -173,11 +173,22 @@ sys_uds_writev(int fd, struct iovec *iov, size_t iov_len,
res = sendmsg(fd, &msg, flags);
+#ifdef ETOOMANYREFS
+ /* Linux may give ETOOMANYREFS when there are too many fds in transit.
+ We map this to EMFILE as bsd and other use this error code and we want
+ the behaviour to be the same on all OSs */
+ if (errno == ETOOMANYREFS)
+ errno = EMFILE;
+#endif
+ error = errno;
+
if (iov_len > MAXIOV)
free(iov[0].iov_base);
free(msg.msg_control);
+ errno = error;
+
return res;
}