]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
attempt a restart on a connection error (bug #3628)
authorRussell Bryant <russell@russellbryant.com>
Sat, 26 Feb 2005 18:57:14 +0000 (18:57 +0000)
committerRussell Bryant <russell@russellbryant.com>
Sat, 26 Feb 2005 18:57:14 +0000 (18:57 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/v1-0@5090 65c4cc65-6c06-0410-ace0-fbb531ad65f3

CHANGES
cdr/cdr_pgsql.c

diff --git a/CHANGES b/CHANGES
index 3f30d298ff41972e13c089d9322a368e66f5b3f9..695fcd3875234d85bb49c9336def467a5b74c19d 100755 (executable)
--- a/CHANGES
+++ b/CHANGES
@@ -43,6 +43,8 @@ Asterisk 1.0.6
     -- If the server you were using was going down, it had the potential to bring your asterisk
        server down with it. Extra stuff has been added so as to bring in more error/connection
        checking.
+ -- cdr_pgsql:
+    -- This will now attempt to reconnect after a connection problem.
  -- internals
     -- Behavior was changed for 'show codec <number>' to make it more intuitive. (kshumard)
     -- DNS failures and asterisk do not get along too well, this is not totally the case anymore.
index f6af7ff5846d71a7d3dea392872aed5c8de56e06..90d386fdcf22c12ef54bb0d828a7458e460f8ad2 100755 (executable)
@@ -127,6 +127,19 @@ static int pgsql_log(struct ast_cdr *cdr)
                         pgerror = PQresultErrorMessage(result);
                        ast_log(LOG_ERROR,"cdr_pgsql: Failed to insert call detail record into database!\n");
                         ast_log(LOG_ERROR,"cdr_pgsql: Reason: %s\n", pgerror);
+                       ast_log(LOG_ERROR,"cdr_pgsql: Connection may have been lost... attempting to reconnect.\n");
+                       PQreset(conn);
+                       if (PQstatus(conn) == CONNECTION_OK) {
+                               ast_log(LOG_ERROR, "cdr_pgsql: Connection reestablished.\n");
+                               connected = 1;
+                               result = PQexec(conn, sqlcmd);
+                               if ( PQresultStatus(result) != PGRES_COMMAND_OK)
+                               {
+                                       pgerror = PQresultErrorMessage(result);
+                                       ast_log(LOG_ERROR,"cdr_pgsql: HARD ERROR!  Attempted reconnection failed.  DROPPING CALL RECORD!\n");
+                                       ast_log(LOG_ERROR,"cdr_pgsql: Reason: %s\n", pgerror);
+                               }
+                       }
                        ast_mutex_unlock(&pgsql_lock);
                        return -1;
                }
@@ -287,7 +300,7 @@ static int process_my_load_module(struct ast_config *cfg)
                connected = 1;
        } else {
                 pgerror = PQerrorMessage(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: Unable to connect to database server %s.  CALLS WILL NOT BE LOGGED!!\n", pghostname);
                 ast_log(LOG_ERROR, "cdr_pgsql: Reason: %s\n", pgerror);
                connected = 0;
        }