Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[tls] use chunk size larger than 1400 if we need to write buffer in m…

…ore than 64 1400b pieces
  • Loading branch information...
commit f087e02da305e8701c0402323598a356ab938c59 1 parent 311b60c
@indutny authored
Showing with 10 additions and 4 deletions.
  1. +10 −4 lib/tls.js
View
14 lib/tls.js
@@ -387,11 +387,17 @@ CleartextStream.prototype._pendingBytes = function() {
CleartextStream.prototype._puller = function(b) {
debug('clearIn ' + b.length + ' bytes');
- var result = 0;
+ var result = 0,
+ blen = b.length,
+ delta = Math.max(1400, Math.round(blen / 64));
- for (var offset = 0, len = b.length; offset < len; offset += 1400) {
- var chunk = b.slice(offset, Math.min(len, offset + 1400));
- result += this.pair._ssl.clearIn(chunk, 0, chunk.length);
+ for (var offset = 0; offset < blen; offset += delta) {
+ var chunk = b.slice(offset, Math.min(blen, offset + delta)),
+ local_result = this.pair._ssl.clearIn(chunk, 0, chunk.length);
+
+ if (local_result < 0) return local_result;
+
+ result += local_result;
}
return result;
Please sign in to comment.
Something went wrong with that request. Please try again.