summaryrefslogtreecommitdiff
path: root/lib/tls.js
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2013-02-11 15:46:19 -0800
committerisaacs <i@izs.me>2013-02-11 16:43:10 -0800
commit02374d0c178b7c8cccab2d1daaa1bf601838bea5 (patch)
treea1283db976b2e6a3b4255d0344e1d66a4b5d5452 /lib/tls.js
parent1762dd7ed98417cc7cf124c099f66af11dcf702b (diff)
downloadnodejs-02374d0c178b7c8cccab2d1daaa1bf601838bea5.tar.gz
nodejs-02374d0c178b7c8cccab2d1daaa1bf601838bea5.tar.bz2
nodejs-02374d0c178b7c8cccab2d1daaa1bf601838bea5.zip
tls: Cycle data when underlying socket drains
Diffstat (limited to 'lib/tls.js')
-rw-r--r--lib/tls.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/tls.js b/lib/tls.js
index 97b7f7484..8b3654fa4 100644
--- a/lib/tls.js
+++ b/lib/tls.js
@@ -1298,6 +1298,18 @@ function pipe(pair, socket) {
cleartext.encrypted = pair.encrypted;
cleartext.authorized = false;
+ // cycle the data whenever the socket drains, so that
+ // we can pull some more into it. normally this would
+ // be handled by the fact that pipe() triggers read() calls
+ // on writable.drain, but CryptoStreams are a bit more
+ // complicated. Since the encrypted side actually gets
+ // its data from the cleartext side, we have to give it a
+ // light kick to get in motion again.
+ socket.on('drain', function() {
+ pair.encrypted.read(0);
+ pair.cleartext.read(0);
+ });
+
function onerror(e) {
if (cleartext._controlReleased) {
cleartext.emit('error', e);