<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][15584] </title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=15584">15584</a></dd>
<dt>Author</dt> <dd>anthm</dd>
<dt>Date</dt> <dd>2009-11-20 17:12:07 -0600 (Fri, 20 Nov 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>another crank on the can opener for the big can o worms</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunksrcincludeprivateswitch_core_pvth">freeswitch/trunk/src/include/private/switch_core_pvt.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_coreh">freeswitch/trunk/src/include/switch_core.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_typesh">freeswitch/trunk/src/include/switch_types.h</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_commandsmod_commandsc">freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_corec">freeswitch/trunk/src/switch_core.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_sqldbc">freeswitch/trunk/src/switch_core_sqldb.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_logc">freeswitch/trunk/src/switch_log.c</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunksrcincludeprivateswitch_core_pvth"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/private/switch_core_pvt.h (15583 => 15584)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/private/switch_core_pvt.h        2009-11-20 23:09:53 UTC (rev 15583)
+++ freeswitch/trunk/src/include/private/switch_core_pvt.h        2009-11-20 23:12:07 UTC (rev 15584)
</span><span class="lines">@@ -210,6 +210,7 @@
</span><span class="cx">         char *odbc_dsn;
</span><span class="cx">         char *odbc_user;
</span><span class="cx">         char *odbc_pass;
</span><ins>+        uint32_t debug_level;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> extern struct switch_runtime runtime;
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_coreh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_core.h (15583 => 15584)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_core.h        2009-11-20 23:09:53 UTC (rev 15583)
+++ freeswitch/trunk/src/include/switch_core.h        2009-11-20 23:12:07 UTC (rev 15584)
</span><span class="lines">@@ -1937,17 +1937,24 @@
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(void) switch_cache_db_release_db_handle(switch_cache_db_handle_t **dbh);
</span><span class="cx"> SWITCH_DECLARE(void) switch_cache_db_destroy_db_handle(switch_cache_db_handle_t **dbh);
</span><del>-SWITCH_DECLARE(switch_status_t) switch_cache_db_get_db_handle(switch_cache_db_handle_t **dbh,
-                                                                                                                                                const char *db_name, const char *odbc_user, const char *odbc_pass);
</del><ins>+SWITCH_DECLARE(switch_status_t) _switch_cache_db_get_db_handle(switch_cache_db_handle_t **dbh,
+                                                                                                                         const char *db_name,
+                                                                                                                         const char *odbc_user,
+                                                                                                                         const char *odbc_pass, const char *file, const char *func, int line);
+#define switch_cache_db_get_db_handle(_a, _b, _c, _d) _switch_cache_db_get_db_handle(_a, _b, _c, _d, __FILE__, __SWITCH_FUNC__, __LINE__)
+
</ins><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql(switch_cache_db_handle_t *dbh, const char *sql, char **err);
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql_callback(switch_cache_db_handle_t *dbh, const char *sql,
</span><span class="cx">                                                                                                                                          switch_core_db_callback_func_t callback, void *pdata, char **err);
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_core_db_handle(switch_cache_db_handle_t **dbh);
</del><ins>+SWITCH_DECLARE(switch_status_t) _switch_core_db_handle(switch_cache_db_handle_t **dbh, const char *file, const char *func, int line);
+#define switch_core_db_handle(_a) _switch_core_db_handle(_a, __FILE__, __SWITCH_FUNC__, __LINE__)
+
</ins><span class="cx"> SWITCH_DECLARE(void) switch_cache_db_test_reactive(switch_cache_db_handle_t *db, const char *test_sql, const char *drop_sql, const char *reactive_sql);
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute(switch_cache_db_handle_t *dbh, const char *sql, uint32_t retries);
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_cache_db_handle_t *dbh, const char *sql, uint32_t retries);
</span><span class="cx"> SWITCH_DECLARE(void) switch_cache_db_detach(void);
</span><ins>+SWITCH_DECLARE(uint32_t) switch_core_debug_level(void);
</ins><span class="cx">
</span><span class="cx"> SWITCH_END_EXTERN_C
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_typesh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_types.h (15583 => 15584)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_types.h        2009-11-20 23:09:53 UTC (rev 15583)
+++ freeswitch/trunk/src/include/switch_types.h        2009-11-20 23:12:07 UTC (rev 15584)
</span><span class="lines">@@ -764,6 +764,16 @@
</span><span class="cx"> </pre>
</span><span class="cx"> */
</span><span class="cx"> typedef enum {
</span><ins>+        SWITCH_LOG_DEBUG10 = 110,
+        SWITCH_LOG_DEBUG9 = 109,
+        SWITCH_LOG_DEBUG8 = 108,
+        SWITCH_LOG_DEBUG7 = 107,
+        SWITCH_LOG_DEBUG6 = 106,
+        SWITCH_LOG_DEBUG5 = 105,
+        SWITCH_LOG_DEBUG4 = 104,
+        SWITCH_LOG_DEBUG3 = 103,
+        SWITCH_LOG_DEBUG2 = 102,
+        SWITCH_LOG_DEBUG1 = 101,
</ins><span class="cx">         SWITCH_LOG_DEBUG = 7,
</span><span class="cx">         SWITCH_LOG_INFO = 6,
</span><span class="cx">         SWITCH_LOG_NOTICE = 5,
</span><span class="lines">@@ -1410,7 +1420,8 @@
</span><span class="cx">         SCSC_SHUTDOWN_ELEGANT,
</span><span class="cx">         SCSC_SHUTDOWN_ASAP,
</span><span class="cx">         SCSC_CANCEL_SHUTDOWN,
</span><del>-        SCSC_SEND_SIGHUP
</del><ins>+        SCSC_SEND_SIGHUP,
+        SCSC_DEBUG_LEVEL
</ins><span class="cx"> } switch_session_ctl_t;
</span><span class="cx">
</span><span class="cx"> typedef enum {
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_commandsmod_commandsc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (15583 => 15584)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c        2009-11-20 23:09:53 UTC (rev 15583)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c        2009-11-20 23:12:07 UTC (rev 15584)
</span><span class="lines">@@ -1250,7 +1250,7 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#define CTL_SYNTAX "[send_sighup|hupall|pause|resume|shutdown [cancel|elegant|asap|restart]|sps|sync_clock|reclaim_mem|max_sessions|min_dtmf_duration [num]|max_dtmf_duration [num]|default_dtmf_duration [num]|loglevel [level]]"
</del><ins>+#define CTL_SYNTAX "[send_sighup|hupall|pause|resume|shutdown [cancel|elegant|asap|restart]|sps|sync_clock|reclaim_mem|max_sessions|min_dtmf_duration [num]|max_dtmf_duration [num]|default_dtmf_duration [num]|loglevel [level]|debug_level [level]]"
</ins><span class="cx"> SWITCH_STANDARD_API(ctl_function)
</span><span class="cx"> {
</span><span class="cx">         int argc;
</span><span class="lines">@@ -1348,6 +1348,16 @@
</span><span class="cx">                                 switch_core_session_ctl(SCSC_LOGLEVEL, &arg);
</span><span class="cx">                                 stream->write_function(stream, "+OK log level: %s [%d]\n", switch_log_level2str(arg), arg);
</span><span class="cx">                         }
</span><ins>+                } else if (!strcasecmp(argv[0], "debug_level")) {
+                        if (argc > 1) {
+                                arg = atoi(argv[1]);
+                        } else {
+                                arg = -1;
+                        }
+
+                        switch_core_session_ctl(SCSC_DEBUG_LEVEL, &arg);
+                        stream->write_function(stream, "+OK DEBUG level: %d\n", arg);
+
</ins><span class="cx">                 } else if (!strcasecmp(argv[0], "last_sps")) {
</span><span class="cx">                         switch_core_session_ctl(SCSC_LAST_SPS, &arg);
</span><span class="cx">                         stream->write_function(stream, "+OK last sessions per second: %d\n", arg);
</span><span class="lines">@@ -3759,6 +3769,8 @@
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, "uuid_media", "media", uuid_media_function, MEDIA_SYNTAX);
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, "fsctl", "control messages", ctl_function, CTL_SYNTAX);
</span><span class="cx">         switch_console_set_complete("add fsctl hupall");
</span><ins>+        switch_console_set_complete("add fsctl loglevel");
+        switch_console_set_complete("add fsctl debug_level");
</ins><span class="cx">         switch_console_set_complete("add fsctl pause");
</span><span class="cx">         switch_console_set_complete("add fsctl resume");
</span><span class="cx">         switch_console_set_complete("add fsctl shutdown");
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_corec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core.c (15583 => 15584)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core.c        2009-11-20 23:09:53 UTC (rev 15583)
+++ freeswitch/trunk/src/switch_core.c        2009-11-20 23:12:07 UTC (rev 15584)
</span><span class="lines">@@ -1463,12 +1463,12 @@
</span><span class="cx"> /*!
</span><span class="cx"> \brief Open the default system database
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(switch_status_t)switch_core_db_handle(switch_cache_db_handle_t **dbh)
</del><ins>+SWITCH_DECLARE(switch_status_t) _switch_core_db_handle(switch_cache_db_handle_t **dbh, const char *file, const char *func, int line)
</ins><span class="cx"> {
</span><span class="cx">         if (runtime.odbc_dsn && runtime.odbc_user && runtime.odbc_pass) {
</span><del>-                return switch_cache_db_get_db_handle(dbh, runtime.odbc_dsn, runtime.odbc_user, runtime.odbc_pass);
</del><ins>+                return _switch_cache_db_get_db_handle(dbh, runtime.odbc_dsn, runtime.odbc_user, runtime.odbc_pass, file, func, line);
</ins><span class="cx">         } else {
</span><del>-                return switch_cache_db_get_db_handle(dbh, SWITCH_CORE_DB, NULL, NULL);
</del><ins>+                return _switch_cache_db_get_db_handle(dbh, SWITCH_CORE_DB, NULL, NULL, file, func, line);
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1576,6 +1576,12 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+SWITCH_DECLARE(uint32_t) switch_core_debug_level(void)
+{
+        return runtime.debug_level;
+}
+
+
</ins><span class="cx"> SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, int32_t *val)
</span><span class="cx"> {
</span><span class="cx">         if (switch_test_flag((&runtime), SCF_SHUTTING_DOWN)) {
</span><span class="lines">@@ -1677,6 +1683,13 @@
</span><span class="cx">                 }
</span><span class="cx">                 *val = runtime.hard_log_level;
</span><span class="cx">                 break;
</span><ins>+        case SCSC_DEBUG_LEVEL:
+                if (*val > -1) {
+                        if (*val > 10) *val = 10;
+                        runtime.debug_level = *val;
+                }
+                *val = runtime.debug_level;
+                break;
</ins><span class="cx">         case SCSC_MAX_SESSIONS:
</span><span class="cx">                 *val = switch_core_session_limit(*val);
</span><span class="cx">                 break;
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_sqldbc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_sqldb.c (15583 => 15584)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_sqldb.c        2009-11-20 23:09:53 UTC (rev 15583)
+++ freeswitch/trunk/src/switch_core_sqldb.c        2009-11-20 23:12:07 UTC (rev 15584)
</span><span class="lines">@@ -164,8 +164,9 @@
</span><span class="cx">         switch_mutex_unlock(dbh_mutex);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t)switch_cache_db_get_db_handle(switch_cache_db_handle_t **dbh,
-                                                                                                                         const char *db_name, const char *odbc_user, const char *odbc_pass)
</del><ins>+SWITCH_DECLARE(switch_status_t)_switch_cache_db_get_db_handle(switch_cache_db_handle_t **dbh,
+                                                                                                                         const char *db_name, const char *odbc_user, const char *odbc_pass,
+                                                                                                                         const char *file, const char *func, int line)
</ins><span class="cx"> {
</span><span class="cx">         switch_thread_id_t self = switch_thread_self();
</span><span class="cx">         char thread_str[CACHE_DB_LEN] = "";
</span><span class="lines">@@ -176,7 +177,10 @@
</span><span class="cx">         snprintf(thread_str, sizeof(thread_str) - 1, "%s_%lu", db_name, (unsigned long)(intptr_t)self);
</span><span class="cx">         
</span><span class="cx">         switch_mutex_lock(dbh_mutex);
</span><del>-        if (!(new_dbh = switch_core_hash_find(dbh_hash, thread_str))) {
</del><ins>+        if ((new_dbh = switch_core_hash_find(dbh_hash, thread_str))) {
+                switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG1,
+                                                 "Reuse Cached DB handle %s [%s]\n", thread_str, new_dbh->db ? "sqlite" : "ODBC");
+        } else {
</ins><span class="cx">                 switch_hash_index_t *hi;
</span><span class="cx">                 const void *var;
</span><span class="cx">                 void *val;
</span><span class="lines">@@ -190,6 +194,8 @@
</span><span class="cx">                                 if (!switch_test_flag(new_dbh, CDF_INUSE) && switch_mutex_trylock(new_dbh->mutex) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_set_flag(new_dbh, CDF_INUSE);
</span><span class="cx">                                         switch_set_string(new_dbh->name, thread_str);
</span><ins>+                                        switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG1,
+                                                                         "Reuse Unused Cached DB handle %s [%s]\n", thread_str, new_dbh->db ? "sqlite" : "ODBC");
</ins><span class="cx">                                         break;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="lines">@@ -217,6 +223,9 @@
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><span class="cx">
</span><ins>+                switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG1,
+                                                 "Create Cached DB handle %s [%s]\n", thread_str, db ? "sqlite" : "ODBC");
+
</ins><span class="cx">                 switch_core_new_memory_pool(&pool);
</span><span class="cx">                 new_dbh = switch_core_alloc(pool, sizeof(*new_dbh));
</span><span class="cx">                 new_dbh->pool = pool;
</span><span class="lines">@@ -242,16 +251,15 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-
-SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql(switch_cache_db_handle_t *dbh, const char *sql, char **err)
</del><ins>+static switch_status_t switch_cache_db_execute_sql_real(switch_cache_db_handle_t *dbh, const char *sql, char **err)
</ins><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">         char *errmsg = NULL;
</span><span class="cx">
</span><span class="cx">         if (err) *err = NULL;
</span><del>-
</del><ins>+        
</ins><span class="cx">         if (switch_odbc_available() && dbh->odbc_dbh) {
</span><del>-                switch_odbc_statement_handle_t stmt;
</del><ins>+                switch_odbc_statement_handle_t stmt = NULL;
</ins><span class="cx">                 if ((status = switch_odbc_handle_exec(dbh->odbc_dbh, sql, &stmt)) != SWITCH_ODBC_SUCCESS) {
</span><span class="cx">                         errmsg = switch_odbc_handle_get_error(dbh->odbc_dbh, stmt);
</span><span class="cx">                 }
</span><span class="lines">@@ -272,9 +280,87 @@
</span><span class="cx">         }
</span><span class="cx">         
</span><span class="cx">         return status;
</span><ins>+}
</ins><span class="cx">
</span><ins>+/**
+ OMFG you cruel bastards. Who chooses 64k as a max buffer len for a sql statement, have you ever heard of transactions?
+ **/
+static switch_status_t switch_cache_db_execute_sql_chunked(switch_cache_db_handle_t *dbh, const char *sql, uint32_t chunk_size, char **err)
+{
+        switch_status_t status = SWITCH_STATUS_FALSE;
+        char *p, *s, *e;
+        int chunk_count;
+        char *dup = NULL;
+        switch_size_t len;
+        
+        switch_assert(chunk_size);
+
+        if (err) *err = NULL;
+
+        len = strlen(sql);
+
+        if (chunk_size > len) {
+                return switch_cache_db_execute_sql_real(dbh, sql, err);
+        }
+
+        if (!(chunk_count = strlen(sql) / chunk_size)) {
+                return SWITCH_STATUS_FALSE;
+        }
+        
+        dup = strdup(sql);
+
+
+        e = end_of_p(dup);
+        s = dup;
+
+        while(s && s < e) {
+                p = s + chunk_size;
+
+                if (p > e) {
+                        p = e;
+                }
+                
+                while (p > s && *p != ';') {
+                        p--;
+                }
+
+                if (p) {
+                        *p = '\0';
+                        while(p < e && (*p == '\n' || *p == ' ')) {
+                                p++;
+                        }
+                }
+                
+                status = switch_cache_db_execute_sql_real(dbh, s, err);
+                if (status != SWITCH_STATUS_SUCCESS || (err && *err)) {
+                        break;
+                }
+
+                s = p + 1;
+        
+        }
+
+        free(dup);
+
+        return status;
+
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+
+SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql(switch_cache_db_handle_t *dbh, const char *sql, char **err)
+{
+        switch_status_t status = SWITCH_STATUS_FALSE;
+
+        if (dbh->db) {
+                status = switch_cache_db_execute_sql_real(dbh, sql, err);
+        } else {
+                status = switch_cache_db_execute_sql_chunked(dbh, (char *)sql, 32000, err);
+        }
+        
+        return status;
+
+}
+
</ins><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute(switch_cache_db_handle_t *dbh, const char *sql, uint32_t retries)
</span><span class="cx"> {
</span><span class="cx">         char *errmsg = NULL;
</span><span class="lines">@@ -313,7 +399,7 @@
</span><span class="cx">         uint8_t forever = 0;
</span><span class="cx">         unsigned begin_retries = 100;
</span><span class="cx">         uint8_t again = 0;
</span><del>-
</del><ins>+        
</ins><span class="cx">         if (!retries) {
</span><span class="cx">                 forever = 1;
</span><span class="cx">                 retries = 1000;
</span><span class="lines">@@ -353,7 +439,10 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         while (retries > 0) {
</span><del>-                switch_cache_db_execute_sql(dbh, sql, &errmsg);
</del><ins>+
+                switch_cache_db_execute_sql(dbh, sql, &errmsg);
+
+
</ins><span class="cx">                 if (errmsg) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR [%s]\n", errmsg);
</span><span class="cx">                         free(errmsg);
</span><span class="lines">@@ -518,7 +607,7 @@
</span><span class="cx">                 
</span><span class="cx">                 
</span><span class="cx">                 if (trans && ((itterations == target) || (nothing_in_queue && ++lc >= 500))) {
</span><del>-                        if (switch_cache_db_persistant_execute_trans(sql_manager.event_db, sqlbuf, 100) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                        if (switch_cache_db_persistant_execute_trans(sql_manager.event_db, sqlbuf, 1) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL thread unable to commit transaction, records lost!\n");
</span><span class="cx">                         }
</span><span class="cx">                         itterations = 0;
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_logc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_log.c (15583 => 15584)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_log.c        2009-11-20 23:09:53 UTC (rev 15583)
+++ freeswitch/trunk/src/switch_log.c        2009-11-20 23:12:07 UTC (rev 15584)
</span><span class="lines">@@ -340,6 +340,14 @@
</span><span class="cx">         const char *extra_fmt = "%s [%s] %s:%d%c%s";
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+        if (level > 100) {
+                if (level - 100 > runtime.debug_level) {
+                        return;
+                }
+
+                level = 7;
+        }
+
</ins><span class="cx">         if (level > runtime.hard_log_level) {
</span><span class="cx">                 return;
</span><span class="cx">         }
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>
</body>
</html>