Browse Source

2007-07-25 Marek Habersack <[email protected]>

	* appdomain.c (get_shadow_assembly_location): do not use TickCount
	to create unique shadow copy target directories, use the domain's
	serial number instead. Each domain gets a unique target directory
	that way.

	* domain.c (mono_domain_create): added code to increment domain
	shadow copy serial number and cache the value in the current
	domain structure.

	* domain-internals.h (struct _MonoDomain): added a new field -
	shadow_serial to hold the serial number used in generation of
	shadow-copy directories. This is to make sure that the directory
	name is unique for each and every domain created. We avoid a race
	condition with overriding assemblies already in use by other app
	domains.

svn path=/trunk/mono/; revision=82635
Marek Habersack 18 years ago
parent
commit
d022fa7cba
4 changed files with 26 additions and 3 deletions
  1. 18 0
      mono/metadata/ChangeLog
  2. 1 2
      mono/metadata/appdomain.c
  3. 1 0
      mono/metadata/domain-internals.h
  4. 6 1
      mono/metadata/domain.c

+ 18 - 0
mono/metadata/ChangeLog

@@ -1,3 +1,21 @@
+2007-07-25  Marek Habersack  <[email protected]>
+
+	* appdomain.c (get_shadow_assembly_location): do not use TickCount
+	to create unique shadow copy target directories, use the domain's
+	serial number instead. Each domain gets a unique target directory
+	that way.
+
+	* domain.c (mono_domain_create): added code to increment domain
+	shadow copy serial number and cache the value in the current
+	domain structure.
+
+	* domain-internals.h (struct _MonoDomain): added a new field -
+	shadow_serial to hold the serial number used in generation of
+	shadow-copy directories. This is to make sure that the directory
+	name is unique for each and every domain created. We avoid a race
+	condition with overriding assemblies already in use by other app
+	domains.
+
 2007-07-24  Rodrigo Kumpera  <[email protected]>
 
 	* class.c (mono_bounded_array_class_get): fixed memory leak when 

+ 1 - 2
mono/metadata/appdomain.c

@@ -851,7 +851,6 @@ static char *
 get_shadow_assembly_location (const char *filename)
 {
 	gint32 hash = 0, hash2 = 0;
-	guint32 ticks = GetTickCount ();
 	char name_hash [9];
 	char path_hash [30];
 	char *bname = g_path_get_basename (filename);
@@ -860,7 +859,7 @@ get_shadow_assembly_location (const char *filename)
 	hash = get_cstring_hash (bname);
 	hash2 = get_cstring_hash (g_path_get_dirname (filename));
 	g_snprintf (name_hash, sizeof (name_hash), "%08x", hash);
-	g_snprintf (path_hash, sizeof (path_hash), "%08x_%08x_%08x", hash ^ hash2, hash2, ticks);
+	g_snprintf (path_hash, sizeof (path_hash), "%08x_%08x_%08x", hash ^ hash2, hash2, domain->shadow_serial);
 	return g_build_filename (mono_string_to_utf8 (domain->setup->dynamic_base), 
 				 "assembly", 
 				 "shadow", 

+ 1 - 0
mono/metadata/domain-internals.h

@@ -127,6 +127,7 @@ struct _MonoDomain {
 	guint32            state;
 	/* Needed by Thread:GetDomainID() */
 	gint32             domain_id;
+	gint32             shadow_serial;
 	GSList             *domain_assemblies;
 	MonoAssembly       *entry_assembly;
 	char               *friendly_name;

+ 6 - 1
mono/metadata/domain.c

@@ -481,13 +481,17 @@ domain_id_alloc (MonoDomain *domain)
 
 static guint32 domain_gc_bitmap [sizeof(MonoDomain)/4/32 + 1];
 static gpointer domain_gc_desc = NULL;
+static guint32 domain_shadow_serial = 0L;
 
 MonoDomain *
 mono_domain_create (void)
 {
 	MonoDomain *domain;
-
+	guint32 shadow_serial;
+  
 	mono_appdomains_lock ();
+	shadow_serial = domain_shadow_serial++;
+  
 	if (!domain_gc_desc) {
 		unsigned int i, bit = 0;
 		for (i = G_STRUCT_OFFSET (MonoDomain, MONO_DOMAIN_FIRST_OBJECT); i < G_STRUCT_OFFSET (MonoDomain, MONO_DOMAIN_FIRST_GC_TRACKED); i += sizeof (gpointer)) {
@@ -499,6 +503,7 @@ mono_domain_create (void)
 	mono_appdomains_unlock ();
 
 	domain = mono_gc_alloc_fixed (sizeof (MonoDomain), domain_gc_desc);
+	domain->shadow_serial = shadow_serial;
 	domain->domain = NULL;
 	domain->setup = NULL;
 	domain->friendly_name = NULL;