http: use an unref'd timer to fix delay in exit
There was previously up to a second exit delay when exiting node right after an http request/response, due to the utcDate() function doing a setTimeout to update the cached date/time. Fixing this should increase the performance of our http tests.
This commit is contained in:
parent
fe176929c2
commit
82ff891e22
@ -21,6 +21,7 @@
|
||||
|
||||
var assert = require('assert').ok;
|
||||
var Stream = require('stream');
|
||||
var timers = require('timers');
|
||||
var util = require('util');
|
||||
|
||||
var common = require('_http_common');
|
||||
@ -44,12 +45,14 @@ function utcDate() {
|
||||
if (!dateCache) {
|
||||
var d = new Date();
|
||||
dateCache = d.toUTCString();
|
||||
setTimeout(function() {
|
||||
dateCache = undefined;
|
||||
}, 1000 - d.getMilliseconds());
|
||||
timers.enroll(utcDate, 1000 - d.getMilliseconds());
|
||||
timers._unrefActive(utcDate);
|
||||
}
|
||||
return dateCache;
|
||||
}
|
||||
utcDate._onTimeout = function() {
|
||||
dateCache = undefined;
|
||||
};
|
||||
|
||||
|
||||
function OutgoingMessage() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user