tls: fix performance issue

See https://github.com/orangemocha/node-connection-drop

I have pinpointed the performance degradation to
ac2263b77f

This change brings performance back to the orginal levels.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
This commit is contained in:
Alexis Campailla 2014-05-23 14:55:34 -04:00 committed by Fedor Indutny
parent e86c9421ef
commit c862c03485

View File

@ -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));
}