From: Jason Parker Date: Wed, 20 Jun 2007 22:31:35 +0000 (+0000) Subject: Fix a race condition in cdr_pgsql that can occur when reloading the module. X-Git-Tag: 1.4.6~72 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6fd76e7bc368be5d1cdc2a8821fefd12c9a44ebe;p=thirdparty%2Fasterisk.git Fix a race condition in cdr_pgsql that can occur when reloading the module. 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 --- diff --git a/cdr/cdr_pgsql.c b/cdr/cdr_pgsql.c index 7788cf0379..14f343abd7 100644 --- a/cdr/cdr_pgsql.c +++ b/cdr/cdr_pgsql.c @@ -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",