diff --git a/recipes-app/node-red-gpio/files/0003-Clean-up-mraa-objects-on-node-closing.patch b/recipes-app/node-red-gpio/files/0003-Clean-up-mraa-objects-on-node-closing.patch new file mode 100644 index 000000000..50ceb5a8c --- /dev/null +++ b/recipes-app/node-red-gpio/files/0003-Clean-up-mraa-objects-on-node-closing.patch @@ -0,0 +1,83 @@ +From 110eec7a5a7452e8df14b67de4188dc8ea8eefd0 Mon Sep 17 00:00:00 2001 +From: Jan Kiszka +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 +--- + 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 + diff --git a/recipes-app/node-red-gpio/node-red-gpio_0.0.6-IOT2050.bb b/recipes-app/node-red-gpio/node-red-gpio_0.0.6-IOT2050.bb index a0af0857d..c704c5895 100644 --- a/recipes-app/node-red-gpio/node-red-gpio_0.0.6-IOT2050.bb +++ b/recipes-app/node-red-gpio/node-red-gpio_0.0.6-IOT2050.bb @@ -17,7 +17,8 @@ MAINTAINER = "chao.zeng@siemens.com" SRC_URI = " \ git://github.com/node-red/node-red-nodes;protocol=https \ file://0001-add-the-board-info-add-the-led-control-node.patch \ - file://0002-extend-gpio-to-D19.patch" + file://0002-extend-gpio-to-D19.patch \ + file://0003-Clean-up-mraa-objects-on-node-closing.patch" SRCREV="3087e8e2a1ea189f394bca0a2af159ad859d7722" S = "${WORKDIR}/git"