Skip to content

Commit

Permalink
timers: do not expose .unref()._handle._list
Browse files Browse the repository at this point in the history
The list is defunct at this point.
I believe this to be in effect a minor defect from
3eecdf9

PR-URL: nodejs/node#8422
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Julien Gilli <jgilli@nodejs.org>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Fishrock123 authored and Stephen Belanger committed Sep 21, 2017
1 parent d1b5fd5 commit b1b9467
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions test/parallel/test-timers-unref-reuse-no-exposed-list.js
Original file line number Diff line number Diff line change
@@ -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');

0 comments on commit b1b9467

Please sign in to comment.