net: return this from getConnections()
PR-URL: https://github.com/nodejs/node/pull/13553 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
cf24177aba
commit
37fdfce93e
@ -162,6 +162,8 @@ connections use asynchronous `server.getConnections` instead.
|
||||
added: v0.9.7
|
||||
-->
|
||||
|
||||
* Returns {net.Server}
|
||||
|
||||
Asynchronously get the number of concurrent connections on the server. Works
|
||||
when sockets were sent to forks.
|
||||
|
||||
|
@ -1550,7 +1550,8 @@ Server.prototype.getConnections = function(cb) {
|
||||
}
|
||||
|
||||
if (!this._usingSlaves) {
|
||||
return end(null, this._connections);
|
||||
end(null, this._connections);
|
||||
return this;
|
||||
}
|
||||
|
||||
// Poll slaves
|
||||
@ -1570,6 +1571,8 @@ Server.prototype.getConnections = function(cb) {
|
||||
for (var n = 0; n < this._slaves.length; n++) {
|
||||
this._slaves[n].getConnections(oncount);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
|
@ -37,10 +37,13 @@ function pingPongTest(port, host) {
|
||||
|
||||
function onSocket(socket) {
|
||||
assert.strictEqual(socket.server, server);
|
||||
server.getConnections(common.mustCall(function(err, connections) {
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(connections, 1);
|
||||
}));
|
||||
assert.strictEqual(
|
||||
server,
|
||||
server.getConnections(common.mustCall(function(err, connections) {
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(connections, 1);
|
||||
}))
|
||||
);
|
||||
|
||||
socket.setNoDelay();
|
||||
socket.timeout = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user