Skip to content

Commit

Permalink
http: abortIncoming only on socket close
Browse files Browse the repository at this point in the history
Don't call abortIncombin twice for same socket, i.e. both during
'end' and 'close'.

PR-URL: #36821
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
ronag authored and ruyadorno committed Jan 21, 2021
1 parent d73d58d commit 82c05f5
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,11 +581,7 @@ function socketOnTimeout() {

function socketOnClose(socket, state) {
debug('server socket close');
// Mark this parser as reusable
if (socket.parser) {
freeParser(socket.parser, null, socket);
}

freeParser(socket.parser, null, socket);
abortIncoming(state.incoming);
}

Expand All @@ -609,18 +605,15 @@ function socketOnEnd(server, socket, parser, state) {

if (ret instanceof Error) {
debug('parse error');
// socketOnError has additional logic and will call socket.destroy(err).
FunctionPrototypeCall(socketOnError, socket, ret);
return;
}

if (!server.httpAllowHalfOpen) {
abortIncoming(state.incoming);
if (socket.writable) socket.end();
} else if (!server.httpAllowHalfOpen) {
socket.end();
} else if (state.outgoing.length) {
state.outgoing[state.outgoing.length - 1]._last = true;
} else if (socket._httpMessage) {
socket._httpMessage._last = true;
} else if (socket.writable) {
} else {
socket.end();
}
}
Expand All @@ -635,6 +628,7 @@ function socketOnData(server, socket, parser, state, d) {

function onRequestTimeout(socket) {
socket[kRequestTimeout] = undefined;
// socketOnError has additional logic and will call socket.destroy(err).
ReflectApply(socketOnError, socket, [new ERR_HTTP_REQUEST_TIMEOUT()]);
}

Expand Down

0 comments on commit 82c05f5

Please sign in to comment.