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:
parent
e809055174
commit
ad65c7b1bc
@ -48,6 +48,7 @@ Connection.prototype.connect = function(port, host) {
|
|||||||
|
|
||||||
this.stream.on('connect', function() {
|
this.stream.on('connect', function() {
|
||||||
self.emit('connect');
|
self.emit('connect');
|
||||||
|
self.stream.setKeepAlive(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.stream.on('error', function(error) {
|
this.stream.on('error', function(error) {
|
||||||
|
@ -43,6 +43,18 @@ test('using closed stream', function() {
|
|||||||
assert.ok(hit);
|
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() {
|
test('using opened stream', function() {
|
||||||
|
@ -15,6 +15,8 @@ p.write = function(packet) {
|
|||||||
this.packets.push(packet);
|
this.packets.push(packet);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
p.setKeepAlive = function(){};
|
||||||
|
|
||||||
p.writable = true;
|
p.writable = true;
|
||||||
|
|
||||||
createClient = function() {
|
createClient = function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user