Browse Source

Make sure watcher.set() isn't being called when active

v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
9c2969253b
  1. 14
      lib/dns.js
  2. 1
      src/node_io_watcher.cc

14
lib/dns.js

@ -14,9 +14,8 @@ timer.callback = function () {
for (var i = 0, l = sockets.length; i < l; i++) { for (var i = 0, l = sockets.length; i < l; i++) {
var socket = sockets[i]; var socket = sockets[i];
var s = parseInt(socket, 10); var s = parseInt(socket, 10);
channel.processFD( watchers[socket].read ? s : dns.SOCKET_BAD channel.processFD(watchers[socket].read ? s : dns.SOCKET_BAD,
, watchers[socket].write ? s : dns.SOCKET_BAD watchers[socket].write ? s : dns.SOCKET_BAD);
);
} }
updateTimer(); updateTimer();
}; };
@ -46,20 +45,19 @@ var channel = new dns.Channel({SOCK_STATE_CB: function (socket, read, write) {
}; };
watcher.callback = function(read, write) { watcher.callback = function(read, write) {
channel.processFD( read ? socket : dns.SOCKET_BAD channel.processFD(read ? socket : dns.SOCKET_BAD,
, write ? socket : dns.SOCKET_BAD write ? socket : dns.SOCKET_BAD);
);
updateTimer(); updateTimer();
}; };
}; };
watcher.set(socket, read == 1, write == 1); watcher.stop();
if (!(read || write)) { if (!(read || write)) {
watcher.stop();
delete activeWatchers[socket]; delete activeWatchers[socket];
return; return;
} else { } else {
watcher.set(socket, read == 1, write == 1);
watcher.start(); watcher.start();
activeWatchers[socket] = watcher; activeWatchers[socket] = watcher;
} }

1
src/node_io_watcher.cc

@ -139,6 +139,7 @@ Handle<Value> IOWatcher::Set(const Arguments& args) {
if (args[2]->IsTrue()) events |= EV_WRITE; if (args[2]->IsTrue()) events |= EV_WRITE;
assert(!io->watcher_.active);
ev_io_set(&io->watcher_, fd, events); ev_io_set(&io->watcher_, fd, events);
return Undefined(); return Undefined();

Loading…
Cancel
Save