[asterisk-addons-commits] tilghman: trunk r554 - /trunk/cdr/cdr_addon_mysql.c

SVN commits to the Asterisk addons project asterisk-addons-commits at lists.digium.com
Tue Mar 18 12:43:14 CDT 2008


Author: tilghman
Date: Tue Mar 18 12:43:14 2008
New Revision: 554

URL: http://svn.digium.com/view/asterisk-addons?view=rev&rev=554
Log:
When the dbsock is blank, we want to use NULL, not the empty string (which causes MySQL to use the default)
Reported via -dev mailing list, fixed by me.

Modified:
    trunk/cdr/cdr_addon_mysql.c

Modified: trunk/cdr/cdr_addon_mysql.c
URL: http://svn.digium.com/view/asterisk-addons/trunk/cdr/cdr_addon_mysql.c?view=diff&rev=554&r1=553&r2=554
==============================================================================
--- trunk/cdr/cdr_addon_mysql.c (original)
+++ trunk/cdr/cdr_addon_mysql.c Tue Mar 18 12:43:14 2008
@@ -112,7 +112,7 @@
 		if (dbport)
 			snprintf(status, 255, "Connected to %s@%s, port %d", dbname->str, hostname->str, dbport);
 		else if (dbsock)
-			snprintf(status, 255, "Connected to %s on socket file %s", dbname->str, dbsock->str);
+			snprintf(status, 255, "Connected to %s on socket file %s", dbname->str, !ast_strlen_zero(dbsock->str) ? dbsock->str : "default");
 		else
 			snprintf(status, 255, "Connected to %s@%s", dbname->str, hostname->str);
 
@@ -180,7 +180,7 @@
 		if (ssl_ca || ssl_cert || ssl_key) {
 			mysql_ssl_set(&mysql, ssl_key ? ssl_key->str : NULL, ssl_cert ? ssl_cert->str : NULL, ssl_ca ? ssl_ca->str : NULL, NULL, NULL);
 		}
-		if (mysql_real_connect(&mysql, hostname->str, dbuser->str, password->str, dbname->str, dbport, dbsock ? dbsock->str : NULL, ssl_ca ? CLIENT_SSL : 0)) {
+		if (mysql_real_connect(&mysql, hostname->str, dbuser->str, password->str, dbname->str, dbport, dbsock && !ast_strlen_zero(dbsock->str) ? dbsock->str : NULL, ssl_ca ? CLIENT_SSL : 0)) {
 			connected = 1;
 			connect_time = time(NULL);
 			records = 0;
@@ -494,7 +494,7 @@
 	if (ssl_ca || ssl_cert || ssl_key) {
 		mysql_ssl_set (&mysql, ssl_key->str, ssl_cert->str, ssl_ca->str, NULL, NULL);
 	}
-	temp = dbsock ? dbsock->str : NULL;
+	temp = dbsock && !ast_strlen_zero(dbsock->str) ? dbsock->str : NULL;
 	if (!mysql_real_connect(&mysql, hostname->str, dbuser->str, password->str, dbname->str, dbport, temp, ssl_ca ? CLIENT_SSL : 0)) {
 		ast_log(LOG_ERROR, "Failed to connect to mysql database %s on %s.\n", dbname->str, hostname->str);
 		connected = 0;




More information about the asterisk-addons-commits mailing list