1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-21 13:00:36 -05:00

fix(napi): don't hold on to borrow during iteration (#17461)

I mistakenly held on to a RefCell's borrow for the whole time of
iteration, but since these counters can be refed/unrefed from any 
thread that is a mistake.
This commit is contained in:
Bartek Iwańczuk 2023-01-18 02:14:53 +01:00 committed by GitHub
parent 69ec45eac7
commit f1b275ed6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -533,7 +533,8 @@ pub fn init<P: NapiPermissions + 'static>(unstable: bool) -> Extension {
maybe_scheduling = true;
}
for (_id, counter) in napi_state.tsfn_ref_counters.borrow().iter() {
let tsfn_ref_counters = napi_state.tsfn_ref_counters.borrow().clone();
for (_id, counter) in tsfn_ref_counters.iter() {
if counter.load(std::sync::atomic::Ordering::SeqCst) > 0 {
maybe_scheduling = true;
break;