aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/io.c
diff options
context:
space:
mode:
authorRaimo Niskanen <[email protected]>2012-03-20 09:49:09 +0100
committerRaimo Niskanen <[email protected]>2012-03-21 10:20:00 +0100
commit5b740336b0d7d0aec7c4df3b3e5c968ec0456766 (patch)
treec185f7f25de7928bdce3254db202ec125d077696 /erts/emulator/beam/io.c
parent1247343914e96b2516f628cce5658a4d21ecf6b2 (diff)
downloadotp-5b740336b0d7d0aec7c4df3b3e5c968ec0456766.tar.gz
otp-5b740336b0d7d0aec7c4df3b3e5c968ec0456766.tar.bz2
otp-5b740336b0d7d0aec7c4df3b3e5c968ec0456766.zip
erts: Implement erl_halt
Diffstat (limited to 'erts/emulator/beam/io.c')
-rw-r--r--erts/emulator/beam/io.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/erts/emulator/beam/io.c b/erts/emulator/beam/io.c
index b23b1f628d..591eb834e6 100644
--- a/erts/emulator/beam/io.c
+++ b/erts/emulator/beam/io.c
@@ -1837,6 +1837,7 @@ terminate_port(Port *prt)
Eterm send_closed_port_id;
Eterm connected_id = NIL /* Initialize to silence compiler */;
erts_driver_t *drv;
+ int halt;
ERTS_SMP_CHK_NO_PROC_LOCKS;
ERTS_SMP_LC_ASSERT(erts_lc_is_port_locked(prt));
@@ -1844,6 +1845,8 @@ terminate_port(Port *prt)
ASSERT(!prt->nlinks);
ASSERT(!prt->monitors);
+ /* prt->status may be altered by kill_port()below */
+ halt = (prt->status & ERTS_PORT_SFLG_HALT) != 0;
if (prt->status & ERTS_PORT_SFLG_SEND_CLOSED) {
erts_port_status_band_set(prt, ~ERTS_PORT_SFLG_SEND_CLOSED);
send_closed_port_id = prt->id;
@@ -1895,6 +1898,10 @@ terminate_port(Port *prt)
* We don't want to send the closed message until after the
* port has been removed from the port table (in kill_port()).
*/
+ if (halt && (erts_smp_atomic32_dec_read_nob(&erts_halt_progress) == 0)) {
+ erts_smp_port_unlock(prt); /* We will exit and never return */
+ erl_exit_flush_async(erts_halt_code, "");
+ }
if (is_internal_port(send_closed_port_id))
deliver_result(send_closed_port_id, connected_id, am_closed);