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: https://github.com/nodejs/node/pull/27136 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
29d0b43426
commit
655c90b287
14
lib/net.js
14
lib/net.js
@ -541,19 +541,9 @@ function onReadableStreamEnd() {
|
|||||||
if (this.writable)
|
if (this.writable)
|
||||||
this.end();
|
this.end();
|
||||||
}
|
}
|
||||||
maybeDestroy(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!this.destroyed && !this.writable && !this.writableLength)
|
||||||
// Call whenever we set writable=false or readable=false
|
this.destroy();
|
||||||
function maybeDestroy(socket) {
|
|
||||||
if (!socket.readable &&
|
|
||||||
!socket.writable &&
|
|
||||||
!socket.destroyed &&
|
|
||||||
!socket.connecting &&
|
|
||||||
!socket.writableLength) {
|
|
||||||
socket.destroy();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user