Skip to content

Commit

Permalink
net: simplify net.Socket#end()
Browse files Browse the repository at this point in the history
`writable` is already set by the streams side, and
there is a handler waiting for the writable side to finish
which already takes care of the other cleanup code that
was previously there; both of these things can therefore be removed.

PR-URL: #18708
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
  • Loading branch information
addaleax authored and MylesBorins committed Aug 16, 2018
1 parent 2cbeea0 commit 4a267f0
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,18 +499,10 @@ Socket.prototype._read = function(n) {
};


Socket.prototype.end = function(data, encoding) {
stream.Duplex.prototype.end.call(this, data, encoding);
this.writable = false;
Socket.prototype.end = function(data, encoding, callback) {
stream.Duplex.prototype.end.call(this, data, encoding, callback);
DTRACE_NET_STREAM_END(this);
LTTNG_NET_STREAM_END(this);

// just in case we're waiting for an EOF.
if (this.readable && !this._readableState.endEmitted)
this.read(0);
else
maybeDestroy(this);

return this;
};

Expand Down

0 comments on commit 4a267f0

Please sign in to comment.