summaryrefslogtreecommitdiff
path: root/lib/net.js
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-01-21 14:54:01 +0100
committerAnna Henningsen <anna@addaleax.net>2019-01-23 16:32:20 +0100
commit2b65399694440d0bab1c4e394898a4555e58c324 (patch)
tree8843314b2b38788a36b60b48454cee370927a0a2 /lib/net.js
parentd3806f9f3cded6bce9831f5d8ff88372ba7e5861 (diff)
downloadandroid-node-v8-2b65399694440d0bab1c4e394898a4555e58c324.tar.gz
android-node-v8-2b65399694440d0bab1c4e394898a4555e58c324.tar.bz2
android-node-v8-2b65399694440d0bab1c4e394898a4555e58c324.zip
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 <vieuxtech@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'lib/net.js')
-rw-r--r--lib/net.js4
1 files changed, 3 insertions, 1 deletions
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'));
};