Author: lupus
Date: 2006-09-11 07:03:33 -0400 (Mon, 11 Sep 2006)
New Revision: 65220
Modified:
trunk/mono/mono/metadata/ChangeLog
trunk/mono/mono/metadata/appdomain.c
trunk/mono/mono/metadata/gc-internal.h
trunk/mono/mono/metadata/gc.c
Log:
Mon Sep 11 12:57:15 CEST 2006 Paolo Molaro <[EMAIL PROTECTED]>
* gc-internal.h, appdomain.c, gc.c: force-destroy GC handles on domain
unload.
Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog 2006-09-11 11:02:03 UTC (rev 65219)
+++ trunk/mono/mono/metadata/ChangeLog 2006-09-11 11:03:33 UTC (rev 65220)
@@ -1,3 +1,9 @@
+
+Mon Sep 11 12:57:15 CEST 2006 Paolo Molaro <[EMAIL PROTECTED]>
+
+ * gc-internal.h, appdomain.c, gc.c: force-destroy GC handles on domain
+ unload.
+
2006-09-10 Zoltan Varga <[EMAIL PROTECTED]>
* object.c (mono_method_return_message_restore): Avoid a crash if one
of the out
Modified: trunk/mono/mono/metadata/appdomain.c
===================================================================
--- trunk/mono/mono/metadata/appdomain.c 2006-09-11 11:02:03 UTC (rev
65219)
+++ trunk/mono/mono/metadata/appdomain.c 2006-09-11 11:03:33 UTC (rev
65220)
@@ -1324,6 +1324,9 @@
/* printf ("UNLOADED %s.\n", domain->friendly_name); */
+ /* remove from the handle table the items related to this domain */
+ //mono_gchandle_free_domain (domain);
+
mono_domain_free (domain, FALSE);
mono_gc_collect (mono_gc_max_generation ());
Modified: trunk/mono/mono/metadata/gc-internal.h
===================================================================
--- trunk/mono/mono/metadata/gc-internal.h 2006-09-11 11:02:03 UTC (rev
65219)
+++ trunk/mono/mono/metadata/gc-internal.h 2006-09-11 11:03:33 UTC (rev
65220)
@@ -69,6 +69,7 @@
/* make sure the gchandle was allocated for an object in domain */
gboolean mono_gchandle_is_in_domain (guint32 gchandle, MonoDomain *domain);
+void mono_gchandle_free_domain (MonoDomain *domain);
/* if there are finalizers to run, run them. Returns the number of finalizers
run */
int mono_gc_invoke_finalizers (void);
Modified: trunk/mono/mono/metadata/gc.c
===================================================================
--- trunk/mono/mono/metadata/gc.c 2006-09-11 11:02:03 UTC (rev 65219)
+++ trunk/mono/mono/metadata/gc.c 2006-09-11 11:03:33 UTC (rev 65220)
@@ -682,6 +682,43 @@
unlock_handles (handles);
}
+/**
+ * mono_gchandle_free_domain:
+ * @domain: domain that is unloading
+ *
+ * Function used internally to cleanup any GC handle for objects belonging
+ * to the specified domain during appdomain unload.
+ */
+void
+mono_gchandle_free_domain (MonoDomain *domain)
+{
+ guint type;
+
+ for (type = 0; type < 3; ++type) {
+ guint slot;
+ HandleData *handles = &gc_handles [type];
+ lock_handles (handles);
+ for (slot = 0; slot < handles->size; ++slot) {
+ if (!(handles->bitmap [slot / 32] & (1 << (slot % 32))))
+ continue;
+ if (type <= HANDLE_WEAK_TRACK) {
+ if (domain->domain_id == handles->domain_ids
[slot]) {
+ handles->bitmap [slot / 32] &= ~(1 <<
(slot % 32));
+ if (handles->entries [slot])
+ mono_gc_weak_link_remove
(&handles->entries [slot]);
+ }
+ } else {
+ if (handles->entries [slot] &&
mono_object_domain (handles->entries [slot]) == domain) {
+ handles->bitmap [slot / 32] &= ~(1 <<
(slot % 32));
+ handles->entries [slot] = NULL;
+ }
+ }
+ }
+ unlock_handles (handles);
+ }
+
+}
+
#ifndef HAVE_NULL_GC
static HANDLE finalizer_event;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches