summaryrefslogtreecommitdiff
path: root/lib/_http_client.js
diff options
context:
space:
mode:
authorTrevor Norris <trev.norris@gmail.com>2017-03-10 06:17:42 -0700
committerAnna Henningsen <anna@addaleax.net>2017-05-10 22:22:29 +0200
commit4a7233c1788334c171d2280026333242df7d37af (patch)
tree649cf5aaa02e391dd90f460c0c4922ba631387dd /lib/_http_client.js
parent7e3a3c962f09233c53cee7ebe381341d7c8b7162 (diff)
downloadandroid-node-v8-4a7233c1788334c171d2280026333242df7d37af.tar.gz
android-node-v8-4a7233c1788334c171d2280026333242df7d37af.tar.bz2
android-node-v8-4a7233c1788334c171d2280026333242df7d37af.zip
lib: implement async_hooks API in core
Implement async_hooks support in the following: * fatalException handler * process.nextTick * Timers * net/dgram/http PR-URL: https://github.com/nodejs/node/pull/12892 Ref: https://github.com/nodejs/node/pull/11883 Ref: https://github.com/nodejs/node/pull/8531 Reviewed-By: Andreas Madsen <amwebdk@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'lib/_http_client.js')
-rw-r--r--lib/_http_client.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/_http_client.js b/lib/_http_client.js
index e1f064e832..a238a4f14c 100644
--- a/lib/_http_client.js
+++ b/lib/_http_client.js
@@ -36,6 +36,7 @@ const Agent = require('_http_agent');
const Buffer = require('buffer').Buffer;
const urlToOptions = require('internal/url').urlToOptions;
const outHeadersKey = require('internal/http').outHeadersKey;
+const nextTick = require('internal/process/next_tick').nextTick;
// The actual list of disallowed characters in regexp form is more like:
// /[^A-Za-z0-9\-._~!$&'()*+,;=/:@]/
@@ -587,9 +588,12 @@ function responseKeepAlive(res, req) {
socket.removeListener('close', socketCloseListener);
socket.removeListener('error', socketErrorListener);
socket.once('error', freeSocketErrorListener);
+ // There are cases where _handle === null. Avoid those. Passing null to
+ // nextTick() will call initTriggerId() to retrieve the id.
+ const asyncId = socket._handle ? socket._handle.getAsyncId() : null;
// Mark this socket as available, AFTER user-added end
// handlers have a chance to run.
- process.nextTick(emitFreeNT, socket);
+ nextTick(asyncId, emitFreeNT, socket);
}
}