Skip to content

Commit

Permalink
tsfn: Remove erroneous finalizer cleanup
Browse files Browse the repository at this point in the history
Removes leftover cleanup in finalizer that was part of the original TSFN
implementation.

Fixes: nodejs/node-addon-api#632
PR-URL: nodejs/node-addon-api#636
Reviewed-By: Gabriel Schulhof <[email protected]>
  • Loading branch information
John French committed Dec 25, 2019
1 parent d305511 commit 09e4b09
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions napi-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,6 @@ struct ThreadSafeFinalize {
ThreadSafeFinalize* finalizeData =
static_cast<ThreadSafeFinalize*>(rawFinalizeData);
finalizeData->callback(Env(env));
if (finalizeData->tsfn) {
*finalizeData->tsfn = nullptr;
}
delete finalizeData;
}

Expand All @@ -166,9 +163,6 @@ struct ThreadSafeFinalize {
ThreadSafeFinalize* finalizeData =
static_cast<ThreadSafeFinalize*>(rawFinalizeData);
finalizeData->callback(Env(env), finalizeData->data);
if (finalizeData->tsfn) {
*finalizeData->tsfn = nullptr;
}
delete finalizeData;
}

Expand All @@ -182,9 +176,6 @@ struct ThreadSafeFinalize {
ThreadSafeFinalize* finalizeData =
static_cast<ThreadSafeFinalize*>(rawFinalizeData);
finalizeData->callback(Env(env), static_cast<ContextType*>(rawContext));
if (finalizeData->tsfn) {
*finalizeData->tsfn = nullptr;
}
delete finalizeData;
}

Expand All @@ -199,15 +190,11 @@ struct ThreadSafeFinalize {
static_cast<ThreadSafeFinalize*>(rawFinalizeData);
finalizeData->callback(Env(env), finalizeData->data,
static_cast<ContextType*>(rawContext));
if (finalizeData->tsfn) {
*finalizeData->tsfn = nullptr;
}
delete finalizeData;
}

FinalizerDataType* data;
Finalizer callback;
napi_threadsafe_function* tsfn;
};
#endif

Expand Down Expand Up @@ -4528,7 +4515,7 @@ inline ThreadSafeFunction ThreadSafeFunction::New(napi_env env,

ThreadSafeFunction tsfn;
auto* finalizeData = new details::ThreadSafeFinalize<ContextType, Finalizer,
FinalizerDataType>({ 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);
Expand Down

0 comments on commit 09e4b09

Please sign in to comment.