aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRickard Green <[email protected]>2017-08-24 15:59:46 +0200
committerRickard Green <[email protected]>2017-08-24 15:59:46 +0200
commitec2c32e2ef0c824046bea1accd34ff383938461c (patch)
treed758f69e80491f626832581158840bd23d0aa991
parent27058d210eb3b6bdfa697de6d18fd1623af32efb (diff)
parent6c8d1ac3112a0cc61849741fd667bbccfa01ee54 (diff)
downloadotp-ec2c32e2ef0c824046bea1accd34ff383938461c.tar.gz
otp-ec2c32e2ef0c824046bea1accd34ff383938461c.tar.bz2
otp-ec2c32e2ef0c824046bea1accd34ff383938461c.zip
Merge branch 'maint'
* maint: Fix BIF timer race between timeout and auto cleanup Conflicts: erts/emulator/beam/erl_hl_timer.c
-rw-r--r--erts/emulator/beam/erl_hl_timer.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/erts/emulator/beam/erl_hl_timer.c b/erts/emulator/beam/erl_hl_timer.c
index d61c1e5bbf..bda2c9b94d 100644
--- a/erts/emulator/beam/erl_hl_timer.c
+++ b/erts/emulator/beam/erl_hl_timer.c
@@ -1256,14 +1256,15 @@ bif_timer_timeout(ErtsHLTimerService *srv,
ERTS_HLT_ASSERT(proc);
}
if (proc) {
+ int dec_refc = 0;
+ ErtsMessage *mp = erts_alloc_message(0, NULL);
+ mp->data.heap_frag = tmr->btm.bp;
+ tmr->btm.bp = NULL;
+ erts_queue_message(proc, 0, mp, tmr->btm.message,
+ am_clock_service);
+ erts_proc_lock(proc, ERTS_PROC_LOCK_BTM);
+ /* If the process is exiting do not disturb the cleanup... */
if (!ERTS_PROC_IS_EXITING(proc)) {
- int dec_refc = 0;
- ErtsMessage *mp = erts_alloc_message(0, NULL);
- mp->data.heap_frag = tmr->btm.bp;
- tmr->btm.bp = NULL;
- erts_queue_message(proc, 0, mp, tmr->btm.message,
- am_clock_service);
- erts_proc_lock(proc, ERTS_PROC_LOCK_BTM);
#ifdef ERTS_MAGIC_REF_BIF_TIMERS
if (tmr->btm.proc_list.next) {
proc_btm_list_delete(&proc->bif_timers, tmr);
@@ -1276,10 +1277,10 @@ bif_timer_timeout(ErtsHLTimerService *srv,
dec_refc = 1;
}
#endif
- erts_proc_unlock(proc, ERTS_PROC_LOCK_BTM);
- if (dec_refc)
- timer_pre_dec_refc((ErtsTimer *) tmr);
}
+ erts_proc_unlock(proc, ERTS_PROC_LOCK_BTM);
+ if (dec_refc)
+ timer_pre_dec_refc((ErtsTimer *) tmr);
}
if (tmr->btm.bp)
free_message_buffer(tmr->btm.bp);