Browse Source

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.
Peter Rust 12 years ago
committed by Timothy J Fontaine
parent
commit
82ff891e22
  1. 9
      lib/_http_outgoing.js

9
lib/_http_outgoing.js

@ -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…
Cancel
Save