mirror of https://github.com/nodejs/node.git
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 #5145pull/28770/head
parent
440dcae987
commit
164d5b3465
|
@ -1322,6 +1322,12 @@ function pipe(pair, socket) {
|
||||||
pair.encrypted.pipe(socket);
|
pair.encrypted.pipe(socket);
|
||||||
socket.pipe(pair.encrypted);
|
socket.pipe(pair.encrypted);
|
||||||
|
|
||||||
|
pair.encrypted.on('close', function() {
|
||||||
|
process.nextTick(function() {
|
||||||
|
socket.destroy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
pair.fd = socket.fd;
|
pair.fd = socket.fd;
|
||||||
var cleartext = pair.cleartext;
|
var cleartext = pair.cleartext;
|
||||||
cleartext.socket = socket;
|
cleartext.socket = socket;
|
||||||
|
|
Loading…
Reference in New Issue