diff --git a/lib/net.js b/lib/net.js index 0f9d728a1099c1..4c84c49430e6cd 100644 --- a/lib/net.js +++ b/lib/net.js @@ -499,18 +499,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; };