Skip to content

Commit 655c90b

Browse files
committed
net: inline maybeDestroy()
`maybeDestroy()` is only called from the listener of the `'end'` event. That event is only emitted after the socket is connected (after `UV_EOF` is read) and after `socket.readable` is set to `false`. PR-URL: #27136 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 29d0b43 commit 655c90b

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

lib/net.js

+2-12
Original file line numberDiff line numberDiff line change
@@ -541,19 +541,9 @@ function onReadableStreamEnd() {
541541
if (this.writable)
542542
this.end();
543543
}
544-
maybeDestroy(this);
545-
}
546-
547544

548-
// Call whenever we set writable=false or readable=false
549-
function maybeDestroy(socket) {
550-
if (!socket.readable &&
551-
!socket.writable &&
552-
!socket.destroyed &&
553-
!socket.connecting &&
554-
!socket.writableLength) {
555-
socket.destroy();
556-
}
545+
if (!this.destroyed && !this.writable && !this.writableLength)
546+
this.destroy();
557547
}
558548

559549

0 commit comments

Comments
 (0)