tls: force readable/writable to `true`
authorFedor Indutny <fedor.indutny@gmail.com>
Tue, 25 Feb 2014 16:38:33 +0000 (20:38 +0400)
committerFedor Indutny <fedor.indutny@gmail.com>
Thu, 27 Mar 2014 19:25:30 +0000 (23:25 +0400)
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
test/simple/test-tls-connect-given-socket.js

index f3061c4..92a649b 100644 (file)
@@ -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()
index 649ef82..ab571c7 100644 (file)
@@ -55,6 +55,8 @@ var server = tls.createServer(options, function(socket) {
           server.close();
       });
     });
+    assert(client.readable);
+    assert(client.writable);
   }
 
   // Already connected socket