-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
node-red-gpio: Add patch to perform explicit node cleanup
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
- Loading branch information
1 parent
633a77e
commit 37ca6cf
Showing
2 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
recipes-app/node-red-gpio/files/0003-Clean-up-mraa-objects-on-node-closing.patch
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
From 110eec7a5a7452e8df14b67de4188dc8ea8eefd0 Mon Sep 17 00:00:00 2001 | ||
From: Jan Kiszka <jan.kiszka@siemens.com> | ||
Date: Fri, 27 Nov 2020 08:14:14 +0100 | ||
Subject: [PATCH 3/3] Clean up mraa objects on node closing | ||
|
||
Required as nodejs will only lazily delete the node objects, and we may | ||
race with the next user requesting the resources. | ||
|
||
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> | ||
--- | ||
hardware/intel/mraa-gpio-ain.js | 1 + | ||
hardware/intel/mraa-gpio-din.js | 1 + | ||
hardware/intel/mraa-gpio-dout.js | 1 + | ||
hardware/intel/mraa-gpio-led.js | 4 ++++ | ||
hardware/intel/mraa-gpio-pwm.js | 1 + | ||
5 files changed, 8 insertions(+) | ||
|
||
diff --git a/hardware/intel/mraa-gpio-ain.js b/hardware/intel/mraa-gpio-ain.js | ||
index 65df93b..91e2b0b 100644 | ||
--- a/hardware/intel/mraa-gpio-ain.js | ||
+++ b/hardware/intel/mraa-gpio-ain.js | ||
@@ -22,6 +22,7 @@ module.exports = function(RED) { | ||
|
||
this.on('close', function() { | ||
clearInterval(this.timer); | ||
+ node.x.close(); | ||
}); | ||
} | ||
RED.nodes.registerType("mraa-gpio-ain", gpioAin); | ||
diff --git a/hardware/intel/mraa-gpio-din.js b/hardware/intel/mraa-gpio-din.js | ||
index 4ac983f..7eca35a 100644 | ||
--- a/hardware/intel/mraa-gpio-din.js | ||
+++ b/hardware/intel/mraa-gpio-din.js | ||
@@ -51,6 +51,7 @@ module.exports = function(RED) { | ||
this.on('close', function() { | ||
node.x.isr(m.EDGE_BOTH, null); | ||
node.x.isrExit(); | ||
+ node.x.close(); | ||
}); | ||
} | ||
RED.nodes.registerType("mraa-gpio-din", gpioDin); | ||
diff --git a/hardware/intel/mraa-gpio-dout.js b/hardware/intel/mraa-gpio-dout.js | ||
index 37d1429..fb3dbd8 100644 | ||
--- a/hardware/intel/mraa-gpio-dout.js | ||
+++ b/hardware/intel/mraa-gpio-dout.js | ||
@@ -24,6 +24,7 @@ module.exports = function(RED) { | ||
}); | ||
|
||
this.on('close', function() { | ||
+ node.p.close(); | ||
}); | ||
} | ||
RED.nodes.registerType("mraa-gpio-dout", gpioDout); | ||
diff --git a/hardware/intel/mraa-gpio-led.js b/hardware/intel/mraa-gpio-led.js | ||
index aa613e9..5803296 100644 | ||
--- a/hardware/intel/mraa-gpio-led.js | ||
+++ b/hardware/intel/mraa-gpio-led.js | ||
@@ -64,6 +64,10 @@ module.exports = function(RED) { | ||
} | ||
}); | ||
this.on('close', function() { | ||
+ this.led0.close(); | ||
+ this.led1.close(); | ||
+ this.led2.close(); | ||
+ this.led3.close(); | ||
}); | ||
} | ||
RED.nodes.registerType("mraa-gpio-led", LEDNode); | ||
diff --git a/hardware/intel/mraa-gpio-pwm.js b/hardware/intel/mraa-gpio-pwm.js | ||
index 22b02cb..6a2469f 100644 | ||
--- a/hardware/intel/mraa-gpio-pwm.js | ||
+++ b/hardware/intel/mraa-gpio-pwm.js | ||
@@ -21,6 +21,7 @@ module.exports = function(RED) { | ||
|
||
this.on('close', function() { | ||
node.p.enable(false); | ||
+ node.p.close(); | ||
}); | ||
} | ||
RED.nodes.registerType("mraa-gpio-pwm", gpioPWM); | ||
-- | ||
2.26.2 | ||
|
This file contains 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