[Freeswitch-svn] [commit] r5787 - in freeswitch/trunk: build src/mod/xml_int/mod_xml_cdr

Freeswitch SVN anthm at freeswitch.org
Wed Oct 3 14:15:20 EDT 2007


Author: anthm
Date: Wed Oct  3 14:15:20 2007
New Revision: 5787

Modified:
   freeswitch/trunk/build/modules.conf.in
   freeswitch/trunk/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c

Log:
fix bug in xml cdr

Modified: freeswitch/trunk/build/modules.conf.in
==============================================================================
--- freeswitch/trunk/build/modules.conf.in	(original)
+++ freeswitch/trunk/build/modules.conf.in	Wed Oct  3 14:15:20 2007
@@ -4,7 +4,6 @@
 applications/mod_conference
 applications/mod_dptools
 applications/mod_enum
-applications/mod_fifo
 #applications/mod_ivrtest
 #applications/mod_soundtouch
 #applications/mod_rss
@@ -24,12 +23,12 @@
 #dialplans/mod_dialplan_directory
 dialplans/mod_dialplan_xml
 #directories/mod_ldap
-endpoints/mod_dingaling
-endpoints/mod_iax
-endpoints/mod_portaudio
+#endpoints/mod_dingaling
+#endpoints/mod_iax
+#endpoints/mod_portaudio
 endpoints/mod_sofia
 #endpoints/mod_wanpipe
-endpoints/mod_woomera
+#endpoints/mod_woomera
 #../../libs/openzap/mod_openzap
 #event_handlers/mod_cdr
 #event_handlers/mod_event_multicast
@@ -42,15 +41,15 @@
 formats/mod_sndfile
 #formats/mod_shout
 #formats/mod_local_stream
-#languages/mod_java
 #languages/mod_perl
 #languages/mod_python
-#languages/mod_spidermonkey
-#languages/mod_spidermonkey_teletone
-#languages/mod_spidermonkey_core_db
-#languages/mod_spidermonkey_odbc
+languages/mod_spidermonkey
+languages/mod_spidermonkey_teletone
+languages/mod_spidermonkey_core_db
+languages/mod_spidermonkey_odbc
 #languages/mod_spidermonkey_etpan
-#xml_int/mod_xml_rpc
+xml_int/mod_xml_rpc
 #xml_int/mod_xml_curl
-#xml_int/mod_xml_cdr
+xml_int/mod_xml_cdr
 say/mod_say_en
+

Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c
==============================================================================
--- freeswitch/trunk/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c	(original)
+++ freeswitch/trunk/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c	Wed Oct  3 14:15:20 2007
@@ -65,17 +65,16 @@
 	char *logdir = NULL;
 	char *xml_text_escaped = NULL;
 	int fd = -1;
-	uint32_t curTry;
+	uint32_t cur_try;
 	long httpRes;
 	CURL *curl_handle = NULL;
 	switch_channel_t *channel = switch_core_session_get_channel(session);
-	uint32_t i;
 	switch_status_t status = SWITCH_STATUS_FALSE;
 
 	if (switch_ivr_generate_xml_cdr(session, &cdr) == SWITCH_STATUS_SUCCESS) {
 
 		/* build the XML */
-		if(!(xml_text = switch_xml_toxml(cdr))) {
+		if (!(xml_text = switch_xml_toxml(cdr))) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
 			goto error;
 		}
@@ -87,7 +86,7 @@
 			logdir = globals.log_dir;
 		}
 
-		if(!switch_strlen_zero(logdir)) {
+		if (!switch_strlen_zero(logdir)) {
 			if ((path = switch_mprintf("%s/%s.cdr.xml", logdir, switch_core_session_get_uuid(session)))) {
 				if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) > -1) {
 					int wrote;
@@ -139,26 +138,21 @@
 			curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1); // 302 recursion level
 			*/
 
-			for (curTry=0;curTry<=globals.retries;curTry++) {
+			for (cur_try = 0; cur_try < globals.retries; cur_try++) {
+				if (cur_try > 0) {
+					sleep(globals.delay);
+				}
 				curl_easy_perform(curl_handle);
-				curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE,&httpRes);
-				if (httpRes==200) {
+				curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &httpRes);
+				if (httpRes == 200) {
 					goto success;
 				} else {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Got error [%ld] posting to web server [%s]\n",httpRes, globals.url);
 				}
-
-				/* make sure we dont sleep on the last try */
-				for (i=0;i<globals.delay && (curTry != (globals.retries));i++) {
-					switch_sleep(1000);
-					if(globals.shutdown) {
-						/* we are shutting down so dont try to webpost any more */
-						i=globals.delay;
-						curTry=globals.retries;
-					}
-				}		
+				
 			}
 			curl_easy_cleanup(curl_handle);
+			curl_handle = NULL;
 
 			/* if we are here the web post failed for some reason */
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to post to web server, writing to file\n");
@@ -274,13 +268,13 @@
 			}
 		}
 	}
-	if(globals.retries < 0) {
+	if (globals.retries < 0) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "retries is negative, setting to 0\n");
 		globals.retries = 0;
 	}
 
 
-	if(globals.retries && globals.delay<=0) {
+	if (globals.retries && globals.delay<=0) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "retries set but delay 0 setting to 5000ms\n");
 		globals.delay = 5000;
 	}



More information about the Freeswitch-svn mailing list