Skip to content

Commit 708728d

Browse files
ronagjasnell
authored andcommitted
http: abortIncoming only on socket close
Don't call abortIncombin twice for same socket, i.e. both during 'end' and 'close'. PR-URL: #36821 Reviewed-By: James M Snell <[email protected]>
1 parent 7be7285 commit 708728d

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

lib/_http_server.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -581,11 +581,7 @@ function socketOnTimeout() {
581581

582582
function socketOnClose(socket, state) {
583583
debug('server socket close');
584-
// Mark this parser as reusable
585-
if (socket.parser) {
586-
freeParser(socket.parser, null, socket);
587-
}
588-
584+
freeParser(socket.parser, null, socket);
589585
abortIncoming(state.incoming);
590586
}
591587

@@ -602,18 +598,15 @@ function socketOnEnd(server, socket, parser, state) {
602598

603599
if (ret instanceof Error) {
604600
debug('parse error');
601+
// socketOnError has additional logic and will call socket.destroy(err).
605602
FunctionPrototypeCall(socketOnError, socket, ret);
606-
return;
607-
}
608-
609-
if (!server.httpAllowHalfOpen) {
610-
abortIncoming(state.incoming);
611-
if (socket.writable) socket.end();
603+
} else if (!server.httpAllowHalfOpen) {
604+
socket.end();
612605
} else if (state.outgoing.length) {
613606
state.outgoing[state.outgoing.length - 1]._last = true;
614607
} else if (socket._httpMessage) {
615608
socket._httpMessage._last = true;
616-
} else if (socket.writable) {
609+
} else {
617610
socket.end();
618611
}
619612
}
@@ -628,6 +621,7 @@ function socketOnData(server, socket, parser, state, d) {
628621

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

0 commit comments

Comments
 (0)