Skip to content

Commit b9ea4c4

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 810925b commit b9ea4c4

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
@@ -496,18 +496,10 @@ Socket.prototype._read = function(n) {
496496
};
497497

498498

499-
Socket.prototype.end = function(data, encoding) {
500-
stream.Duplex.prototype.end.call(this, data, encoding);
501-
this.writable = false;
499+
Socket.prototype.end = function(data, encoding, callback) {
500+
stream.Duplex.prototype.end.call(this, data, encoding, callback);
502501
DTRACE_NET_STREAM_END(this);
503502
LTTNG_NET_STREAM_END(this);
504-
505-
// just in case we're waiting for an EOF.
506-
if (this.readable && !this._readableState.endEmitted)
507-
this.read(0);
508-
else
509-
maybeDestroy(this);
510-
511503
return this;
512504
};
513505

0 commit comments

Comments
 (0)