GeezerVison is showing github.com — net: refactor onSlaveClose in Server.close · nodejs/node@1bd07ac
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/net.js +6-8Lines changed: 6 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1495,13 +1495,6 @@ Server.prototype.getConnections = function(cb) { |
1495 | 1495 |
|
1496 | 1496 |
|
1497 | 1497 | Server.prototype.close = function(cb) { |
1498 | | - function onSlaveClose() { |
1499 | | - if (--left !== 0) return; |
1500 | | - |
1501 | | - self._connections = 0; |
1502 | | - self._emitCloseIfDrained(); |
1503 | | - } |
1504 | | - |
1505 | 1498 | if (typeof cb === 'function') { |
1506 | 1499 | if (!this._handle) { |
1507 | 1500 | this.once('close', function() { |
@@ -1518,8 +1511,13 @@ Server.prototype.close = function(cb) { |
1518 | 1511 | } |
1519 | 1512 |
|
1520 | 1513 | if (this._usingSlaves) { |
1521 | | - var self = this; |
1522 | 1514 | var left = this._slaves.length; |
| 1515 | + const onSlaveClose = () => { |
| 1516 | + if (--left !== 0) return; |
| 1517 | + |
| 1518 | + this._connections = 0; |
| 1519 | + this._emitCloseIfDrained(); |
| 1520 | + }; |
1523 | 1521 |
|
1524 | 1522 | // Increment connections to be sure that, even if all sockets will be closed |
1525 | 1523 | // during polling of slaves, `close` event will be emitted only once. |
|