From c862c0348530824bfacef8eadfaf448120d91664 Mon Sep 17 00:00:00 2001 From: Alexis Campailla Date: Fri, 23 May 2014 14:55:34 -0400 Subject: [PATCH] tls: fix performance issue See https://github.com/orangemocha/node-connection-drop I have pinpointed the performance degradation to https://github.com/joyent/node/commit/ac2263b77f3f346458d06fc019de27e24c63cee0 This change brings performance back to the orginal levels. Signed-off-by: Fedor Indutny --- lib/tls.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/tls.js b/lib/tls.js index 5d04da59fe7..719a719bbf0 100644 --- a/lib/tls.js +++ b/lib/tls.js @@ -510,16 +510,11 @@ CryptoStream.prototype._read = function read(size) { if (this.ondata) { this.ondata(pool, start, start + bytesRead); - // Deceive streams2 - var self = this; + // Force state.reading to set to false + this.push(''); - setImmediate(function() { - // Force state.reading to set to false - self.push(''); - - // Try reading more, we most likely have some data - self.read(0); - }); + // Try reading more, we most likely have some data + this.read(0); } else { this.push(pool.slice(start, start + bytesRead)); }