Skip to content

Commit 4a267f0

Browse files
addaleaxMylesBorins
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: #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 2cbeea0 commit 4a267f0

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

‎lib/net.js‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -499,18 +499,10 @@ Socket.prototype._read = function(n){
499499
};
500500

501501

502-
Socket.prototype.end=function(data,encoding){
503-
stream.Duplex.prototype.end.call(this,data,encoding);
504-
this.writable=false;
502+
Socket.prototype.end=function(data,encoding,callback){
503+
stream.Duplex.prototype.end.call(this,data,encoding,callback);
505504
DTRACE_NET_STREAM_END(this);
506505
LTTNG_NET_STREAM_END(this);
507-
508-
// just in case we're waiting for an EOF.
509-
if(this.readable&&!this._readableState.endEmitted)
510-
this.read(0);
511-
else
512-
maybeDestroy(this);
513-
514506
returnthis;
515507
};
516508

0 commit comments

Comments
(0)