Browse Source

net: reset `endEmitted` on reconnect

fix #6908
v0.10.26-release
Fedor Indutny 11 years ago
committed by Timothy J Fontaine
parent
commit
00efcb4cd7
  1. 1
      lib/net.js
  2. 3
      test/simple/test-net-reconnect.js

1
lib/net.js

@ -781,6 +781,7 @@ Socket.prototype.connect = function(options, cb) {
if (this.destroyed) {
this._readableState.reading = false;
this._readableState.ended = false;
this._readableState.endEmitted = false;
this._writableState.ended = false;
this._writableState.ending = false;
this._writableState.finished = false;

3
test/simple/test-net-reconnect.js

@ -27,6 +27,7 @@ var net = require('net');
var N = 50;
var c = 0;
var client_recv_count = 0;
var client_end_count = 0;
var disconnect_count = 0;
var server = net.createServer(function(socket) {
@ -67,6 +68,7 @@ server.listen(common.PORT, function() {
client.on('end', function() {
console.error('CLIENT end');
client_end_count++;
});
client.on('close', function(had_error) {
@ -82,5 +84,6 @@ server.listen(common.PORT, function() {
process.on('exit', function() {
assert.equal(N + 1, disconnect_count);
assert.equal(N + 1, client_recv_count);
assert.equal(N + 1, client_end_count);
});

Loading…
Cancel
Save