Skip to content

Commit

Permalink
http: convert utcDate to use setTimeout
Browse files Browse the repository at this point in the history
A sort-of follow-up to #17704, this
removes the last internal use of enroll().

PR-URL: #17800
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Evan Lucas <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
  • Loading branch information
Fishrock123 authored and MylesBorins committed Jan 8, 2018
1 parent 134238c commit e5394e5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/internal/http.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
'use strict';

const timers = require('timers');
const { setUnrefTimeout } = require('internal/timers');

var dateCache;
function utcDate() {
if (!dateCache) {
const d = new Date();
dateCache = d.toUTCString();
timers.enroll(utcDate, 1000 - d.getMilliseconds());
timers._unrefActive(utcDate);

setUnrefTimeout(resetCache, 1000 - d.getMilliseconds());
}
return dateCache;
}
utcDate._onTimeout = function() {

function resetCache() {
dateCache = undefined;
};
}

function ondrain() {
if (this._httpMessage) this._httpMessage.emit('drain');
Expand Down

0 comments on commit e5394e5

Please sign in to comment.