From 4bb7b4be859d2a01732f33aebdd0f29fd7fbcae3 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sun, 11 Feb 2018 03:08:21 +0100 Subject: [PATCH 1/2] 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. --- lib/net.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/lib/net.js b/lib/net.js index 48dd690e89dc7d..ddd681012683c2 100644 --- a/lib/net.js +++ b/lib/net.js @@ -524,16 +524,8 @@ Socket.prototype._read = function(n) { Socket.prototype.end = function(data, encoding) { stream.Duplex.prototype.end.call(this, data, encoding); - this.writable = false; 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; }; From 4ba6592cd61e25e5189e61e9224eec50a858a00a Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 13 Feb 2018 17:25:31 +0100 Subject: [PATCH 2/2] [squash] mcollina comment: add callback --- lib/net.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/net.js b/lib/net.js index ddd681012683c2..9c6c6bef07eb63 100644 --- a/lib/net.js +++ b/lib/net.js @@ -522,8 +522,8 @@ Socket.prototype._read = function(n) { }; -Socket.prototype.end = function(data, encoding) { - stream.Duplex.prototype.end.call(this, data, encoding); +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); return this;