aboutsummaryrefslogtreecommitdiffstats
path: root/cdr/cdr_pgsql.c
diff options
context:
space:
mode:
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 1521adaf0..7c2bc9355 100644
--- a/cdr/cdr_pgsql.c
+++ b/cdr/cdr_pgsql.c
@@ -89,6 +89,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;
}
}
@@ -149,6 +150,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;
@@ -184,8 +186,7 @@ static int pgsql_log(struct ast_cdr *cdr)
static int my_unload_module(void)
{
- if (conn)
- PQfinish(conn);
+ PQfinish(conn);
if (pghostname)
free(pghostname);
if (pgdbname)