File tree Expand file tree Collapse file tree 2 files changed +4
-9
lines changed Expand file tree Collapse file tree 2 files changed +4
-9
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,6 @@ class NSFW : public Napi::ObjectWrap<NSFW> {
2626 std::string mPath ;
2727 std::thread mPollThread ;
2828 std::atomic<bool > mRunning ;
29- std::atomic<bool > mFinalizing ;
3029 std::condition_variable mWaitPoolEvents ;
3130 std::mutex mRunningLock ;
3231 std::vector<std::string> mExcludedPaths ;
Original file line number Diff line number Diff line change @@ -99,7 +99,6 @@ NSFW::NSFW(const Napi::CallbackInfo &info):
9999
100100NSFW::~NSFW () {
101101 if (mRunning ) {
102- mFinalizing = true ;
103102 {
104103 std::lock_guard<std::mutex> lock (mRunningLock );
105104 mRunning = false ;
@@ -213,6 +212,10 @@ void NSFW::StopWorker::Execute() {
213212 mNSFW ->mWaitPoolEvents .notify_one ();
214213 mNSFW ->mPollThread .join ();
215214
215+ // Release ThreadSafeFunction callbacks to prevent keeping event loop alive
216+ mNSFW ->mErrorCallback .Release ();
217+ mNSFW ->mEventCallback .Release ();
218+
216219 std::lock_guard<std::mutex> lock (mNSFW ->mInterfaceLock );
217220 mNSFW ->mInterface .reset (nullptr );
218221 mNSFW ->mQueue ->clear ();
@@ -443,13 +446,6 @@ void NSFW::pollForEvents() {
443446 }
444447 );
445448 }
446-
447- // If we are destroying NFSW object (destructor) we cannot release the thread safe functions at this point
448- // or we get a segfault
449- if (!mFinalizing ) {
450- mErrorCallback .Release ();
451- mEventCallback .Release ();
452- }
453449}
454450
455451Napi::Value NSFW::ExcludedPaths () {
You can’t perform that action at this time.
0 commit comments