From 5a84461e46cdf4c05d6beb418645989db59a546a Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Fri, 12 Nov 2010 09:54:48 -0800 Subject: [PATCH] Also do ondrain callback for socket (needed by http) --- lib/net.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/net.js b/lib/net.js index 59af9b9f32..998322678e 100644 --- a/lib/net.js +++ b/lib/net.js @@ -57,12 +57,16 @@ var ioWatchers = new FreeList("iowatcher", 100, function () { IOWatcher.prototype.ondrain = function () { assert(this.socket); - if (this.writable || this.readable) { - require('timers').active(this.socket); - this.socket.emit('drain'); + var socket = this.socket; + + if (socket.writable || socket.readable) { + require('timers').active(socket); } - if (this.socket._eof) this.socket._shutdown(); + socket.emit('drain'); + if (socket.ondrain) socket.ondrain(); + + if (socket._eof) socket._shutdown(); };