Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

async_wrap: correctly pass parent to init callback #3216

Closed
wants to merge 1 commit into from

Conversation

trevnorris
Copy link
Contributor

Previous logic didn't allow parent to propagate to the init callback
properly. The fix now allows the init callback to be called and passed
the parent if:

  • async wrap callbacks are enabled and parent exists
  • the init callback has been called on the parent and an init callback
    exists then it will be called regardless of whether async wrap
    callbacks are disabled.

Change the init/pre/post callback checks to see if it has been properly
set. This allows removal of the Environment "using_asyncwrap" variable.

Pass Isolate to TryCatch instance.

R=@bnoordhuis

CI: https://ci.nodejs.org/job/node-test-pull-request/428/

@trevnorris trevnorris added the c++ Issues and PRs that require attention from people who are familiar with C++. label Oct 6, 2015
// Cannot assert in init callback or will abort.
process.nextTick(() => {
assert.equal(parent, server._handle, 'server doesn\'t match parent');
assert.equal(this, client._handle, 'client doesn\t match context');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: doesn\'t

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah whoop. thanks.

const assert = require('assert');
const net = require('net');
const async_wrap = process.binding('async_wrap');
const providers = Object.keys(async_wrap.Providers);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't seem to be used

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. fixed.

@rvagg
Copy link
Member

rvagg commented Oct 7, 2015

lgtm, /cc @thlorenz

Previous logic didn't allow parent to propagate to the init callback
properly. The fix now allows the init callback to be called and passed
the parent if:

- async wrap callbacks are enabled and parent exists
- the init callback has been called on the parent and an init callback
  exists then it will be called regardless of whether async wrap
  callbacks are disabled.

Change the init/pre/post callback checks to see if it has been properly
set. This allows removal of the Environment "using_asyncwrap" variable.

Pass Isolate to TryCatch instance.
@trevnorris
Copy link
Contributor Author

trevnorris added a commit that referenced this pull request Oct 7, 2015
Previous logic didn't allow parent to propagate to the init callback
properly. The fix now allows the init callback to be called and receive
the parent if:

- async wrap callbacks are enabled and parent exists
- the init callback has been called on the parent and an init callback
  exists then it will be called regardless of whether async wrap
  callbacks are disabled.

Change the init/pre/post callback checks to see if it has been properly
set. This allows removal of the Environment "using_asyncwrap" variable.

Pass Isolate to a TryCatch instance.

Fixes: #2986
PR-URL: #3216
Reviewed-By: Rod Vagg <rod@vagg.org>
@trevnorris
Copy link
Contributor Author

CI is green. Landed in aeee956.

@trevnorris trevnorris closed this Oct 7, 2015
@trevnorris trevnorris deleted the propagate-parent branch October 7, 2015 20:15
@jasnell jasnell mentioned this pull request Oct 8, 2015
29 tasks
trevnorris added a commit that referenced this pull request Oct 8, 2015
Previous logic didn't allow parent to propagate to the init callback
properly. The fix now allows the init callback to be called and receive
the parent if:

- async wrap callbacks are enabled and parent exists
- the init callback has been called on the parent and an init callback
  exists then it will be called regardless of whether async wrap
  callbacks are disabled.

Change the init/pre/post callback checks to see if it has been properly
set. This allows removal of the Environment "using_asyncwrap" variable.

Pass Isolate to a TryCatch instance.

Fixes: #2986
PR-URL: #3216
Reviewed-By: Rod Vagg <rod@vagg.org>
@MylesBorins
Copy link
Member

landed in v4.x-staging in 3eaa593

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants