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'.
  • Loading branch information
ronag committed Jan 6, 2021
1 parent db79783 commit 43fc062
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 @@ -602,18 +598,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 @@ -628,6 +621,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 43fc062

Please sign in to comment.