From b3dad2be69c8d01b9ff0be5c4c91caf207138368 Mon Sep 17 00:00:00 2001 From: Julian Mesa Date: Fri, 17 Dec 2021 09:11:16 +0100 Subject: [PATCH 1/2] Stop the service on error. This way the watcher will release all RAM used for watching the inodes on linux. --- js/spec/index-spec.js | 1 - src/NSFW.cpp | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/js/spec/index-spec.js b/js/spec/index-spec.js index 085719a..b84b8ed 100644 --- a/js/spec/index-spec.js +++ b/js/spec/index-spec.js @@ -558,7 +558,6 @@ describe('Node Sentinel File Watcher', function() { assert.ok(erroredOut); } finally { - await watch.stop(); watch = null; } }); diff --git a/src/NSFW.cpp b/src/NSFW.cpp index 0a1807a..3f29657 100644 --- a/src/NSFW.cpp +++ b/src/NSFW.cpp @@ -293,6 +293,9 @@ void NSFW::pollForEvents() { std::lock_guard lock(mRunningLock); mRunning = false; } + mInterface.reset(nullptr); + mPollThread.detach(); + Unref(); break; } From 4c1f2801405c153da749c6820b7f2dce8a30b05e Mon Sep 17 00:00:00 2001 From: Julian Mesa Date: Wed, 16 Feb 2022 12:38:22 +0100 Subject: [PATCH 2/2] Document new behavior Now when the service receives an error, the watcher stops releasing all resources, so if you try to stop the service after an error, you will get an exception. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index ae38f5a..fa78ce6 100644 --- a/README.md +++ b/README.md @@ -118,3 +118,7 @@ nsfw.actions = { ## Installation NSFW is a native node module and requires Node-Gyp to be functional before you can install it. Make sure you have completed installing all of the dependencies listed for [Node-Gyp](https://github.com/nodejs/node-gyp) on your operating system. + +## Breaking changes +Prior to version 2.3.0 when the service receive an error, the service is shutdown but the watcher is not stopped. +Now when the service receives an error, the watcher stops releasing all resources, so if you try to stop the service after an error, you will get an exception. \ No newline at end of file