Skip to content

Commit

Permalink
http: cork/uncork before flushing pipelined res
Browse files Browse the repository at this point in the history
Make sure that the pipelined response data will be written as less TCP
packets as possible.

PR-URL: #3172
Reviewed-By: Brian White <[email protected]>
Reviewed-By: Trevor Norris <[email protected]>
  • Loading branch information
indutny authored and jasnell committed Oct 8, 2015
1 parent 660f759 commit 2ddbbfd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,12 @@ OutgoingMessage.prototype._writeRaw = function(data, encoding, callback) {
var output = this.output;
var outputEncodings = this.outputEncodings;
var outputCallbacks = this.outputCallbacks;
connection.cork();
for (var i = 0; i < outputLength; i++) {
connection.write(output[i], outputEncodings[i],
outputCallbacks[i]);
}
connection.uncork();

this.output = [];
this.outputEncodings = [];
Expand Down Expand Up @@ -637,10 +639,12 @@ OutgoingMessage.prototype._flush = function() {
var output = this.output;
var outputEncodings = this.outputEncodings;
var outputCallbacks = this.outputCallbacks;
socket.cork();
for (var i = 0; i < outputLength; i++) {
ret = socket.write(output[i], outputEncodings[i],
outputCallbacks[i]);
}
socket.uncork();

this.output = [];
this.outputEncodings = [];
Expand Down

0 comments on commit 2ddbbfd

Please sign in to comment.