[Asterisk-cvs] asterisk loader.c,1.30,1.31
markster at lists.digium.com
markster at lists.digium.com
Wed Nov 17 08:40:18 CST 2004
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv22697
Modified Files:
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.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- loader.c 13 Nov 2004 22:44:32 -0000 1.30
+++ loader.c 17 Nov 2004 13:40:47 -0000 1.31
@@ -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;
@@ -190,6 +192,8 @@
{
struct module *m;
int reloaded = 0;
+ int oldversion;
+ int (*reload)(void);
/* We'll do the logger and manager the favor of calling its reload here first */
if (ast_mutex_trylock(&reloadlock)) {
@@ -215,17 +219,23 @@
time(&ast_lastreloadtime);
ast_mutex_lock(&modlock);
+ oldversion = modlistver;
m = module_list;
while(m) {
if (!name || !strcasecmp(name, m->resource)) {
if (reloaded < 1)
reloaded = 1;
- if (m->reload) {
+ reload = m->reload;
+ ast_mutex_unlock(&modlock);
+ if (reload) {
reloaded = 2;
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;
}
@@ -380,6 +390,7 @@
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