From d64e070e26cc3545367ef38098a0fe963be0ea8d Mon Sep 17 00:00:00 2001 From: Henry Rawas Date: Tue, 28 Jun 2011 14:32:01 -0700 Subject: [PATCH] net_uv: Delay listen emit --- lib/net_uv.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/net_uv.js b/lib/net_uv.js index 4ea91221d0..9b3750a517 100644 --- a/lib/net_uv.js +++ b/lib/net_uv.js @@ -404,7 +404,9 @@ function listenip(self, ip, port) { self.emit('error', errnoException(errno, 'listen')); } else { self._handle.listen(self._backlog || 128); - self.emit('listening'); + process.nextTick(function() { + self.emit('listening'); + }); } } @@ -422,7 +424,9 @@ Server.prototype.listen = function() { // Don't bind(). OS will assign a port with INADDR_ANY. // The port can be found with server.address() this._handle.listen(self._backlog || 128); - this.emit('listening'); + process.nextTick(function() { + self.emit('listening'); + }); } else if (typeof arguments[1] == 'undefined') { // The first argument is the port, no IP given.