tls: fix premature connection termination
authorBen Noordhuis <info@bnoordhuis.nl>
Wed, 9 Oct 2013 15:46:17 +0000 (17:46 +0200)
committerBen Noordhuis <info@bnoordhuis.nl>
Wed, 9 Oct 2013 17:25:47 +0000 (19:25 +0200)
Destroying the TLS session implies destroying the underlying socket but
before this commit, that was done with net.Socket#destroy() rather than
net.Socket#destroySoon().  The former closes the connection right away,
even when there is still data to write.  In other words, sometimes the
final TLS record got truncated.

Fixes #6107.

lib/tls.js

index fe94a51..dcdd99a 100644 (file)
@@ -1400,7 +1400,7 @@ function pipe(pair, socket) {
       // Encrypted should be unpiped from socket to prevent possible
       // write after destroy.
       pair.encrypted.unpipe(socket);
-      socket.destroy();
+      socket.destroySoon();
     });
   });