Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2013-03-30 05:23:39 +0400
committerisaacs <i@izs.me>2013-04-01 21:53:49 +0400
commit164d5b3465571a88da59cdddc03bb869126548eb (patch)
tree635162efbc4091335f317a1e7e746613573f282b /lib
parent440dcae98744954d1528506f2648aff71aadde25 (diff)
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
Diffstat (limited to 'lib')
-rw-r--r--lib/tls.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/tls.js b/lib/tls.js
index 53859121733..8650041c91f 100644
--- a/lib/tls.js
+++ b/lib/tls.js
@@ -1322,6 +1322,12 @@ function pipe(pair, socket) {
pair.encrypted.pipe(socket);
socket.pipe(pair.encrypted);
+ pair.encrypted.on('close', function() {
+ process.nextTick(function() {
+ socket.destroy();
+ });
+ });
+
pair.fd = socket.fd;
var cleartext = pair.cleartext;
cleartext.socket = socket;