Author: mmichelson
Date: Thu Jul 26 13:31:28 2007
New Revision: 77319
URL: http://svn.digium.com/view/asterisk?view=rev&rev=77319
Log:
Merged revisions 77318 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r77318 | mmichelson | 2007-07-26 13:30:29 -0500 (Thu, 26 Jul 2007) | 8 lines
Two consecutive calls to PQfinish could occur, meaning free gets called on the
same variable twice.
This patch sets the connection to NULL after calls to PQfinish so that the
problem does not occur.
Also in this patch, prashant_jois informed me that it is safe to pass a null
pointer to PQfinish, so
I have removed the check for conn's existence from my_unload_module.
(closes issue 10295, reported by junky, patched by me with input from
prashant_jois)
........
Modified:
trunk/ (props changed)
trunk/cdr/cdr_pgsql.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.
Modified: trunk/cdr/cdr_pgsql.c
URL:
http://svn.digium.com/view/asterisk/trunk/cdr/cdr_pgsql.c?view=diff&rev=77319&r1=77318&r2=77319
==============================================================================
--- trunk/cdr/cdr_pgsql.c (original)
+++ trunk/cdr/cdr_pgsql.c Thu Jul 26 13:31:28 2007
@@ -90,6 +90,7 @@
PQfinish(conn);
ast_log(LOG_ERROR, "cdr_pgsql: Unable to connect to
database server %s. Calls will not be logged!\n", pghostname);
ast_log(LOG_ERROR, "cdr_pgsql: Reason: %s\n", pgerror);
+ conn = NULL;
}
}
@@ -148,6 +149,7 @@
PQfinish(conn);
ast_log(LOG_ERROR, "cdr_pgsql: Unable to
reconnect to database server %s. Calls will not be logged!\n", pghostname);
ast_log(LOG_ERROR, "cdr_pgsql: Reason: %s\n",
pgerror);
+ conn = NULL;
connected = 0;
ast_mutex_unlock(&pgsql_lock);
return -1;
@@ -183,8 +185,7 @@
static int my_unload_module(void)
{
- if (conn)
- PQfinish(conn);
+ PQfinish(conn);
if (pghostname)
ast_free(pghostname);
if (pgdbname)
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
svn-commits mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/svn-commits