Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 75ecf8e

Browse filesBrowse files
AndreasMadsenMyles Borins
authored andcommitted
async_wrap: add parent uid to init hook
When the parent uid is required it is not necessary to store the uid in the parent handle object. Ref: #7048 PR-URL: #4600 Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
1 parent e10eebf commit 75ecf8e
Copy full SHA for 75ecf8e

File tree

Expand file treeCollapse file tree

3 files changed

+27
-8
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+27
-8
lines changed
Open diff view settings
Collapse file

‎src/async-wrap-inl.h‎

Copy file name to clipboardExpand all lines: src/async-wrap-inl.h
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,14 @@ inline AsyncWrap::AsyncWrap(Environment* env,
4242
v8::Local<v8::Value> argv[] = {
4343
v8::Integer::New(env->isolate(), get_uid()),
4444
v8::Int32::New(env->isolate(), provider),
45+
Null(env->isolate()),
4546
Null(env->isolate())
4647
};
4748

48-
if (parent != nullptr)
49-
argv[2] = parent->object();
49+
if (parent != nullptr) {
50+
argv[2] = v8::Integer::New(env->isolate(), parent->get_uid());
51+
argv[3] = parent->object();
52+
}
5053

5154
v8::MaybeLocal<v8::Value> ret =
5255
init_fn->Call(env->context(), object, arraysize(argv), argv);
Collapse file

‎test/parallel/test-async-wrap-disabled-propagate-parent.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-async-wrap-disabled-propagate-parent.js
+10-3Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,23 @@ const net = require('net');
66
const async_wrap = process.binding('async_wrap');
77
const providers = Object.keys(async_wrap.Providers);
88

9+
const uidSymbol = Symbol('uid');
10+
911
let cntr = 0;
1012
let client;
1113

12-
function init(id, type, parent) {
13-
if (parent) {
14+
function init(uid, type, parentUid, parentHandle) {
15+
this[uidSymbol] = uid;
16+
17+
if (parentHandle) {
1418
cntr++;
1519
// Cannot assert in init callback or will abort.
1620
process.nextTick(() => {
1721
assert.equal(providers[type], 'TCPWRAP');
18-
assert.equal(parent, server._handle, 'server doesn\'t match parent');
22+
assert.equal(parentUid, server._handle[uidSymbol],
23+
'server uid doesn\'t match parent uid');
24+
assert.equal(parentHandle, server._handle,
25+
'server handle doesn\'t match parent handle');
1926
assert.equal(this, client._handle, 'client doesn\'t match context');
2027
});
2128
}
Collapse file

‎test/parallel/test-async-wrap-propagate-parent.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-async-wrap-propagate-parent.js
+12-3Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,25 @@ const common = require('../common');
44
const assert = require('assert');
55
const net = require('net');
66
const async_wrap = process.binding('async_wrap');
7+
const providers = Object.keys(async_wrap.Providers);
8+
9+
const uidSymbol = Symbol('uid');
710

811
let cntr = 0;
912
let client;
1013

11-
function init(id, type, parent) {
12-
if (parent) {
14+
function init(uid, type, parentUid, parentHandle) {
15+
this[uidSymbol] = uid;
16+
17+
if (parentHandle) {
1318
cntr++;
1419
// Cannot assert in init callback or will abort.
1520
process.nextTick(() => {
16-
assert.equal(parent, server._handle, 'server doesn\'t match parent');
21+
assert.equal(providers[type], 'TCPWRAP');
22+
assert.equal(parentUid, server._handle[uidSymbol],
23+
'server uid doesn\'t match parent uid');
24+
assert.equal(parentHandle, server._handle,
25+
'server handle doesn\'t match parent handle');
1726
assert.equal(this, client._handle, 'client doesn\'t match context');
1827
});
1928
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.