Fix of pool leaking by TCP-keepalive (#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
This commit is contained in:
Konstantin Petryaev 2016-06-22 02:49:41 +07:00 committed by Brian C
parent e809055174
commit ad65c7b1bc
3 changed files with 15 additions and 0 deletions

View File

@ -48,6 +48,7 @@ Connection.prototype.connect = function(port, host) {
this.stream.on('connect', function() {
self.emit('connect');
self.stream.setKeepAlive(true);
});
this.stream.on('error', function(error) {

View File

@ -43,6 +43,18 @@ test('using closed stream', function() {
assert.ok(hit);
});
test('after stream emits connected event init TCP-keepalive', function() {
var res = false;
stream.setKeepAlive = function(bit) {
res = bit;
};
assert.ok(stream.emit('connect'));
assert.equal(res, true);
});
});
test('using opened stream', function() {

View File

@ -15,6 +15,8 @@ p.write = function(packet) {
this.packets.push(packet);
};
p.setKeepAlive = function(){};
p.writable = true;
createClient = function() {