[asterisk-commits] murf: branch murf/selway r143901 - /team/murf/selway/cdr/cdr_odbc.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Sep 22 16:31:13 CDT 2008


Author: murf
Date: Mon Sep 22 16:31:13 2008
New Revision: 143901

URL: http://svn.digium.com/view/asterisk?view=rev&rev=143901
Log:
extend the life of timestr, and pass down its size

Modified:
    team/murf/selway/cdr/cdr_odbc.c

Modified: team/murf/selway/cdr/cdr_odbc.c
URL: http://svn.digium.com/view/asterisk/team/murf/selway/cdr/cdr_odbc.c?view=diff&rev=143901&r1=143900&r2=143901
==============================================================================
--- team/murf/selway/cdr/cdr_odbc.c (original)
+++ team/murf/selway/cdr/cdr_odbc.c Mon Sep 22 16:31:13 2008
@@ -90,10 +90,10 @@
 	connected = 0;
 }
 
-static void build_query(struct ast_cdr *cdr)
+static void build_query(struct ast_cdr *cdr, char *timestr, int timesize)
 {
 	int ODBC_res;
-	char sqlcmd[2048] = "", timestr[128];
+	char sqlcmd[2048] = "";
 	int res = 0;
 	struct tm tm;
 
@@ -102,7 +102,7 @@
 	else
 		ast_localtime(&cdr->start.tv_sec, &tm, NULL);
 
-	strftime(timestr, sizeof(timestr), DATE_FORMAT, &tm);
+	strftime(timestr, timesize, DATE_FORMAT, &tm);
 	memset(sqlcmd,0,2048);
 	if (loguniqueid) {
 		snprintf(sqlcmd,sizeof(sqlcmd),"INSERT INTO %s "
@@ -150,7 +150,7 @@
 		return;
 	}
 
-	SQLBindParameter(ODBC_stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(timestr), 0, &timestr, 0, NULL);
+	SQLBindParameter(ODBC_stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, timesize, 0, timestr, 0, NULL);
 	SQLBindParameter(ODBC_stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->clid), 0, cdr->clid, 0, NULL);
 	SQLBindParameter(ODBC_stmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->src), 0, cdr->src, 0, NULL);
 	SQLBindParameter(ODBC_stmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->dst), 0, cdr->dst, 0, NULL);
@@ -177,9 +177,10 @@
 static int odbc_log(struct ast_cdr *cdr)
 {
 	int res = 0;
+	char timestr[150];
 
 	ast_mutex_lock(&odbc_lock);
-	build_query(cdr);
+	build_query(cdr, timestr, sizeof(timestr));
 
 	if (connected) {
 		res = odbc_do_query();
@@ -198,7 +199,7 @@
 				if (option_verbose > 10)
 					ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: Trying Query again!\n");
 				SQLFreeHandle(SQL_HANDLE_STMT, ODBC_stmt);
-				build_query(cdr); /* what a waste. If we have to reconnect, we have to build a new query */
+				build_query(cdr, timestr, sizeof(timestr)); /* what a waste. If we have to reconnect, we have to build a new query */
 				res = odbc_do_query();
 				if (res < 0) {
 					if (option_verbose > 10)




More information about the asterisk-commits mailing list