2009-06-04 Zoltan Varga <vargaz@gmail.com>
[mono.git] / mono / metadata / domain.c
index 2063133e058b64afb9e081feb656e99dd6890b83..f870683f131136693a4a31e3fb2ff8474bc35478 100644 (file)
@@ -1199,7 +1199,9 @@ mono_domain_create (void)
        domain->jit_info_table = jit_info_table_new (domain);
        domain->jit_info_free_queue = NULL;
        domain->finalizable_objects_hash = g_hash_table_new (mono_aligned_addr_hash, NULL);
+#ifndef HAVE_SGEN_GC
        domain->track_resurrection_handles_hash = g_hash_table_new (mono_aligned_addr_hash, NULL);
+#endif
 
        InitializeCriticalSection (&domain->lock);
        InitializeCriticalSection (&domain->assemblies_lock);
@@ -1759,6 +1761,9 @@ mono_domain_set_internal_with_options (MonoDomain *domain, gboolean migrate_exce
 {
        MonoThread *thread;
 
+       if (mono_domain_get () == domain)
+               return;
+
        SET_APPDOMAIN (domain);
        SET_APPCONTEXT (domain->default_context);
 
@@ -1865,6 +1870,8 @@ mono_domain_free (MonoDomain *domain, gboolean force)
 
        mono_debug_domain_unload (domain);
 
+       mono_gc_clear_domain (domain);
+
        mono_appdomains_lock ();
        appdomains_list [domain->domain_id] = NULL;
        mono_appdomains_unlock ();
@@ -1951,12 +1958,14 @@ mono_domain_free (MonoDomain *domain, gboolean force)
        }
        g_hash_table_destroy (domain->finalizable_objects_hash);
        domain->finalizable_objects_hash = NULL;
+#ifndef HAVE_SGEN_GC
        if (domain->track_resurrection_objects_hash) {
                g_hash_table_foreach (domain->track_resurrection_objects_hash, free_slist, NULL);
                g_hash_table_destroy (domain->track_resurrection_objects_hash);
        }
        if (domain->track_resurrection_handles_hash)
                g_hash_table_destroy (domain->track_resurrection_handles_hash);
+#endif
        if (domain->method_rgctx_hash) {
                g_hash_table_destroy (domain->method_rgctx_hash);
                domain->method_rgctx_hash = NULL;