Skip to content

Commit

Permalink
merge from head
Browse files Browse the repository at this point in the history
svn path=/branches/mono-1-1-7/mono/; revision=47438
  • Loading branch information
Ben Maurer committed Jul 19, 2005
1 parent d983140 commit 12e29d9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
19 changes: 5 additions & 14 deletions mono/metadata/assembly.c
Expand Up @@ -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 *
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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
*/
Expand Down
9 changes: 3 additions & 6 deletions mono/metadata/image.c
Expand Up @@ -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 () */
Expand Down
2 changes: 1 addition & 1 deletion mono/metadata/metadata-internals.h
Expand Up @@ -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;
Expand Down

0 comments on commit 12e29d9

Please sign in to comment.