aboutsummaryrefslogtreecommitdiffstats
path: root/cdr/cdr_pgsql.c
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2007-07-26 18:31:28 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2007-07-26 18:31:28 +0000
commita68fc90ea676d7bafb7916fa43cce923b7fdec5f (patch)
tree6a86ed891f4cdb7d958b5fa7d240893c58a45b07 /cdr/cdr_pgsql.c
parent4f3c4dc7f238b64a21172be86266311c9c645c77 (diff)
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) ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@77319 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'cdr/cdr_pgsql.c')
-rw-r--r--cdr/cdr_pgsql.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/cdr/cdr_pgsql.c b/cdr/cdr_pgsql.c
index 12d9778c2..82dce65e7 100644
--- a/cdr/cdr_pgsql.c
+++ b/cdr/cdr_pgsql.c
@@ -90,6 +90,7 @@ static int pgsql_log(struct ast_cdr *cdr)
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 @@ static int pgsql_log(struct ast_cdr *cdr)
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 pgsql_log(struct ast_cdr *cdr)
static int my_unload_module(void)
{
- if (conn)
- PQfinish(conn);
+ PQfinish(conn);
if (pghostname)
ast_free(pghostname);
if (pgdbname)