From 5eeabb0214f55b21f2385da8a063a2657e64fa66 Mon Sep 17 00:00:00 2001 From: Kevin Eady <8634912+KevinEady@users.noreply.github.com> Date: Mon, 16 Dec 2019 20:51:03 +0100 Subject: [PATCH] tsfn: Remove erroneous finalizer cleanup Removes leftover cleanup in finalizer that was part of the original TSFN implementation. Fixes: https://github.com/nodejs/node-addon-api/issues/632 PR-URL: https://github.com/nodejs/node-addon-api/pull/636 Reviewed-By: Gabriel Schulhof --- napi-inl.h | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/napi-inl.h b/napi-inl.h index bef889f9a..2250b6b1c 100644 --- a/napi-inl.h +++ b/napi-inl.h @@ -150,9 +150,6 @@ struct ThreadSafeFinalize { ThreadSafeFinalize* finalizeData = static_cast(rawFinalizeData); finalizeData->callback(Env(env)); - if (finalizeData->tsfn) { - *finalizeData->tsfn = nullptr; - } delete finalizeData; } @@ -166,9 +163,6 @@ struct ThreadSafeFinalize { ThreadSafeFinalize* finalizeData = static_cast(rawFinalizeData); finalizeData->callback(Env(env), finalizeData->data); - if (finalizeData->tsfn) { - *finalizeData->tsfn = nullptr; - } delete finalizeData; } @@ -182,9 +176,6 @@ struct ThreadSafeFinalize { ThreadSafeFinalize* finalizeData = static_cast(rawFinalizeData); finalizeData->callback(Env(env), static_cast(rawContext)); - if (finalizeData->tsfn) { - *finalizeData->tsfn = nullptr; - } delete finalizeData; } @@ -199,15 +190,11 @@ struct ThreadSafeFinalize { static_cast(rawFinalizeData); finalizeData->callback(Env(env), finalizeData->data, static_cast(rawContext)); - if (finalizeData->tsfn) { - *finalizeData->tsfn = nullptr; - } delete finalizeData; } FinalizerDataType* data; Finalizer callback; - napi_threadsafe_function* tsfn; }; #endif @@ -4528,7 +4515,7 @@ inline ThreadSafeFunction ThreadSafeFunction::New(napi_env env, ThreadSafeFunction tsfn; auto* finalizeData = new details::ThreadSafeFinalize({ data, finalizeCallback, &tsfn._tsfn }); + FinalizerDataType>({ data, finalizeCallback }); napi_status status = napi_create_threadsafe_function(env, callback, resource, Value::From(env, resourceName), maxQueueSize, initialThreadCount, finalizeData, wrapper, context, CallJS, &tsfn._tsfn);