diff --git a/lib/net.js b/lib/net.js index 48dd690e89dc7d..9c6c6bef07eb63 100644 --- a/lib/net.js +++ b/lib/net.js @@ -522,18 +522,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; };