diff options
author | Fedor Indutny <fedor@indutny.com> | 2014-04-14 14:12:35 +0400 |
---|---|---|
committer | Fedor Indutny <fedor@indutny.com> | 2014-04-14 14:12:35 +0400 |
commit | 16a083919bbf9cb29ea194a9a488af178b963443 (patch) | |
tree | 26b97f1832ee68d289f98fb9de611cc301a84800 | |
parent | c61b0e9cbc748c5e90fc5e25e4fb490b4104cae3 (diff) | |
download | node-16a083919bbf9cb29ea194a9a488af178b963443.tar.gz |
tls: set _connecting before starting the flowfix/orangemocha-readable-stuff
When creating a TLSSocket instance based on the existing connecting
socket, `_connecting` property is copied after the initialization of
`net.Socket`. However, since `net.Socket` constructor will call
`.read(0)` if the `readable` is true - error may happen at this code
chunk in net.js:
Socket.prototype._read = function(n) {
debug('_read');
if (this._connecting || !this._handle) {
debug('_read wait for connection');
this.once('connect', this._read.bind(this, n));
...
Leading to a test failures on windows:
- test/simple/test-tls-connect-given-socket.js
-rw-r--r-- | lib/_tls_wrap.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index fc515bbc3..3f017e1e1 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -177,8 +177,8 @@ function TLSSocket(socket, options) { net.Socket.call(this, { handle: socket && socket._handle, allowHalfOpen: socket && socket.allowHalfOpen, - readable: true, - writable: true + readable: false, + writable: false }); // To prevent assertion in afterConnect() @@ -210,6 +210,13 @@ function TLSSocket(socket, options) { } else { this._init(socket); } + + // Make sure to setup all required properties like: `_connecting` before + // starting the flow of the data + this.readable = true; + this.writable = true; + if (this.readable) + this.read(0); } util.inherits(TLSSocket, net.Socket); exports.TLSSocket = TLSSocket; |