aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/io.c
diff options
context:
space:
mode:
authorRickard Green <[email protected]>2010-06-01 13:52:51 +0000
committerErlang/OTP <[email protected]>2010-06-01 13:52:51 +0000
commite9ffa6bab3583a4ddabe4f41218579503c8d4b95 (patch)
tree290b913bc6960c3aebdb9c2e865ca84ea1ca483c /erts/emulator/beam/io.c
parentc68f1802ce375c3425795671c74c6b3fd9c3a8ef (diff)
downloadotp-e9ffa6bab3583a4ddabe4f41218579503c8d4b95.tar.gz
otp-e9ffa6bab3583a4ddabe4f41218579503c8d4b95.tar.bz2
otp-e9ffa6bab3583a4ddabe4f41218579503c8d4b95.zip
OTP-8612 Fix potential premature destruction of port locks
Port locks could be prematurely destroyed.
Diffstat (limited to 'erts/emulator/beam/io.c')
-rw-r--r--erts/emulator/beam/io.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/erts/emulator/beam/io.c b/erts/emulator/beam/io.c
index 10f1082039..68625801cf 100644
--- a/erts/emulator/beam/io.c
+++ b/erts/emulator/beam/io.c
@@ -280,10 +280,36 @@ erts_test_next_port(int set, Uint next)
return res;
}
+
+static void port_cleanup(Port *prt);
+
+#ifdef ERTS_SMP
+
+static void
+sched_port_cleanup(void *vprt)
+{
+ Port *prt = (Port *) vprt;
+ erts_smp_mtx_lock(prt->lock);
+ port_cleanup(prt);
+}
+
+#endif
+
void
erts_port_cleanup(Port *prt)
{
#ifdef ERTS_SMP
+ if (erts_smp_mtx_trylock(prt->lock) == EBUSY)
+ erts_schedule_misc_op(sched_port_cleanup, (void *) prt);
+ else
+#endif
+ port_cleanup(prt);
+}
+
+void
+port_cleanup(Port *prt)
+{
+#ifdef ERTS_SMP
Uint32 port_specific;
erts_smp_mtx_t *mtx;
#endif