aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/nifs/unix/unix_prim_file.c
diff options
context:
space:
mode:
authorJohn Högberg <[email protected]>2018-11-16 09:52:39 +0100
committerJohn Högberg <[email protected]>2018-11-16 09:52:39 +0100
commit200c2718e16c9186f3b4cdccaf989a31946a3f20 (patch)
treeca57a19b37349a6d5aa742c38bf5d87147340b0c /erts/emulator/nifs/unix/unix_prim_file.c
parentcf8aae2646bc0c200d44577ca2942d3b53bd30e9 (diff)
parent7c902ed60b759c30aabfecde52baa2d12b8885bd (diff)
downloadotp-200c2718e16c9186f3b4cdccaf989a31946a3f20.tar.gz
otp-200c2718e16c9186f3b4cdccaf989a31946a3f20.tar.bz2
otp-200c2718e16c9186f3b4cdccaf989a31946a3f20.zip
Merge branch 'john/erts/defer-orphan-file-close/OTP-15421/ERIERL-261' into maint
* john/erts/defer-orphan-file-close/OTP-15421/ERIERL-261: Fix broken assertion on monitor release Avoid closing files in gc/monitor callbacks
Diffstat (limited to 'erts/emulator/nifs/unix/unix_prim_file.c')
-rw-r--r--erts/emulator/nifs/unix/unix_prim_file.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/erts/emulator/nifs/unix/unix_prim_file.c b/erts/emulator/nifs/unix/unix_prim_file.c
index dea73db18a..169b193993 100644
--- a/erts/emulator/nifs/unix/unix_prim_file.c
+++ b/erts/emulator/nifs/unix/unix_prim_file.c
@@ -202,21 +202,24 @@ posix_errno_t efile_open(const efile_path_t *path, enum efile_modes_t modes,
return errno;
}
-int efile_close(efile_data_t *d) {
+int efile_close(efile_data_t *d, posix_errno_t *error) {
efile_unix_t *u = (efile_unix_t*)d;
int fd;
+ ASSERT(enif_thread_type() == ERL_NIF_THR_DIRTY_IO_SCHEDULER);
ASSERT(erts_atomic32_read_nob(&d->state) == EFILE_STATE_CLOSED);
ASSERT(u->fd != -1);
fd = u->fd;
u->fd = -1;
+ enif_release_resource(d);
+
/* close(2) either always closes (*BSD, Linux) or leaves the fd in an
* undefined state (POSIX 2008, Solaris), so we must not retry on EINTR. */
if(close(fd) < 0) {
- u->common.posix_errno = errno;
+ *error = errno;
return 0;
}