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

src: use libuv's refcounting directly #6395

Merged
merged 3 commits into from
Apr 27, 2016

Conversation

bnoordhuis
Copy link
Member

@bnoordhuis bnoordhuis commented Apr 26, 2016

The first commit is cleanup:

Don't implement an additional reference counting scheme on top of libuv.
Libuv is the canonical source for that information so use it directly.

The second one is what I think the logic should be:

This also updates the tests to expect that a closed handle has no
reference count.

R=@Fishrock123

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

@bnoordhuis bnoordhuis added the c++ Issues and PRs that require attention from people who are familiar with C++. label Apr 26, 2016
@addaleax
Copy link
Member

Nice, LGTM!

@cjihrig
Copy link
Contributor

cjihrig commented Apr 26, 2016

LGTM

@Fishrock123
Copy link
Contributor

This still has the same behavior though?

i.e. IsAlive is required to get the unref flag from a handle in case it is gone?

Should we just track this in JS?

NOT lgtm since this will interfere with likely reverts of my commits.

@addaleax
Copy link
Member

@Fishrock123 fwiw, #6381 passes when replayed on top of this

@bnoordhuis
Copy link
Member Author

Should we just track this in JS?

I'm not sure what 'this' refers to. The reference count, liveliness, or something else?

@jasnell
Copy link
Member

jasnell commented Apr 26, 2016

LGTM. Should this go into v6?

@bnoordhuis
Copy link
Member Author

Well... #6401 might block that.

Don't implement an additional reference counting scheme on top of libuv.
Libuv is the canonical source for that information so use it directly.

PR-URL: nodejs#6395
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
This also updates the tests to expect that a closed handle has no
reference count.

PR-URL: nodejs#6395
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Verify that a second call to handle.close() is a no-op.

PR-URL: nodejs#6395
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@bnoordhuis bnoordhuis closed this Apr 27, 2016
@bnoordhuis bnoordhuis deleted the handlewrap-refcounting branch April 27, 2016 14:32
@bnoordhuis bnoordhuis merged commit 4282405 into nodejs:master Apr 27, 2016
@bnoordhuis
Copy link
Member Author

Seeing how the reverts never landed (#6401 (comment)), I went ahead and landed this in 23818c6...4282405.

@Fishrock123
Copy link
Contributor

That's fine; but this is also a behavior breaker and will make fixing my stupid API problems even more complex.

Fishrock123 added a commit to Fishrock123/node that referenced this pull request May 3, 2016
This reverts commit 9bb5a5e.

Refs: nodejs#6395
Refs: nodejs#6204
Refs: nodejs#6401
Refs: nodejs#6382
Fixes: nodejs#6381

Conflicts:
	src/handle_wrap.cc
	test/parallel/test-handle-wrap-isrefed-tty.js
	test/parallel/test-handle-wrap-isrefed.js
Fishrock123 added a commit to Fishrock123/node that referenced this pull request May 11, 2016
This reverts commit 9bb5a5e.

This API is not suitable because it depended on being able to
potentially access the handle's flag after the handle was already
cleaned up. Since this is not actually possible (obviously, oops)
this newer API no longer makes much sense, and the older API is more
suitable.

API comparison:
IsRefed -> Has a strong reference AND is alive. (Deterministic)
Unrefed -> Has a weak reference OR is dead. (Less deterministic)

Refs: nodejs#6395
Refs: nodejs#6204
Refs: nodejs#6401
Refs: nodejs#6382
Fixes: nodejs#6381

PR-URL: nodejs#6546
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Trevor Norris <[email protected]>

Conflicts:
	src/handle_wrap.cc
	test/parallel/test-handle-wrap-isrefed-tty.js
	test/parallel/test-handle-wrap-isrefed.js
Fishrock123 added a commit to Fishrock123/node that referenced this pull request May 11, 2016
Rename slightly to HasRef() at bnoordhuis’ request.
Better reflects what we actually do for this check.

Refs: nodejs#6395
Refs: nodejs#6204
Refs: nodejs#6401
Refs: nodejs#6382
Refs: nodejs#6381

PR-URL: nodejs#6546
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Trevor Norris <[email protected]>
evanlucas pushed a commit that referenced this pull request May 17, 2016
Don't implement an additional reference counting scheme on top of libuv.
Libuv is the canonical source for that information so use it directly.

PR-URL: #6395
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
evanlucas pushed a commit that referenced this pull request May 17, 2016
This also updates the tests to expect that a closed handle has no
reference count.

PR-URL: #6395
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
evanlucas pushed a commit that referenced this pull request May 17, 2016
Verify that a second call to handle.close() is a no-op.

PR-URL: #6395
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
evanlucas pushed a commit that referenced this pull request May 17, 2016
This reverts commit 9bb5a5e.

This API is not suitable because it depended on being able to
potentially access the handle's flag after the handle was already
cleaned up. Since this is not actually possible (obviously, oops)
this newer API no longer makes much sense, and the older API is more
suitable.

API comparison:
IsRefed -> Has a strong reference AND is alive. (Deterministic)
Unrefed -> Has a weak reference OR is dead. (Less deterministic)

Refs: #6395
Refs: #6204
Refs: #6401
Refs: #6382
Fixes: #6381

PR-URL: #6546
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Trevor Norris <[email protected]>

Conflicts:
	src/handle_wrap.cc
	test/parallel/test-handle-wrap-isrefed-tty.js
	test/parallel/test-handle-wrap-isrefed.js
evanlucas pushed a commit that referenced this pull request May 17, 2016
Rename slightly to HasRef() at bnoordhuis’ request.
Better reflects what we actually do for this check.

Refs: #6395
Refs: #6204
Refs: #6401
Refs: #6382
Refs: #6381

PR-URL: #6546
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Trevor Norris <[email protected]>
@MylesBorins
Copy link
Contributor

I'm setting this as don't land... @Fishrock123 / @bnoordhuis please let me know if that is incorrect

@Fishrock123
Copy link
Contributor

Hmmmm, seems fine unless @bnoordhuis Thinks it's important to backport. May need to be manual because this depended on my handle wrap additions.

@bnoordhuis
Copy link
Member Author

I'm okay with having it back-ported (as long as I don't have to do the work - hah!) but it's not strictly necessary from a 'bug fixes only' perspective.

@MylesBorins
Copy link
Contributor

I'll put it on watch and see if it lands nicely... if it doesn't we just won't do it 😄

@MylesBorins
Copy link
Contributor

@bnoordhuis this does not land cleanly and I've added the dont-land label. Please feel free to revisit this if you like

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.

6 participants