diff options
author | Ben Maurer <benm@mono-cvs.ximian.com> | 2005-07-20 01:29:27 +0400 |
---|---|---|
committer | Ben Maurer <benm@mono-cvs.ximian.com> | 2005-07-20 01:29:27 +0400 |
commit | 12e29d94328a7a21d0fd8d0d3713f1fa3c3d92b9 (patch) | |
tree | 28eace926336cc2680320e7ba6580e90f70d6f38 | |
parent | d98314087615a200c7fb2baf9af0da79846d4dd3 (diff) |
merge from head
svn path=/branches/mono-1-1-7/mono/; revision=47438
-rw-r--r-- | mono/metadata/assembly.c | 19 | ||||
-rw-r--r-- | mono/metadata/image.c | 9 | ||||
-rw-r--r-- | mono/metadata/metadata-internals.h | 2 |
3 files changed, 9 insertions, 21 deletions
diff --git a/mono/metadata/assembly.c b/mono/metadata/assembly.c index f4a71a0011a..1a1270dc1ff 100644 --- a/mono/metadata/assembly.c +++ b/mono/metadata/assembly.c @@ -380,10 +380,7 @@ assemblyref_public_tok (MonoImage *image, guint32 key_index, guint32 flags) void mono_assembly_addref (MonoAssembly *assembly) { - EnterCriticalSection (&assemblies_mutex); - /*g_print ("adding ref from %d to %s (%p)\n", assembly->ref_count, assembly->aname.name, assembly);*/ - assembly->ref_count++; - LeaveCriticalSection (&assemblies_mutex); + InterlockedIncrement (&assembly->ref_count); } static MonoAssemblyName * @@ -521,7 +518,7 @@ mono_assembly_load_reference (MonoImage *image, int index) /* Flag as not found */ reference = (gpointer)-1; } else { - reference->ref_count++; + mono_assembly_addref (reference); } if (!image->references [index]) @@ -1479,20 +1476,14 @@ mono_assembly_loaded (MonoAssemblyName *aname) void mono_assembly_close (MonoAssembly *assembly) { - MonoImage *image; - g_return_if_fail (assembly != NULL); - EnterCriticalSection (&assemblies_mutex); - /*g_print ("destroy assembly %p %d (%s)\n", assembly, assembly->ref_count, assembly->image->name);*/ - g_assert (assembly->ref_count > 0); - if (--assembly->ref_count != 0) { - LeaveCriticalSection (&assemblies_mutex); + if (InterlockedDecrement (&assembly->ref_count)) return; - } + + EnterCriticalSection (&assemblies_mutex); loaded_assemblies = g_list_remove (loaded_assemblies, assembly); LeaveCriticalSection (&assemblies_mutex); - image = assembly->image; /* assemblies belong to domains, so the domain code takes care of unloading the * referenced assemblies */ diff --git a/mono/metadata/image.c b/mono/metadata/image.c index 9d0369296ac..785de4da87b 100644 --- a/mono/metadata/image.c +++ b/mono/metadata/image.c @@ -995,13 +995,10 @@ mono_image_close (MonoImage *image) g_return_if_fail (image != NULL); - EnterCriticalSection (&images_mutex); - /*g_print ("destroy image '%s' %p (dynamic: %d) refcount: %d\n", image->name, image, image->dynamic, image->ref_count);*/ - g_assert (image->ref_count > 0); - if (--image->ref_count) { - LeaveCriticalSection (&images_mutex); + if (InterlockedDecrement (&image->ref_count)) return; - } + + EnterCriticalSection (&images_mutex); image2 = g_hash_table_lookup (loaded_images_hash, image->name); if (image == image2) { /* This is not true if we are called from mono_image_open () */ diff --git a/mono/metadata/metadata-internals.h b/mono/metadata/metadata-internals.h index daa6bd931e3..311b9680f93 100644 --- a/mono/metadata/metadata-internals.h +++ b/mono/metadata/metadata-internals.h @@ -8,7 +8,7 @@ #include "mono/utils/mono-hash.h" struct _MonoAssembly { - int ref_count; + int ref_count; /* use atomic operations only */ char *basedir; MonoAssemblyName aname; GModule *aot_module; |