From b1b94678d8e81caa9f0e123d5e85828acd03a961 Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Tue, 6 Sep 2016 11:49:19 -0400 Subject: [PATCH] timers: do not expose .unref()._handle._list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The list is defunct at this point. I believe this to be in effect a minor defect from 3eecdf9f1422640c7439507cb39ffb3dff57b3e4 PR-URL: https://github.com/nodejs/node/pull/8422 Reviewed-By: Michaƫl Zasso Reviewed-By: Colin Ihrig Reviewed-By: Julien Gilli Reviewed-By: Ruben Bridgewater Reviewed-By: Matteo Collina Reviewed-By: James M Snell --- lib/timers.js | 3 +++ .../test-timers-unref-reuse-no-exposed-list.js | 14 ++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 test/parallel/test-timers-unref-reuse-no-exposed-list.js diff --git a/lib/timers.js b/lib/timers.js index 6651e24a4e..7bfed79d15 100644 --- a/lib/timers.js +++ b/lib/timers.js @@ -598,6 +598,9 @@ Timeout.prototype.unref = function() { } var handle = reuse(this); + if (handle) { + handle._list = undefined; + } this._handle = handle || new TimerWrap(); this._handle.owner = this; diff --git a/test/parallel/test-timers-unref-reuse-no-exposed-list.js b/test/parallel/test-timers-unref-reuse-no-exposed-list.js new file mode 100644 index 0000000000..33b2da2f9e --- /dev/null +++ b/test/parallel/test-timers-unref-reuse-no-exposed-list.js @@ -0,0 +1,14 @@ +'use strict'; + +require('../common'); +const assert = require('assert'); + +const timer1 = setTimeout(() => {}, 1).unref(); +assert.strictEqual(timer1._handle._list, undefined, + 'timer1._handle._list should be undefined'); + +// Check that everything works even if the handle was not re-used. +setTimeout(() => {}, 1); +const timer2 = setTimeout(() => {}, 1).unref(); +assert.strictEqual(timer2._handle._list, undefined, + 'timer2._handle._list should be undefined');