Skip to content

Commit

Permalink
http: cleanup cork logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed May 12, 2024
1 parent ca2f874 commit 19bddc6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ ObjectDefineProperty(OutgoingMessage.prototype, 'writableHighWaterMark', {
ObjectDefineProperty(OutgoingMessage.prototype, 'writableCorked', {
__proto__: null,
get() {
return this[kCorked];
return this[kSocket] ? this[kSocket].writableCorked : this[kCorked];
},
});

Expand Down Expand Up @@ -1000,9 +1000,9 @@ function write_(msg, chunk, encoding, callback, fromEnd) {
}
}

if (!fromEnd && msg.socket && !msg.socket.writableCorked) {
msg.socket.cork();
process.nextTick(connectionCorkNT, msg.socket);
if (!fromEnd && !msg.writableCorked) {
msg.cork();
process.nextTick(connectionUncorkNT, msg);
}

let ret;
Expand All @@ -1027,8 +1027,8 @@ function write_(msg, chunk, encoding, callback, fromEnd) {
}


function connectionCorkNT(conn) {
conn.uncork();
function connectionUncorkNT(msg) {
msg.uncork();
}

OutgoingMessage.prototype.addTrailers = function addTrailers(headers) {
Expand Down Expand Up @@ -1143,9 +1143,9 @@ OutgoingMessage.prototype.end = function end(chunk, encoding, callback) {
// Fully uncork connection on end().
this[kSocket]._writableState.corked = 1;
this[kSocket].uncork();
} else {
this[kCorked] = 0;
}
this[kCorked] = 1;
this.uncork();

this.finished = true;

Expand Down

0 comments on commit 19bddc6

Please sign in to comment.