Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

net: defer net.Server 'close' event to next tick

  • Loading branch information...
commit c24276f0087a5f72f68be2384f32e20ba83dfa09 1 parent 0c3b357
@bnoordhuis bnoordhuis authored
View
10 lib/net.js
@@ -862,9 +862,13 @@ Server.prototype.close = function() {
};
Server.prototype._emitCloseIfDrained = function() {
- if (!this._handle && !this.connections) {
- this.emit('close');
- }
+ var self = this;
+
+ if (self._handle || self.connections) return;
+
+ process.nextTick(function() {
+ self.emit('close');
+ });
};
View
3  test/simple/test-net-server-listen-remove-callback.js
@@ -34,6 +34,9 @@ server.on('close', function() {
server.listen(common.PORT, function() {
server.close();
+});
+
+server.once('close', function() {
server.listen(common.PORT + 1, function() {
server.close();
});
Please sign in to comment.
Something went wrong with that request. Please try again.