diff options
author | Lukas Larsson <[email protected]> | 2018-06-12 15:25:38 +0200 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2018-07-30 16:02:33 +0200 |
commit | 48bbcab1b0d51ed19ab5676aa712e976bc76ee97 (patch) | |
tree | e6615bba09431e96d532fb3b35d4e5e65159e22e /erts/emulator/sys/unix/sys_uds.c | |
parent | afdea8a790903c4500185cf0459b23acf4bde062 (diff) | |
download | otp-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.c | 13 |
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; } |