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:
parent
99d693da5c
commit
590eacecaa
12
lib/net.js
12
lib/net.js
@ -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;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user