[asterisk-commits] file: branch 1.4 r77540 - /branches/1.4/cdr/cdr_pgsql.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jul 27 12:04:08 CDT 2007


Author: file
Date: Fri Jul 27 12:04:08 2007
New Revision: 77540

URL: http://svn.digium.com/view/asterisk?view=rev&rev=77540
Log:
(closes issue #10310)
Reported by: prashant_jois
Patches:
      cdr_pgsql.patch uploaded by prashant (license 114)
Finish the Postgresql connection after the log messages are printed so we don't access invalid memory.

Modified:
    branches/1.4/cdr/cdr_pgsql.c

Modified: branches/1.4/cdr/cdr_pgsql.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/cdr/cdr_pgsql.c?view=diff&rev=77540&r1=77539&r2=77540
==============================================================================
--- branches/1.4/cdr/cdr_pgsql.c (original)
+++ branches/1.4/cdr/cdr_pgsql.c Fri Jul 27 12:04:08 2007
@@ -86,9 +86,9 @@
 			connected = 1;
 		} else {
 			pgerror = PQerrorMessage(conn);
-			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);
+			PQfinish(conn);
 			conn = NULL;
 		}
 	}
@@ -147,9 +147,9 @@
 				connected = 1;
 			} else {
 				pgerror = PQerrorMessage(conn);
-				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);
+				PQfinish(conn);
 				conn = NULL;
 				connected = 0;
 				ast_mutex_unlock(&pgsql_lock);




More information about the asterisk-commits mailing list