From 2b65399694440d0bab1c4e394898a4555e58c324 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 21 Jan 2019 14:54:01 +0100 Subject: http2: allow fully synchronous `_final()` HTTP/2 streams do not use the fact that the native `StreamBase::Shutdown()` is asynchronous by default and always finish synchronously. Adding a status code for this scenario allows skipping an expensive `MakeCallback()` C++/JS boundary crossing. PR-URL: https://github.com/nodejs/node/pull/25609 Reviewed-By: Sam Roberts Reviewed-By: Matteo Collina --- lib/net.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/net.js') diff --git a/lib/net.js b/lib/net.js index 7680c8860e..9eb7448c59 100644 --- a/lib/net.js +++ b/lib/net.js @@ -362,7 +362,9 @@ Socket.prototype._final = function(cb) { req.callback = cb; var err = this._handle.shutdown(req); - if (err) + if (err === 1) // synchronous finish + return afterShutdown.call(req, 0); + else if (err !== 0) return this.destroy(errnoException(err, 'shutdown')); }; -- cgit v1.2.3