[asterisk-addons-commits] tilghman: trunk r476 - in /trunk: ./ cdr_addon_mysql.c

SVN commits to the Asterisk addons project asterisk-addons-commits at lists.digium.com
Fri Oct 26 09:48:22 CDT 2007


Author: tilghman
Date: Fri Oct 26 09:48:21 2007
New Revision: 476

URL: http://svn.digium.com/view/asterisk-addons?view=rev&rev=476
Log:
Merged revisions 475 via svnmerge from 
https://origsvn.digium.com/svn/asterisk-addons/branches/1.4

........
r475 | tilghman | 2007-10-26 09:40:32 -0500 (Fri, 26 Oct 2007) | 5 lines

Auto reconnect database on connection failure (fixes missing CDRs)
Reported by ys.
Fixed by ys.
Closes issue #11092

........

Modified:
    trunk/   (props changed)
    trunk/cdr_addon_mysql.c

Propchange: trunk/
------------------------------------------------------------------------------
--- branch-1.4-merged (original)
+++ branch-1.4-merged Fri Oct 26 09:48:21 2007
@@ -1,1 +1,1 @@
-/branches/1.4:1-299,308,310,317,319,329,342,348,358,380,382,387,389,398,405,410,414,417,423,428,466,472
+/branches/1.4:1-299,308,310,317,319,329,342,348,358,380,382,387,389,398,405,410,414,417,423,428,466,472,475

Modified: trunk/cdr_addon_mysql.c
URL: http://svn.digium.com/view/asterisk-addons/trunk/cdr_addon_mysql.c?view=diff&rev=476&r1=475&r2=476
==============================================================================
--- trunk/cdr_addon_mysql.c (original)
+++ trunk/cdr_addon_mysql.c Fri Oct 26 09:48:21 2007
@@ -148,6 +148,9 @@
 	char *clid=NULL, *dcontext=NULL, *channel=NULL, *dstchannel=NULL, *lastapp=NULL, *lastdata=NULL, *src=NULL, *dst=NULL, *accountcode=NULL, *tmp;
 	int retries = 5;
 	char *uniqueid = NULL;
+#if MYSQL_VERSION_ID >= 50013
+	my_bool my_bool_true = 1;
+#endif
 
 	ast_mutex_lock(&mysql_lock);
 
@@ -161,9 +164,15 @@
 		/* Attempt to connect */
 		mysql_init(&mysql);
 		/* Add option to quickly timeout the connection */
-		if (timeout && mysql_options(&mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *)&timeout)!=0) {
+		if (timeout && mysql_options(&mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *)&timeout) != 0) {
 			ast_log(LOG_ERROR, "cdr_mysql: mysql_options returned (%d) %s\n", mysql_errno(&mysql), mysql_error(&mysql));
 		}
+#if MYSQL_VERSION_ID >= 50013
+		/* Add option for automatic reconnection */
+		if (mysql_options(&mysql, MYSQL_OPT_RECONNECT, &my_bool_true) != 0) {
+			ast_log(LOG_ERROR, "cdr_mysql: mysql_options returned (%d) %s\n", mysql_errno(&mysql), mysql_error(&mysql));
+		}
+#endif
 		tmp = dbsock ? dbsock->str : NULL;
 		if (ssl_ca || ssl_cert || ssl_key) {
 			mysql_ssl_set (&mysql, ssl_key->str, ssl_cert->str, ssl_ca->str, NULL, NULL);
@@ -346,6 +355,9 @@
 	struct ast_variable *var;
 	struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
 	char *temp;
+#if MYSQL_VERSION_ID >= 50013
+	my_bool my_bool_true = 1;
+#endif
 
 	cfg = ast_config_load(config, config_flags);
 	if (!cfg) {
@@ -432,9 +444,17 @@
 
 	mysql_init(&mysql);
 
-	if (timeout && mysql_options(&mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *)&timeout)!=0) {
+	if (timeout && mysql_options(&mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *)&timeout) != 0) {
 		ast_log(LOG_ERROR, "cdr_mysql: mysql_options returned (%d) %s\n", mysql_errno(&mysql), mysql_error(&mysql));
 	}
+
+#if MYSQL_VERSION_ID >= 50013
+	/* Add option for automatic reconnection */
+	if (mysql_options(&mysql, MYSQL_OPT_RECONNECT, &my_bool_true) != 0) {
+		ast_log(LOG_ERROR, "cdr_mysql: mysql_options returned (%d) %s\n", mysql_errno(&mysql), mysql_error(&mysql));
+	}
+#endif
+
 	if (ssl_ca || ssl_cert || ssl_key) {
 		mysql_ssl_set (&mysql, ssl_key->str, ssl_cert->str, ssl_ca->str, NULL, NULL);
 	}




More information about the asterisk-addons-commits mailing list