Skip to content

Commit 6a27774

Browse files
sam-githubMylesBorins
authored andcommitted
net: return this from getConnections()
PR-URL: #13553 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 063c4fa commit 6a27774

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

doc/api/net.md

+2
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ connections use asynchronous `server.getConnections` instead.
121121
added: v0.9.7
122122
-->
123123

124+
* Returns {net.Server}
125+
124126
Asynchronously get the number of concurrent connections on the server. Works
125127
when sockets were sent to forks.
126128

lib/net.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,8 @@ Server.prototype.getConnections = function(cb) {
14871487
}
14881488

14891489
if (!this._usingSlaves) {
1490-
return end(null, this._connections);
1490+
end(null, this._connections);
1491+
return this;
14911492
}
14921493

14931494
// Poll slaves
@@ -1507,6 +1508,8 @@ Server.prototype.getConnections = function(cb) {
15071508
this._slaves.forEach(function(slave) {
15081509
slave.getConnections(oncount);
15091510
});
1511+
1512+
return this;
15101513
};
15111514

15121515

test/parallel/test-net-pingpong.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ function pingPongTest(port, host) {
1616

1717
function onSocket(socket) {
1818
assert.strictEqual(socket.server, server);
19-
server.getConnections(common.mustCall(function(err, connections) {
20-
assert.ifError(err);
21-
assert.strictEqual(connections, 1);
22-
}));
19+
assert.strictEqual(
20+
server,
21+
server.getConnections(common.mustCall(function(err, connections) {
22+
assert.ifError(err);
23+
assert.strictEqual(connections, 1);
24+
}))
25+
);
2326

2427
socket.setNoDelay();
2528
socket.timeout = 0;

0 commit comments

Comments
 (0)