diff options
Diffstat (limited to 'cdr')
-rw-r--r-- | cdr/cdr_pgsql.c | 5 |
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) |