Revision
15465
Author
anthm
Date
2009-11-13 17:15:15 -0600 (Fri, 13 Nov 2009)

Log Message

tolerate MySuckWELL ODBC limitation FSCORE-487

Modified Paths

Diff

Modified: freeswitch/trunk/src/include/switch_utils.h (15464 => 15465)


--- freeswitch/trunk/src/include/switch_utils.h	2009-11-13 22:11:41 UTC (rev 15464)
+++ freeswitch/trunk/src/include/switch_utils.h	2009-11-13 23:15:15 UTC (rev 15465)
@@ -75,7 +75,7 @@
   \return true value if the string is NULL or zero length
 */
 static inline int zstr(const char *s) {
-	return (!s || *(s) == '\0');
+	return !s || *s == '\0';
 }
 
 #define switch_strlen_zero(x) zstr(x)

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (15464 => 15465)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	2009-11-13 22:11:41 UTC (rev 15464)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	2009-11-13 23:15:15 UTC (rev 15465)
@@ -915,9 +915,7 @@
 
 				switch_mutex_lock(profile->ireg_mutex);
 			
-				
-				sprintf(sqlbuf, "begin;\n");
-				sofia_glue_actually_execute_sql(profile, sqlbuf, NULL);
+				sofia_glue_actually_execute_sql(profile, "begin;\n", NULL);
 
 				while (switch_queue_trypop(profile->sql_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
 					char *sql = (char *) pop;
@@ -943,11 +941,9 @@
 
 				//printf("TRANS:\n%s\n", sqlbuf);
 				sofia_glue_actually_execute_sql(profile, sqlbuf, NULL);
+				sofia_glue_actually_execute_sql(profile, "commit;\n", NULL);
 
-				sprintf(sqlbuf, "commit;\n");
-				sofia_glue_actually_execute_sql(profile, sqlbuf, NULL);
 
-
 				switch_mutex_unlock(profile->ireg_mutex);
 				loop_count = 0;
 			}

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (15464 => 15465)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	2009-11-13 22:11:41 UTC (rev 15464)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	2009-11-13 23:15:15 UTC (rev 15465)
@@ -3793,9 +3793,24 @@
 			switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_registrations", NULL);
 			switch_odbc_handle_exec(odbc_dbh, reg_sql, NULL);
 		}
-		free(test_sql);
 
 
+
+		if (sofia_test_pflag(profile, PFLAG_SQL_IN_TRANS)) {
+			char *test2 = switch_mprintf("%s;%s", test_sql, test_sql);
+
+			if (switch_odbc_handle_exec(odbc_dbh, test2, NULL) != SWITCH_ODBC_SUCCESS) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "GREAT SCOTT!!! Cannot execute batched statements!\n"
+								  "If you are using mysql, make sure you are using MYODBC 3.51.18 or higher and enable FLAG_MULTI_STATEMENTS\n");
+				sofia_clear_pflag(profile, PFLAG_SQL_IN_TRANS);
+				
+			}
+			free(test2);
+		}
+
+		free(test_sql);		
+
+
 		test_sql = switch_mprintf("delete from sip_subscriptions where hostname='%q' and network_ip like '%%' and network_port like '%%'", 
 								  mod_sofia_globals.hostname);