Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

tls: Destroy socket when encrypted side closes

The v0.8 Stream.pipe() method automatically destroyed the destination
stream whenever the src stream closed.  However, this caused a lot of
problems, and was removed by popular demand.  (Many userland modules
still have a no-op destroy() method just because of this.) It was also
very hazardous because this would be done even if { end: false } was
passed in the pipe options.

In v0.10, we decided that the 'close' event and destroy() method are
application-specific, and pipe() doesn't automatically call destroy().
However, TLS actually depended (silently) on this behavior.  So, in this
case, we should just go ahead and destroy the thing when close happens.

Closes #5145
  • Loading branch information...
commit 426de209dfc9200ed43b51c77414960b75264ecd 1 parent 7af075e
Isaac Z. Schlueter authored

Showing 1 changed file with 6 additions and 0 deletions. Show diff stats Hide diff stats

  1. +6 0 lib/tls.js
6 lib/tls.js
@@ -1322,6 +1322,12 @@ function pipe(pair, socket) {
1322 1322 pair.encrypted.pipe(socket);
1323 1323 socket.pipe(pair.encrypted);
1324 1324
  1325 + pair.encrypted.on('close', function() {
  1326 + process.nextTick(function() {
  1327 + socket.destroy();
  1328 + });
  1329 + });
  1330 +
1325 1331 pair.fd = socket.fd;
1326 1332 var cleartext = pair.cleartext;
1327 1333 cleartext.socket = socket;

0 comments on commit 426de20

Please sign in to comment.
Something went wrong with that request. Please try again.