[Asterisk-cvs] asterisk loader.c,1.26,1.26.2.1

russell at lists.digium.com russell at lists.digium.com
Mon Dec 6 21:19:00 CST 2004


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv24382

Modified Files:
      Tag: v1-0
	loader.c 
Log Message:
Don't hold modlock while doing reload


Index: loader.c
===================================================================
RCS file: /usr/cvsroot/asterisk/loader.c,v
retrieving revision 1.26
retrieving revision 1.26.2.1
diff -u -d -r1.26 -r1.26.2.1
--- loader.c	3 Sep 2004 14:02:12 -0000	1.26
+++ loader.c	7 Dec 2004 02:16:49 -0000	1.26.2.1
@@ -103,6 +103,7 @@
 AST_MUTEX_DEFINE_STATIC(reloadlock);
 
 static struct module *module_list=NULL;
+static int modlistver = 0;
 
 int ast_unload_resource(char *resource_name, int force)
 {
@@ -142,6 +143,7 @@
 		ml = m;
 		m = m->next;
 	}
+	modlistver = rand();
 	ast_mutex_unlock(&modlock);
 	ast_update_use_count();
 	return res;
@@ -150,6 +152,8 @@
 void ast_module_reload(const char *name)
 {
 	struct module *m;
+	int oldversion;
+	int (*reload)(void);
 
 	/* We'll do the logger and manager the favor of calling its reload here first */
 
@@ -168,14 +172,20 @@
 	time(&ast_lastreloadtime);
 
 	ast_mutex_lock(&modlock);
+	oldversion = modlistver;	
 	m = module_list;
 	while(m) {
 		if (!name || !strcasecmp(name, m->resource)) {
-			if (m->reload) {
+			reload = m->reload;
+			ast_mutex_unlock(&modlock);
+			if (reload) {
 				if (option_verbose > 2) 
 					ast_verbose(VERBOSE_PREFIX_3 "Reloading module '%s' (%s)\n", m->resource, m->description());
-				m->reload();
+				reload();	
 			}
+			ast_mutex_lock(&modlock);
+			if (oldversion != modlistver)
+				break;
 		}
 		m = m->next;
 	}
@@ -328,7 +338,8 @@
 			;
 		i->next = m;
 	}
-	
+
+	modlistver = rand();
 	ast_mutex_unlock(&modlock);
 	if ((res = m->load_module())) {
 		ast_log(LOG_WARNING, "%s: load_module failed, returning %d\n", m->resource, res);




More information about the svn-commits mailing list