#include <mono/metadata/domain-internals.h>
#include "mono/metadata/metadata-internals.h"
#include <mono/metadata/assembly.h>
+#include <mono/metadata/assembly-internals.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/exception-internals.h>
#include <mono/metadata/threads.h>
#include <mono/metadata/marshal-internals.h>
#include <mono/metadata/monitor.h>
#include <mono/metadata/mono-debug.h>
-#include <mono/metadata/mono-debug-debugger.h>
#include <mono/metadata/attach.h>
#include <mono/metadata/w32file.h>
#include <mono/metadata/lock-tracer.h>
if (!is_ok (error))
goto leave;
- MonoAssembly *ass = mono_assembly_open_full (filename, &status, refOnly);
+ MonoAssembly *ass = mono_assembly_open_predicate (filename, refOnly, TRUE, NULL, NULL, &status);
if (!ass) {
if (status == MONO_IMAGE_IMAGE_INVALID)
MonoError error;
unload_data *data = (unload_data*)arg;
MonoDomain *domain = data->domain;
- MonoThread *thread;
+ MonoInternalThread *internal;
int i;
- /* Have to attach to the runtime so shutdown can wait for this thread */
- /* Force it to be attached to avoid racing during shutdown. */
- thread = mono_thread_attach_full (mono_get_root_domain (), TRUE);
+ internal = mono_thread_internal_current ();
- mono_thread_set_name_internal (thread->internal_thread, mono_string_new (mono_get_root_domain (), "Domain unloader"), TRUE, FALSE, &error);
+ mono_thread_set_name_internal (internal, mono_string_new (mono_domain_get (), "Domain unloader"), TRUE, FALSE, &error);
if (!is_ok (&error)) {
data->failure_reason = g_strdup (mono_error_get_message (&error));
mono_error_cleanup (&error);
mono_domain_unlock (domain);
mono_loader_unlock ();
- mono_threads_clear_cached_culture (domain);
-
domain->state = MONO_APPDOMAIN_UNLOADED;
/* printf ("UNLOADED %s.\n", domain->friendly_name); */
mono_atomic_store_release (&data->done, TRUE);
unload_data_unref (data);
- mono_thread_detach (thread);
return 0;
failure:
mono_atomic_store_release (&data->done, TRUE);
unload_data_unref (data);
- mono_thread_detach (thread);
return 1;
}
MonoAppDomainState prev_state;
MonoMethod *method;
unload_data *thread_data;
- MonoNativeThreadId tid;
+ MonoInternalThread *internal;
MonoDomain *caller_domain = mono_domain_get ();
/* printf ("UNLOAD STARTING FOR %s (%p) IN THREAD 0x%x.\n", domain->friendly_name, domain, mono_native_thread_id_get ()); */
/*
* First we create a separate thread for unloading, since
* we might have to abort some threads, including the current one.
+ *
+ * Have to attach to the runtime so shutdown can wait for this thread.
+ *
+ * Force it to be attached to avoid racing during shutdown.
*/
- thread_handle = mono_threads_create_thread (unload_thread_main, thread_data, NULL, &tid);
- if (thread_handle == NULL)
- return;
+ internal = mono_thread_create_internal (mono_get_root_domain (), unload_thread_main, thread_data, MONO_THREAD_CREATE_FLAGS_FORCE_CREATE, &error);
+ mono_error_assert_ok (&error);
+
+ thread_handle = mono_threads_open_thread_handle (internal->handle);
/* Wait for the thread */
while (!thread_data->done && guarded_wait (thread_handle, MONO_INFINITE_WAIT, TRUE) == MONO_THREAD_INFO_WAIT_RET_ALERTED) {