-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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: close HandleWraps instead of deleting them in OnGCCollect() #39441
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,7 +85,16 @@ void HandleWrap::Close(Local<Value> close_callback) { | |
|
||
|
||
void HandleWrap::OnGCCollect() { | ||
Close(); | ||
// When all references to a HandleWrap are lost and the object is supposed to | ||
// be destroyed, we first call Close() to clean up the underlying libuv | ||
// handle. The OnClose callback then acquires and destroys another reference | ||
// to that object, and when that reference is lost, we perform the default | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It’s a new one. (The reader of this comment can just look up the source code of the referenced function to see it) |
||
// action (i.e. destroying `this`). | ||
if (state_ != kClosed) { | ||
Close(); | ||
} else { | ||
BaseObject::OnGCCollect(); | ||
} | ||
} | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will this cause behavioral change to other subclasses of
BaseObject
? (for example those who do not have custom implementations ofOnGCCollect
and expects content to be deleted through the old code)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no subclasses other than
HandleWrap
which have customOnGCCollect
behavior, so, no.