fixed timers, whoops.
Fixes issue https://github.com/ry/node/issues/issue/481
This commit is contained in:
parent
355936dcde
commit
5f3464cf4e
@ -43,7 +43,6 @@ function shift (list) {
|
||||
function remove (item) {
|
||||
item._idleNext._idlePrev = item._idlePrev;
|
||||
item._idlePrev._idleNext = item._idleNext;
|
||||
item._idleNext = null;
|
||||
}
|
||||
|
||||
|
||||
@ -209,7 +208,7 @@ exports.setTimeout = function (callback, after) {
|
||||
|
||||
|
||||
exports.clearTimeout = function (timer) {
|
||||
if (timer) {
|
||||
if (timer && (timer.callback || timer._onTimeout)) {
|
||||
timer.callback = timer._onTimeout = null;
|
||||
exports.unenroll(timer);
|
||||
if (timer instanceof Timer) timer.stop(); // for after === 0
|
||||
|
41
test/simple/test-net-can-reset-timeout.js
Normal file
41
test/simple/test-net-can-reset-timeout.js
Normal file
@ -0,0 +1,41 @@
|
||||
var net = require('net');
|
||||
var common = require('../common');
|
||||
var assert = require('assert');
|
||||
|
||||
var timeoutCount = 0;
|
||||
|
||||
var server = net.createServer(function(stream){
|
||||
stream.setTimeout(100);
|
||||
|
||||
stream.on('timeout', function () {
|
||||
console.log("timeout");
|
||||
// try to reset the timeout.
|
||||
stream.write("WHAT.");
|
||||
// don't worry, the socket didn't *really* time out, we're just thinking
|
||||
// it did.
|
||||
timeoutCount += 1;
|
||||
});
|
||||
|
||||
stream.on('end', function () {
|
||||
console.log("server side end");
|
||||
stream.end();
|
||||
});
|
||||
});
|
||||
|
||||
server.listen(common.PORT, function() {
|
||||
var c = net.createConnection(common.PORT);
|
||||
|
||||
c.on('data', function () {
|
||||
c.end();
|
||||
});
|
||||
|
||||
c.on('end', function () {
|
||||
console.log("client side end");
|
||||
server.close();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
process.on('exit', function () {
|
||||
assert.equal(1, timeoutCount);
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user