diff options
author | Sverker Eriksson <[email protected]> | 2019-03-21 21:05:42 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2019-03-21 21:05:42 +0100 |
commit | bc3de715d1aaf6604cd8bde43900f22a631ce548 (patch) | |
tree | 4374576ce4d5b785fb03108b5aa3ba203f303332 /erts/emulator/beam/erl_process.c | |
parent | d015f4819d14694fe81b0ddb5935d14c80898ccc (diff) | |
parent | 9cce1357c3a0d3e13c57a0d9baaeccd249efe136 (diff) | |
download | otp-bc3de715d1aaf6604cd8bde43900f22a631ce548.tar.gz otp-bc3de715d1aaf6604cd8bde43900f22a631ce548.tar.bz2 otp-bc3de715d1aaf6604cd8bde43900f22a631ce548.zip |
Merge 'sverker/master/enif_whereis_pid-dirty-dtor/OTP-15694'
* sverker/master/enif_whereis_pid-dirty-dtor:
erts: Add test of enif_whereis* from resource destructor
erts: Simplify nif_SUITE:nif_whereis* tests
erts: Schedule resource destructors always
Diffstat (limited to 'erts/emulator/beam/erl_process.c')
-rw-r--r-- | erts/emulator/beam/erl_process.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/erts/emulator/beam/erl_process.c b/erts/emulator/beam/erl_process.c index 3fa06d1407..f34289339f 100644 --- a/erts/emulator/beam/erl_process.c +++ b/erts/emulator/beam/erl_process.c @@ -2375,9 +2375,12 @@ struct debug_lop { static void later_thr_debug_wait_completed(void *vlop) { struct debug_lop *lop = vlop; - erts_aint32_t count = (erts_aint32_t) erts_no_schedulers; - count += 1; /* aux thread */ - if (erts_atomic32_dec_read_mb(&debug_wait_completed_count) == count) { + + if (erts_atomic32_dec_read_mb(&debug_wait_completed_count) == 1) { + erts_aint32_t count = (erts_aint32_t) erts_no_schedulers; + count += 1; /* aux thread */ + erts_atomic32_set_nob(&debug_wait_completed_count, count); + /* scheduler threads */ erts_schedule_multi_misc_aux_work(0, erts_no_schedulers, @@ -2395,19 +2398,28 @@ static void later_thr_debug_wait_completed(void *vlop) static void init_thr_debug_wait_completed(void *vproc) { - struct debug_lop* lop = erts_alloc(ERTS_ALC_T_DEBUG, - sizeof(struct debug_lop)); - lop->proc = vproc; - erts_schedule_thr_prgr_later_op(later_thr_debug_wait_completed, lop, &lop->lop); + if (debug_wait_completed_flags == ERTS_DEBUG_WAIT_COMPLETED_AUX_WORK) { + if (erts_atomic32_dec_read_mb(&debug_wait_completed_count) == 1) { + erts_atomic32_set_nob(&debug_wait_completed_count, 0); + erts_resume((Process *) vproc, (ErtsProcLocks) 0); + erts_proc_dec_refc((Process *) vproc); + } + } + else { + struct debug_lop* lop = erts_alloc(ERTS_ALC_T_DEBUG, + sizeof(struct debug_lop)); + lop->proc = vproc; + erts_schedule_thr_prgr_later_op(later_thr_debug_wait_completed, lop, &lop->lop); + } } int erts_debug_wait_completed(Process *c_p, int flags) { - /* Only one process at a time can do this */ - erts_aint32_t count = (erts_aint32_t) (2*erts_no_schedulers); - count += 1; /* aux thread */ + /* Only one process at a time can do this, +1 to mark as busy */ + erts_aint32_t count = (erts_aint32_t) (erts_no_schedulers + 1); + if (0 == erts_atomic32_cmpxchg_mb(&debug_wait_completed_count, count, 0)) { |