mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
net: defer net.Server 'close' event to next tick
This commit is contained in:
10
lib/net.js
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');
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user