Skip to content

Commit

Permalink
fixup: ref/unref should still work when destroyed
Browse files Browse the repository at this point in the history
  • Loading branch information
apapirovski committed Dec 13, 2019
1 parent 33b3eb4 commit d249fc2
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/internal/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,23 +207,25 @@ Timeout.prototype.refresh = function() {
};

Timeout.prototype.unref = function() {
if (this[kRefed] && !this._destroyed) {
if (this[kRefed]) {
this[kRefed] = false;
decRefCount();
if (!this._destroyed)
decRefCount();
}
return this;
};

Timeout.prototype.ref = function() {
if (!this[kRefed] && !this._destroyed) {
if (!this[kRefed]) {
this[kRefed] = true;
incRefCount();
if (!this._destroyed)
incRefCount();
}
return this;
};

Timeout.prototype.hasRef = function() {
return !!(this[kRefed] && !this._destroyed);
return this[kRefed];
};

function TimersList(expiry, msecs) {
Expand Down

0 comments on commit d249fc2

Please sign in to comment.