From ef096f8d8fb42b5ce030d3bef34bf363b401cbcb Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Tue, 25 Feb 2014 20:38:33 +0400 Subject: [PATCH] tls: force readable/writable to `true` These are an old and deprecated properties that was used by previous stream implementation, and are still in use in some user-land modules. Prior to this commit, they were read from the underlying socket, which may be non-readable/non-writable while connecting or while staying uninitialized. Force set them to `true`, just to make sure that there will be no inconsistency. fix #7152 --- lib/_tls_wrap.js | 10 +++++----- test/simple/test-tls-connect-given-socket.js | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index f3061c4..92a649b 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -171,11 +171,11 @@ function TLSSocket(socket, options) { // Disallow wrapping TLSSocket in TLSSocket assert(!(socket instanceof TLSSocket)); - net.Socket.call(this, socket && { - handle: socket._handle, - allowHalfOpen: socket.allowHalfOpen, - readable: socket.readable, - writable: socket.writable + net.Socket.call(this, { + handle: socket && socket._handle, + allowHalfOpen: socket && socket.allowHalfOpen, + readable: true, + writable: true }); // To prevent assertion in afterConnect() diff --git a/test/simple/test-tls-connect-given-socket.js b/test/simple/test-tls-connect-given-socket.js index 649ef82..ab571c7 100644 --- a/test/simple/test-tls-connect-given-socket.js +++ b/test/simple/test-tls-connect-given-socket.js @@ -55,6 +55,8 @@ var server = tls.createServer(options, function(socket) { server.close(); }); }); + assert(client.readable); + assert(client.writable); } // Already connected socket -- 2.7.4