X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Fappdomain.c;h=0608394ff10b1db34d66b3aefc98aee657cf0cb1;hb=2c48afbc63c9ff04f4b188f9c471c15a8aa2b287;hp=82150dbe0574a8f5477b22d387e4373587e2d03f;hpb=3fc81be928a070d9aee16fba5f36e144f42d3c91;p=mono.git diff --git a/mono/metadata/appdomain.c b/mono/metadata/appdomain.c index 82150dbe057..0608394ff10 100644 --- a/mono/metadata/appdomain.c +++ b/mono/metadata/appdomain.c @@ -58,6 +58,7 @@ #include #include #include +#include #include #include #include @@ -83,7 +84,7 @@ * Changes which are already detected at runtime, like the addition * of icalls, do not require an increment. */ -#define MONO_CORLIB_VERSION 151 +#define MONO_CORLIB_VERSION 157 typedef struct { @@ -343,8 +344,14 @@ mono_check_corlib_version (void) int version = mono_get_corlib_version (); if (version != MONO_CORLIB_VERSION) return g_strdup_printf ("expected corlib version %d, found %d.", MONO_CORLIB_VERSION, version); - else - return NULL; + + /* Check that the managed and unmanaged layout of MonoInternalThread matches */ + guint32 native_offset = (guint32) MONO_STRUCT_OFFSET (MonoInternalThread, last); + guint32 managed_offset = mono_field_get_offset (mono_class_get_field_from_name (mono_defaults.internal_thread_class, "last")); + if (native_offset != managed_offset) + return g_strdup_printf ("expected InternalThread.last field offset %u, found %u. See InternalThread.last comment", native_offset, managed_offset); + + return NULL; } /** @@ -2355,7 +2362,7 @@ deregister_reflection_info_roots (MonoDomain *domain) mono_domain_assemblies_unlock (domain); } -static guint32 WINAPI +static gsize WINAPI unload_thread_main (void *arg) { MonoError error; @@ -2505,7 +2512,6 @@ mono_domain_try_unload (MonoDomain *domain, MonoObject **exc) unload_data *thread_data; MonoNativeThreadId tid; MonoDomain *caller_domain = mono_domain_get (); - MonoThreadParm tp; /* printf ("UNLOAD STARTING FOR %s (%p) IN THREAD 0x%x.\n", domain->friendly_name, domain, mono_native_thread_id_get ()); */ @@ -2562,25 +2568,22 @@ mono_domain_try_unload (MonoDomain *domain, MonoObject **exc) * First we create a separate thread for unloading, since * we might have to abort some threads, including the current one. */ - tp.priority = 0; - tp.stack_size = 0; - tp.creation_flags = CREATE_SUSPENDED; - thread_handle = mono_threads_create_thread ((LPTHREAD_START_ROUTINE)unload_thread_main, thread_data, &tp, &tid); + thread_handle = mono_threads_create_thread (unload_thread_main, thread_data, 0, &tid); if (thread_handle == NULL) return; - mono_thread_info_resume (tid); /* Wait for the thread */ while (!thread_data->done && guarded_wait (thread_handle, INFINITE, TRUE) == WAIT_IO_COMPLETION) { if (mono_thread_internal_has_appdomain_ref (mono_thread_internal_current (), domain) && (mono_thread_interruption_requested ())) { /* The unload thread tries to abort us */ /* The icall wrapper will execute the abort */ - CloseHandle (thread_handle); + mono_threads_close_thread_handle (thread_handle); unload_data_unref (thread_data); return; } } - CloseHandle (thread_handle); + + mono_threads_close_thread_handle (thread_handle); if (thread_data->failure_reason) { /* Roll back the state change */