Browse Source

TCP timeout opt-in instead of opt-out

For speed, idle connections are super cheap.
v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
3adf7a3dcf
  1. 22
      lib/net.js

22
lib/net.js

@ -145,15 +145,17 @@ var timeout = new (function () {
var unenroll = this.unenroll = function (socket) {
socket._idleNext._idlePrev = socket._idlePrev;
socket._idlePrev._idleNext = socket._idleNext;
var list = lists[socket._idleTimeout];
// if empty then stop the watcher
//sys.puts('unenroll');
if (list && list._idlePrev == list) {
//sys.puts('unenroll: list empty');
list.stop();
if (socket._idleNext) {
socket._idleNext._idlePrev = socket._idlePrev;
socket._idlePrev._idleNext = socket._idleNext;
var list = lists[socket._idleTimeout];
// if empty then stop the watcher
//sys.puts('unenroll');
if (list && list._idlePrev == list) {
//sys.puts('unenroll: list empty');
list.stop();
}
}
};
@ -256,8 +258,6 @@ function _doFlush () {
}
function initSocket (self) {
timeout.enroll(self, 60*1000); // default timeout, 60 seconds
self._readWatcher = ioWatchers.alloc();
self._readWatcher.callback = function () {
// If this is the first recv (recvBuffer doesn't exist) or we've used up

Loading…
Cancel
Save