[asterisk-addons-commits] juggie: branch juggie/asterisk-addons-NoLossCDR r454 - /team/juggie/asterisk-...

SVN commits to the Asterisk addons project asterisk-addons-commits at lists.digium.com
Fri Sep 28 19:12:31 CDT 2007


Author: juggie
Date: Fri Sep 28 19:12:30 2007
New Revision: 454

URL: http://svn.digium.com/view/asterisk-addons?view=rev&rev=454
Log:
port cdr_mysql to cdr noloss model

Modified:
    team/juggie/asterisk-addons-NoLossCDR/cdr_addon_mysql.c

Modified: team/juggie/asterisk-addons-NoLossCDR/cdr_addon_mysql.c
URL: http://svn.digium.com/view/asterisk-addons/team/juggie/asterisk-addons-NoLossCDR/cdr_addon_mysql.c?view=diff&rev=454&r1=453&r2=454
==============================================================================
--- team/juggie/asterisk-addons-NoLossCDR/cdr_addon_mysql.c (original)
+++ team/juggie/asterisk-addons-NoLossCDR/cdr_addon_mysql.c Fri Sep 28 19:12:30 2007
@@ -131,13 +131,14 @@
 	handle_cdr_mysql_status, "Show connection status of cdr_mysql",
 	cdr_mysql_status_help, NULL };
 
-static int mysql_log(struct ast_cdr *cdr)
+static int mysql_log(struct ast_cdr *cdr, void * data)
 {
 	struct ast_tm tm;
 	char *userfielddata = NULL;
 	char sqlcmd[2048], timestr[128];
 	char *clid=NULL, *dcontext=NULL, *channel=NULL, *dstchannel=NULL, *lastapp=NULL, *lastdata=NULL, *tmp;
 	int retries = 5;
+	int res;
 	char *uniqueid = NULL;
 
 	ast_mutex_lock(&mysql_lock);
@@ -217,7 +218,7 @@
 	if ((!clid) || (!dcontext) || (!channel) || (!dstchannel) || (!lastapp) || (!lastdata) || (loguniqueid && !uniqueid)) {
 		ast_log(LOG_ERROR, "cdr_mysql:  Out of memory error (insert fails)\n");
 		ast_mutex_unlock(&mysql_lock);
-		return -1;
+		return AST_CDR_POST_FAILED;
 	}
 
 	ast_debug(1, "cdr_mysql: inserting a CDR record.\n");
@@ -237,7 +238,7 @@
 	ast_debug(1, "cdr_mysql: SQL command as follows: %s\n", sqlcmd);
 	
 	if (connected) {
-		if (mysql_real_query(&mysql, sqlcmd, strlen(sqlcmd))) {
+		if (res = mysql_real_query(&mysql, sqlcmd, strlen(sqlcmd))) {
 			ast_log(LOG_ERROR, "mysql_cdr: Failed to insert into database: (%d) %s", mysql_errno(&mysql), mysql_error(&mysql));
 			mysql_close(&mysql);
 			connected = 0;
@@ -270,7 +271,7 @@
 	AST_LIST_UNLOCK(&unload_strings);
 	
 	dbport = 0;
-	ast_cdr_unregister(name);
+	ast_cdr_unregister(name, NULL);
 	
 	return 0;
 }
@@ -435,7 +436,7 @@
 		connect_time = time(NULL);
 	}
 
-	res = ast_cdr_register(name, desc, mysql_log);
+	res = ast_cdr_register(name, NULL, desc, mysql_log, NULL, NULL);
 	if (res) {
 		ast_log(LOG_ERROR, "Unable to register MySQL CDR handling\n");
 	} else {




More information about the asterisk-addons-commits mailing list