Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`.
  • Loading branch information
lpinca committed Apr 8, 2019
commit 767321c174e34f4d541d1c3d8dbf08c9e16403d7
14 changes: 2 additions & 12 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}


Expand Down