Skip to content

Commit 82c05f5

Browse files
ronagruyadorno
authored andcommittedJan 21, 2021
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 <jasnell@gmail.com>
1 parent d73d58d commit 82c05f5

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed
 

‎lib/_http_server.js

+6-12
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

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

610606
if (ret instanceof Error) {
611607
debug('parse error');
608+
// socketOnError has additional logic and will call socket.destroy(err).
612609
FunctionPrototypeCall(socketOnError, socket, ret);
613-
return;
614-
}
615-
616-
if (!server.httpAllowHalfOpen) {
617-
abortIncoming(state.incoming);
618-
if (socket.writable) socket.end();
610+
} else if (!server.httpAllowHalfOpen) {
611+
socket.end();
619612
} else if (state.outgoing.length) {
620613
state.outgoing[state.outgoing.length - 1]._last = true;
621614
} else if (socket._httpMessage) {
622615
socket._httpMessage._last = true;
623-
} else if (socket.writable) {
616+
} else {
624617
socket.end();
625618
}
626619
}
@@ -635,6 +628,7 @@ function socketOnData(server, socket, parser, state, d) {
635628

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

0 commit comments

Comments
 (0)
Please sign in to comment.