diff --git a/lib/dns.js b/lib/dns.js index f0f25b4c53..40b7c65fde 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -14,9 +14,8 @@ timer.callback = function () { for (var i = 0, l = sockets.length; i < l; i++) { var socket = sockets[i]; var s = parseInt(socket, 10); - channel.processFD( watchers[socket].read ? s : dns.SOCKET_BAD - , watchers[socket].write ? s : dns.SOCKET_BAD - ); + channel.processFD(watchers[socket].read ? s : dns.SOCKET_BAD, + watchers[socket].write ? s : dns.SOCKET_BAD); } updateTimer(); }; @@ -46,20 +45,19 @@ var channel = new dns.Channel({SOCK_STATE_CB: function (socket, read, write) { }; watcher.callback = function(read, write) { - channel.processFD( read ? socket : dns.SOCKET_BAD - , write ? socket : dns.SOCKET_BAD - ); + channel.processFD(read ? socket : dns.SOCKET_BAD, + write ? socket : dns.SOCKET_BAD); updateTimer(); }; }; - watcher.set(socket, read == 1, write == 1); + watcher.stop(); if (!(read || write)) { - watcher.stop(); delete activeWatchers[socket]; return; } else { + watcher.set(socket, read == 1, write == 1); watcher.start(); activeWatchers[socket] = watcher; } diff --git a/src/node_io_watcher.cc b/src/node_io_watcher.cc index d0d83a0b16..d007633106 100644 --- a/src/node_io_watcher.cc +++ b/src/node_io_watcher.cc @@ -139,6 +139,7 @@ Handle IOWatcher::Set(const Arguments& args) { if (args[2]->IsTrue()) events |= EV_WRITE; + assert(!io->watcher_.active); ev_io_set(&io->watcher_, fd, events); return Undefined();