-
Notifications
You must be signed in to change notification settings - Fork 553
Attach unattached threads before querying for the current domain #6223
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
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 |
---|---|---|
|
@@ -1041,7 +1041,7 @@ OSBridge::ensure_jnienv (void) | |
JNIEnv *env; | ||
jvm->GetEnv ((void**)&env, JNI_VERSION_1_6); | ||
if (env == nullptr) { | ||
mono_thread_attach (mono_domain_get ()); | ||
mono_thread_attach (utils.get_current_domain (/* attach_thread_if_needed */ false)); | ||
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. If Why not just call 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. We can't do that. If |
||
jvm->GetEnv ((void**)&env, JNI_VERSION_1_6); | ||
} | ||
return env; | ||
|
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.
How does
mono_thread_attach()
differ frommono_jit_thread_attach()
? Why useutils.get_current_domain (/* attach_thread_if_needed */ false)
instead of usingutils.get_current_domain ()
and removing themono_jit_thread_attach()
invocation?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.
mono_jit_thread_attach
will callmono_get_root_domain()
when thedomain
passed to it isNULL
, basically what ourutils.get_current_domain()
does and it also switches to the new domain if it's different than the current one (somethingmono_thread_attach
doesn't do). The reason I left it around and added the call toutils.get_current_domain
is because I usually try not to make as few changes to existing code as possible, usingutils.get_current_domain
is consistent throughout the code and there's the subtle side effect ofmono_jit_thread_attach
switching to the passed domain.