Fix mtx_do_lock on exit or reload context#170
Merged
ianhattendorf merged 2 commits intoAxosoft:masterfrom Dec 2, 2022
Merged
Conversation
a19a408 to
881138f
Compare
881138f to
0f12e72
Compare
Contributor
Author
|
To use cleanuphooks again we need this PR merged. |
ianhattendorf
approved these changes
Dec 2, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We made an effort to try using AddCleanupHook to stop the watcher on all NSFW instances when exiting from a worker or electron context, but in the end we couldn’t make it work correctly, so we had to stop using them.
The reason is that using CleanupHooks introduces a problem: if you create and free a NSFW object when you close o reload a context or worker the CleanupHook will be triggered on an already freed object, so you will get a crash. We have tried to remove the CleanupHook before that, but you will get a crash if you try to remove it in the destructor. You cannot create or remove a CleanupHook anywhere you want, you can only do it when you have access to Napi::env directly in the call, and you cannot store it to use it later in the destructor.