★ wanayoo — archive 1999 https://github.com/nodejs/node/commit/655c90b287Nouvelle recherche | Portail wanayoo
Skip to content
Permalink
Browse files
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 <ruben@bridgewater.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
lpinca committed Apr 11, 2019
1 parent 29d0b43 commit 655c90b287375d7920f509136d7a75492739dd2a
Showing with 2 additions and 12 deletions.
  1. +2 −12 lib/net.js
@@ -541,19 +541,9 @@ function onReadableStreamEnd() {
if (this.writable)
this.end();
}
maybeDestroy(this);
}


// Call whenever we set writable=false or readable=false
function maybeDestroy(socket) {
if (!socket.readable &&
!socket.writable &&
!socket.destroyed &&
!socket.connecting &&
!socket.writableLength) {
socket.destroy();
}
if (!this.destroyed && !this.writable && !this.writableLength)
this.destroy();
}


0 comments on commit 655c90b

Please sign in to comment.