Skip to content

Commit

Permalink
lock for the duration of drop
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny committed May 22, 2021
1 parent 2974364 commit 48f4491
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/neon-runtime/src/napi/tsfn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,11 @@ impl<T: Send + 'static> ThreadsafeFunction<T> {

impl<T> Drop for ThreadsafeFunction<T> {
fn drop(&mut self) {
let is_finalized = self.is_finalized.lock().unwrap();

// tsfn was already finalized by `Environment::CleanupHandles()` in
// Node.js
if *self.is_finalized.lock().unwrap() {
if *is_finalized {
return;
}

Expand Down

0 comments on commit 48f4491

Please sign in to comment.