summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNathan Rajlich <nathan@tootallnate.net>2013-09-11 18:18:10 -0700
committerNathan Rajlich <nathan@tootallnate.net>2013-09-13 10:08:35 -0700
commit7196742852c9da5d29e2fb1e333bca9d21c8e205 (patch)
tree1d2422ba20a4fcd4f55d6fd0da6460b6a1b707f6 /lib
parent9fad8e5dc440b07507039d617bbaadc0be98edb5 (diff)
downloadandroid-node-v8-7196742852c9da5d29e2fb1e333bca9d21c8e205.tar.gz
android-node-v8-7196742852c9da5d29e2fb1e333bca9d21c8e205.tar.bz2
android-node-v8-7196742852c9da5d29e2fb1e333bca9d21c8e205.zip
tls: don't push() incoming data when ondata is set
Otherwise the data ends up "on the wire" twice, and switching between consuming the stream using `ondata` vs. `read()` would yield duplicate data, which was bad.
Diffstat (limited to 'lib')
-rw-r--r--lib/tls.js9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/tls.js b/lib/tls.js
index 976ff46352..a758c8e01c 100644
--- a/lib/tls.js
+++ b/lib/tls.js
@@ -505,16 +505,15 @@ CryptoStream.prototype._read = function read(size) {
} else {
// Give them requested data
if (this.ondata) {
- var self = this;
this.ondata(pool, start, start + bytesRead);
// Consume data automatically
// simple/test-https-drain fails without it
- process.nextTick(function() {
- self.read(bytesRead);
- });
+ this.push(pool.slice(start, start + bytesRead));
+ this.read(bytesRead);
+ } else {
+ this.push(pool.slice(start, start + bytesRead));
}
- this.push(pool.slice(start, start + bytesRead));
}
// Let users know that we've some internal data to read