Don't flush net writeQueue on end() if its still connecting
This commit is contained in:
parent
045bd4c7a4
commit
73b29d79b9
@ -1032,9 +1032,11 @@ Stream.prototype.end = function (data, encoding) {
|
|||||||
if (data) this.write(data, encoding);
|
if (data) this.write(data, encoding);
|
||||||
if (this._writeQueueLast() !== END_OF_FILE) {
|
if (this._writeQueueLast() !== END_OF_FILE) {
|
||||||
this._writeQueue.push(END_OF_FILE);
|
this._writeQueue.push(END_OF_FILE);
|
||||||
|
if (!this._connecting) {
|
||||||
this.flush();
|
this.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
47
test/simple/test-net-connect-buffer.js
Normal file
47
test/simple/test-net-connect-buffer.js
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
var common = require('../common');
|
||||||
|
var assert = require('assert');
|
||||||
|
var net = require('net');
|
||||||
|
|
||||||
|
var tcpPort = common.PORT;
|
||||||
|
|
||||||
|
var tcp = net.Server(function (s) {
|
||||||
|
tcp.close();
|
||||||
|
|
||||||
|
console.log("tcp server connection");
|
||||||
|
|
||||||
|
var buf = "";
|
||||||
|
s.on('data', function (d) {
|
||||||
|
buf += d;
|
||||||
|
});
|
||||||
|
|
||||||
|
s.on('end', function () {
|
||||||
|
assert.equal("foobar", buf);
|
||||||
|
console.log("tcp socket disconnect");
|
||||||
|
s.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
s.on('error', function (e) {
|
||||||
|
console.log("tcp server-side error: " + e.message);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
tcp.listen(tcpPort, startClient);
|
||||||
|
|
||||||
|
function startClient () {
|
||||||
|
var socket = net.Stream();
|
||||||
|
|
||||||
|
console.log("Connecting to socket");
|
||||||
|
|
||||||
|
socket.connect(tcpPort);
|
||||||
|
|
||||||
|
socket.on('connect', function () {
|
||||||
|
console.log('socket connected');
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.equal("opening", socket.readyState);
|
||||||
|
|
||||||
|
assert.equal(false, socket.write("foo"));
|
||||||
|
socket.end("bar");
|
||||||
|
|
||||||
|
assert.equal("opening", socket.readyState);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user