]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
tolerate MySuckWELL ODBC limitation FSCORE-487
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 13 Nov 2009 23:15:15 +0000 (23:15 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 13 Nov 2009 23:15:15 +0000 (23:15 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15465 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_utils.h
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_glue.c

index 18bfbaf418cf35133e35950dcd386566263f4660..23dc3868d3e2b6b081b8364c0629847d16eab37a 100644 (file)
@@ -75,7 +75,7 @@ SWITCH_DECLARE(int) switch_isxdigit(int c);
   \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)
index cea5db904fc80fa1d152861c3a0fb943517ef971..6121db0b0b4dbfff32289327de9c8ffcd946879f 100644 (file)
@@ -915,9 +915,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread
 
                                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,9 +941,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread
 
                                //printf("TRANS:\n%s\n", sqlbuf);
                                sofia_glue_actually_execute_sql(profile, sqlbuf, NULL);
-
-                               sprintf(sqlbuf, "commit;\n");
-                               sofia_glue_actually_execute_sql(profile, sqlbuf, NULL);
+                               sofia_glue_actually_execute_sql(profile, "commit;\n", NULL);
 
 
                                switch_mutex_unlock(profile->ireg_mutex);
index 006eba57ac6879140c353fad583da3ac85f0e6c5..a27c4117cdc528baeb8a1dc0eb12f93318b4c94d 100644 (file)
@@ -3793,7 +3793,22 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
                        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 '%%'",