aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2019-01-23 10:22:07 +0100
committerLukas Larsson <[email protected]>2019-01-23 10:22:07 +0100
commit3aba68193ab414cd807fe0757a6b6f8f20bd57ef (patch)
treecad82d8d0dee3357fd1c2f75417183e748753461
parentb487f750abe3b6bb8c3f1cf8615f6c2166e203ef (diff)
parent336eea33ebb8287736327370607c77a9589f7e0b (diff)
downloadotp-3aba68193ab414cd807fe0757a6b6f8f20bd57ef.tar.gz
otp-3aba68193ab414cd807fe0757a6b6f8f20bd57ef.tar.bz2
otp-3aba68193ab414cd807fe0757a6b6f8f20bd57ef.zip
Merge branch 'lukas/erts/fix_spawn_driver_early_close/OTP-15537' into maint
* lukas/erts/fix_spawn_driver_early_close/OTP-15537: erts: Fix too early close of spawn driver fd
-rw-r--r--erts/emulator/sys/unix/sys_drivers.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/erts/emulator/sys/unix/sys_drivers.c b/erts/emulator/sys/unix/sys_drivers.c
index 816bdea9c5..2f5459bee5 100644
--- a/erts/emulator/sys/unix/sys_drivers.c
+++ b/erts/emulator/sys/unix/sys_drivers.c
@@ -998,9 +998,9 @@ static void clear_fd_data(ErtsSysFdData *fdd)
fdd->psz = 0;
}
-static void nbio_stop_fd(ErlDrvPort prt, ErtsSysFdData *fdd)
+static void nbio_stop_fd(ErlDrvPort prt, ErtsSysFdData *fdd, int use)
{
- driver_select(prt, abs(fdd->fd), ERL_DRV_USE_NO_CALLBACK|DO_READ|DO_WRITE, 0);
+ driver_select(prt, abs(fdd->fd), use ? ERL_DRV_USE_NO_CALLBACK : 0|DO_READ|DO_WRITE, 0);
clear_fd_data(fdd);
SET_BLOCKING(abs(fdd->fd));
@@ -1020,11 +1020,11 @@ static void fd_stop(ErlDrvData ev) /* Does not close the fds */
if (dd->ifd) {
sz += sizeof(ErtsSysFdData);
- nbio_stop_fd(prt, dd->ifd);
+ nbio_stop_fd(prt, dd->ifd, 1);
}
if (dd->ofd && dd->ofd != dd->ifd) {
sz += sizeof(ErtsSysFdData);
- nbio_stop_fd(prt, dd->ofd);
+ nbio_stop_fd(prt, dd->ofd, 1);
}
erts_free(ERTS_ALC_T_DRV_TAB, dd);
@@ -1070,12 +1070,12 @@ static void stop(ErlDrvData ev)
ErlDrvPort prt = dd->port_num;
if (dd->ifd) {
- nbio_stop_fd(prt, dd->ifd);
+ nbio_stop_fd(prt, dd->ifd, 0);
driver_select(prt, abs(dd->ifd->fd), ERL_DRV_USE, 0); /* close(ifd); */
}
if (dd->ofd && dd->ofd != dd->ifd) {
- nbio_stop_fd(prt, dd->ofd);
+ nbio_stop_fd(prt, dd->ofd, 0);
driver_select(prt, abs(dd->ofd->fd), ERL_DRV_USE, 0); /* close(ofd); */
}