Skip to content

Commit 590eace

Browse files
addaleaxBridgeAR
authored andcommitted
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: nodejs#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]>
1 parent 99d693d commit 590eace

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

lib/net.js

+2-10
Original file line numberDiff line numberDiff line change
@@ -525,18 +525,10 @@ Socket.prototype._read = function(n) {
525525
};
526526

527527

528-
Socket.prototype.end = function(data, encoding) {
529-
stream.Duplex.prototype.end.call(this, data, encoding);
530-
this.writable = false;
528+
Socket.prototype.end = function(data, encoding, callback) {
529+
stream.Duplex.prototype.end.call(this, data, encoding, callback);
531530
DTRACE_NET_STREAM_END(this);
532531
LTTNG_NET_STREAM_END(this);
533-
534-
// just in case we're waiting for an EOF.
535-
if (this.readable && !this._readableState.endEmitted)
536-
this.read(0);
537-
else
538-
maybeDestroy(this);
539-
540532
return this;
541533
};
542534

0 commit comments

Comments
 (0)