Emit 'end' from crypto streams on close
authorRyan Dahl <ry@tinyclouds.org>
Fri, 21 Oct 2011 20:07:48 +0000 (13:07 -0700)
committerRyan Dahl <ry@tinyclouds.org>
Fri, 21 Oct 2011 20:16:41 +0000 (13:16 -0700)
Fixes test/simple/test-tls-peer-certificate.js on Windows

Patch from bnoordhuis.

See also 75a0cf970fb48440a93a62796ab1f128fcbe7d76

lib/tls.js

index 2dd8f16..e84d501 100644 (file)
@@ -679,6 +679,8 @@ SecurePair.prototype.destroy = function() {
     self.cleartext.writable = self.cleartext.readable = false;
 
     process.nextTick(function() {
+      self.encrypted.emit('end');
+      self.cleartext.emit('end');
       self.encrypted.emit('close');
       self.cleartext.emit('close');
     });
@@ -1025,7 +1027,7 @@ function pipe(pair, socket) {
 
   function onclose() {
     socket.removeListener('error', onerror);
-    socket.removeListener('close', onclose);
+    socket.removeListener('end', onclose);
     socket.removeListener('timeout', ontimeout);
   }