Skip to content

Commit ad65c7b

Browse files
NumminorihSFbrianc
authored andcommitted
Fix of pool leaking by TCP-keepalive (brianc#918)
* fix of bug with pool leaking by TCP keep-alives * add test for check setKeepAlive on connect * fix mistake with var * fix mistake with var
1 parent e809055 commit ad65c7b

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

lib/connection.js

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Connection.prototype.connect = function(port, host) {
4848

4949
this.stream.on('connect', function() {
5050
self.emit('connect');
51+
self.stream.setKeepAlive(true);
5152
});
5253

5354
this.stream.on('error', function(error) {

test/unit/connection/startup-tests.js

+12
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ test('using closed stream', function() {
4343
assert.ok(hit);
4444

4545
});
46+
47+
test('after stream emits connected event init TCP-keepalive', function() {
48+
49+
var res = false;
50+
51+
stream.setKeepAlive = function(bit) {
52+
res = bit;
53+
};
54+
55+
assert.ok(stream.emit('connect'));
56+
assert.equal(res, true);
57+
});
4658
});
4759

4860
test('using opened stream', function() {

test/unit/test-helper.js

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ p.write = function(packet) {
1515
this.packets.push(packet);
1616
};
1717

18+
p.setKeepAlive = function(){};
19+
1820
p.writable = true;
1921

2022
createClient = function() {

0 commit comments

Comments
 (0)