[svn-commits] seanbright: branch 1.6.1 r137782 - in /branches/1.6.1: ./ cdr/cdr_tds.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Aug 14 10:06:49 CDT 2008


Author: seanbright
Date: Thu Aug 14 10:06:49 2008
New Revision: 137782

URL: http://svn.digium.com/view/asterisk?view=rev&rev=137782
Log:
Merged revisions 137780 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
r137780 | seanbright | 2008-08-14 11:03:03 -0400 (Thu, 14 Aug 2008) | 8 lines

If we detect that we are no longer connected, try to reconnect a few times
before giving up.  This relies on the timeout settings in the freetds.conf
file and, unfortunately, on a recent version of FreeTDS (0.82 or newer).

I either need to change the current execs to be non-blocking (which I do
not want to do) or we have to force people to run with the latest and
greatest of FreeTDS.  I'm on the fence...

........

Modified:
    branches/1.6.1/   (props changed)
    branches/1.6.1/cdr/cdr_tds.c

Propchange: branches/1.6.1/
------------------------------------------------------------------------------
--- trunk-merged (original)
+++ trunk-merged Thu Aug 14 10:06:49 2008
@@ -1,1 +1,1 @@
-/trunk:1-137647,137680
+/trunk:1-137647,137680,137780

Modified: branches/1.6.1/cdr/cdr_tds.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.1/cdr/cdr_tds.c?view=diff&rev=137782&r1=137781&r2=137782
==============================================================================
--- branches/1.6.1/cdr/cdr_tds.c (original)
+++ branches/1.6.1/cdr/cdr_tds.c Thu Aug 14 10:06:49 2008
@@ -114,6 +114,7 @@
 	char *accountcode, *src, *dst, *dcontext, *clid, *channel, *dstchannel, *lastapp, *lastdata, *uniqueid, *userfield = NULL;
 	RETCODE erc;
 	int res = -1;
+	int attempt = 1;
 
 	accountcode = anti_injection(cdr->accountcode, 20);
 	src         = anti_injection(cdr->src, 80);
@@ -136,10 +137,15 @@
 		userfield = anti_injection(cdr->userfield, AST_MAX_USER_FIELD);
 	}
 
+retry:
 	/* Ensure that we are connected */
 	if (!settings->connected) {
+		ast_log(LOG_NOTICE, "Attempting to reconnect to %s (Attempt %d)\n", settings->hostname, attempt);
 		if (mssql_connect()) {
 			/* Connect failed */
+			if (attempt++ < 3) {
+				goto retry;
+			}
 			goto done;
 		}
 	}
@@ -186,13 +192,25 @@
 	}
 
 	if (erc == FAIL) {
-		ast_log(LOG_ERROR, "Failed to build INSERT statement, no CDR was logged.\n");
-		goto done;
+		if (attempt++ < 3) {
+			ast_log(LOG_NOTICE, "Failed to build INSERT statement, retrying...\n");
+			mssql_disconnect();
+			goto retry;
+		} else {
+			ast_log(LOG_ERROR, "Failed to build INSERT statement, no CDR was logged.\n");
+			goto done;
+		}
 	}
 
 	if (dbsqlexec(settings->dbproc) == FAIL) {
-		ast_log(LOG_ERROR, "Failed to execute INSERT statement, no CDR was logged.\n");
-		goto done;
+		if (attempt++ < 3) {
+			ast_log(LOG_NOTICE, "Failed to execute INSERT statement, retrying...\n");
+			mssql_disconnect();
+			goto retry;
+		} else {
+			ast_log(LOG_ERROR, "Failed to execute INSERT statement, no CDR was logged.\n");
+			goto done;
+		}
 	}
 
 	/* Consume any results we might get back (this is more of a sanity check than




More information about the svn-commits mailing list