]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix a race condition in cdr_pgsql that can occur when reloading the module.
authorJason Parker <jparker@digium.com>
Wed, 20 Jun 2007 22:31:35 +0000 (22:31 +0000)
committerJason Parker <jparker@digium.com>
Wed, 20 Jun 2007 22:31:35 +0000 (22:31 +0000)
Issue 10022, patch by me, with credit to prashant_jois for finding the bug.

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@70554 65c4cc65-6c06-0410-ace0-fbb531ad65f3

cdr/cdr_pgsql.c

index 7788cf037912c1981a8272d1eab1f770b691cdee..14f343abd710d60222c9d2b00f8519958e7c4789 100644 (file)
@@ -311,8 +311,12 @@ static int unload_module(void)
 
 static int reload(void)
 {
+       int res;
+       ast_mutex_lock(&pgsql_lock);
        my_unload_module();
-       return my_load_module();
+       res = my_load_module();
+       ast_mutex_lock(&pgsql_lock);
+       return res;
 }
 
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "PostgreSQL CDR Backend",