net: simplify net.Socket#end()

`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: https://github.com/nodejs/node/pull/18708
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
Anna Henningsen 2018-02-11 03:08:21 +01:00 committed by Ruben Bridgewater
parent 99d693da5c
commit 590eacecaa
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762

View File

@ -525,18 +525,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;
};