Move wapi shutdown to mono_cleanup () as TlsGetValue()/TlsSetValue() is used
[mono.git] / mono / metadata / appdomain.c
index 13a3d5f54d9560fd569e7ff2ca63b74224d73837..47d2febbf4a543749a04d7a736acb7b738b055ac 100644 (file)
@@ -73,7 +73,7 @@
  * Changes which are already detected at runtime, like the addition
  * of icalls, do not require an increment.
  */
-#define MONO_CORLIB_VERSION 90
+#define MONO_CORLIB_VERSION 91
 
 typedef struct
 {
@@ -165,7 +165,7 @@ mono_runtime_get_no_exec (void)
 }
 
 static void
-create_exceptions (MonoDomain *domain)
+create_domain_objects (MonoDomain *domain)
 {
        MonoDomain *old_domain = mono_domain_get ();
        MonoString *arg;
@@ -190,6 +190,9 @@ create_exceptions (MonoDomain *domain)
        arg = mono_string_new (domain, "The requested operation caused a stack overflow.");
        domain->stack_overflow_ex = mono_exception_from_name_two_strings (mono_defaults.corlib, "System", "StackOverflowException", arg, NULL);
 
+       /*The ephemeron tombstone i*/
+       domain->ephemeron_tombstone = mono_object_new (domain, mono_defaults.object_class);
+
        if (domain != old_domain) {
                mono_thread_pop_appdomain_ref ();
                mono_domain_set_internal_with_options (old_domain, FALSE);
@@ -263,7 +266,7 @@ mono_runtime_init (MonoDomain *domain, MonoThreadStartCB start_cb,
        mono_type_initialization_init ();
 
        if (!mono_runtime_get_no_exec ())
-               create_exceptions (domain);
+               create_domain_objects (domain);
 
        /* GC init has to happen after thread init */
        mono_gc_init ();
@@ -367,10 +370,6 @@ mono_runtime_cleanup (MonoDomain *domain)
        mono_type_initialization_cleanup ();
 
        mono_monitor_cleanup ();
-
-#ifndef HOST_WIN32
-       _wapi_cleanup ();
-#endif
 }
 
 static MonoDomainFunc quit_function = NULL;
@@ -516,7 +515,7 @@ mono_domain_create_appdomain_internal (char *friendly_name, MonoAppDomainSetup *
        g_free (shadow_location);
 #endif
 
-       create_exceptions (data);
+       create_domain_objects (data);
 
        return ad;
 }
@@ -539,6 +538,10 @@ mono_domain_has_type_resolve (MonoDomain *domain)
                g_assert (field);
        }
 
+       /*pedump doesn't create an appdomin, so the domain object doesn't exist.*/
+       if (!domain->domain)
+               return FALSE;
+
        mono_field_get_value ((MonoObject*)(domain->domain), field, &o);
        return o != NULL;
 }
@@ -1259,8 +1262,18 @@ shadow_copy_sibling (gchar *src, gint srclen, const char *extension, gchar *targ
        gboolean copy_result;
        
        strcpy (src + srclen - tail_len, extension);
-       if (!g_file_test (src, G_FILE_TEST_IS_REGULAR))
+
+       if (IS_PORTABILITY_CASE) {
+               gchar *file = mono_portability_find_file (src, TRUE);
+
+               if (file == NULL)
+                       return TRUE;
+
+               g_free (file);
+       } else if (!g_file_test (src, G_FILE_TEST_IS_REGULAR)) {
                return TRUE;
+       }
+
        orig = g_utf8_to_utf16 (src, strlen (src), NULL, NULL, NULL);
 
        strcpy (target + targetlen - tail_len, extension);