<!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][15800] </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=15800">15800</a></dd>
<dt>Author</dt> <dd>anthm</dd>
<dt>Date</dt> <dd>2009-12-05 12:54:56 -0600 (Sat, 05 Dec 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>add io mutex to cache db for optional mutex protection</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunksrcincludeswitch_coreh">freeswitch/trunk/src/include/switch_core.h</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_dbc">freeswitch/trunk/src/switch_core_db.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_sqldbc">freeswitch/trunk/src/switch_core_sqldb.c</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunksrcincludeswitch_coreh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_core.h (15799 => 15800)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_core.h        2009-12-04 23:21:51 UTC (rev 15799)
+++ freeswitch/trunk/src/include/switch_core.h        2009-12-05 18:54:56 UTC (rev 15800)
</span><span class="lines">@@ -1987,6 +1987,7 @@
</span><span class="cx">         switch_cache_db_native_handle_t native_handle;
</span><span class="cx">         time_t last_used;
</span><span class="cx">         switch_mutex_t *mutex;
</span><ins>+        switch_mutex_t *io_mutex;
</ins><span class="cx">         switch_memory_pool_t *pool;
</span><span class="cx">         int32_t flags;
</span><span class="cx">         unsigned long hash;
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_dbc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_db.c (15799 => 15800)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_db.c        2009-12-04 23:21:51 UTC (rev 15799)
+++ freeswitch/trunk/src/switch_core_db.c        2009-12-05 18:54:56 UTC (rev 15800)
</span><span class="lines">@@ -86,7 +86,7 @@
</span><span class="cx"> SWITCH_DECLARE(int) switch_core_db_exec(switch_core_db_t *db, const char *sql, switch_core_db_callback_func_t callback, void *data, char **errmsg)
</span><span class="cx"> {
</span><span class="cx">         int ret = 0;
</span><del>-        int sane = 100;
</del><ins>+        int sane = 300;
</ins><span class="cx">         char *err = NULL;
</span><span class="cx">
</span><span class="cx">         while (--sane > 0) {
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_sqldbc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_sqldb.c (15799 => 15800)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_sqldb.c        2009-12-04 23:21:51 UTC (rev 15799)
+++ freeswitch/trunk/src/switch_core_sqldb.c        2009-12-05 18:54:56 UTC (rev 15800)
</span><span class="lines">@@ -35,7 +35,20 @@
</span><span class="cx"> #include <switch.h>
</span><span class="cx"> #include "private/switch_core_pvt.h"
</span><span class="cx">
</span><ins>+static struct {
+        switch_cache_db_handle_t *event_db;
+        switch_queue_t *sql_queue[2];
+        switch_memory_pool_t *memory_pool;
+        switch_event_node_t *event_node;
+        switch_thread_t *thread;
+        int thread_running;
+        switch_bool_t manage;
+        switch_mutex_t *io_mutex;
+        switch_mutex_t *dbh_mutex;
+        switch_hash_t *dbh_hash;
+} sql_manager;
</ins><span class="cx">
</span><ins>+
</ins><span class="cx"> #define SWITCH_CORE_DB "core"
</span><span class="cx"> /*!
</span><span class="cx"> \brief Open the default system database
</span><span class="lines">@@ -43,32 +56,26 @@
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) _switch_core_db_handle(switch_cache_db_handle_t **dbh, const char *file, const char *func, int line)
</span><span class="cx"> {
</span><span class="cx">         switch_cache_db_connection_options_t options = { {0} };
</span><del>-
</del><ins>+        switch_status_t r;
+        
</ins><span class="cx">         if (runtime.odbc_dsn && runtime.odbc_user && runtime.odbc_pass) {
</span><span class="cx">                 options.odbc_options.dsn = runtime.odbc_dsn;
</span><span class="cx">                 options.odbc_options.user = runtime.odbc_user;
</span><span class="cx">                 options.odbc_options.pass = runtime.odbc_pass;
</span><span class="cx">
</span><del>-                return _switch_cache_db_get_db_handle(dbh, SCDB_TYPE_ODBC, &options, file, func, line);
</del><ins>+                r = _switch_cache_db_get_db_handle(dbh, SCDB_TYPE_ODBC, &options, file, func, line);
</ins><span class="cx">         } else {
</span><span class="cx">                 options.core_db_options.db_path = SWITCH_CORE_DB;
</span><del>-                return _switch_cache_db_get_db_handle(dbh, SCDB_TYPE_CORE_DB, &options, file, func, line);
</del><ins>+                r = _switch_cache_db_get_db_handle(dbh, SCDB_TYPE_CORE_DB, &options, file, func, line);
</ins><span class="cx">         }
</span><del>-}
</del><span class="cx">
</span><ins>+        if (r == SWITCH_STATUS_SUCCESS && !(*dbh)->io_mutex) {
+                (*dbh)->io_mutex = sql_manager.io_mutex;
+        }
</ins><span class="cx">
</span><del>-static struct {
-        switch_cache_db_handle_t *event_db;
-        switch_queue_t *sql_queue[2];
-        switch_memory_pool_t *memory_pool;
-        switch_event_node_t *event_node;
-        switch_thread_t *thread;
-        int thread_running;
-        switch_bool_t manage;
-} sql_manager;
</del><ins>+        return r;
+}
</ins><span class="cx">
</span><del>-static switch_mutex_t *dbh_mutex = NULL;
-static switch_hash_t *dbh_hash = NULL;
</del><span class="cx">
</span><span class="cx"> #define SQL_CACHE_TIMEOUT 300
</span><span class="cx">
</span><span class="lines">@@ -81,11 +88,11 @@
</span><span class="cx">         int locked = 0;
</span><span class="cx">         char *key;
</span><span class="cx">         
</span><del>-        switch_mutex_lock(dbh_mutex);
</del><ins>+        switch_mutex_lock(sql_manager.dbh_mutex);
</ins><span class="cx"> top:
</span><span class="cx">         locked = 0;
</span><span class="cx">         
</span><del>-        for (hi = switch_hash_first(NULL, dbh_hash); hi; hi = switch_hash_next(hi)) {
</del><ins>+        for (hi = switch_hash_first(NULL, sql_manager.dbh_hash); hi; hi = switch_hash_next(hi)) {
</ins><span class="cx">                 switch_hash_this(hi, &var, NULL, &val);
</span><span class="cx">                 key = (char *) var;
</span><span class="cx">
</span><span class="lines">@@ -117,7 +124,7 @@
</span><span class="cx">                                         break;
</span><span class="cx">                                 }
</span><span class="cx">
</span><del>-                                switch_core_hash_delete(dbh_hash, key);
</del><ins>+                                switch_core_hash_delete(sql_manager.dbh_hash, key);
</ins><span class="cx">                                 switch_mutex_unlock(dbh->mutex);
</span><span class="cx">                                 switch_core_destroy_memory_pool(&dbh->pool);
</span><span class="cx">                                 goto top;
</span><span class="lines">@@ -133,7 +140,7 @@
</span><span class="cx">                 goto top;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        switch_mutex_unlock(dbh_mutex);
</del><ins>+        switch_mutex_unlock(sql_manager.dbh_mutex);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -149,7 +156,7 @@
</span><span class="cx"> SWITCH_DECLARE(void) switch_cache_db_destroy_db_handle(switch_cache_db_handle_t **dbh)
</span><span class="cx"> {
</span><span class="cx">         if (dbh && *dbh) {
</span><del>-                switch_mutex_lock(dbh_mutex);
</del><ins>+                switch_mutex_lock(sql_manager.dbh_mutex);
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Deleting DB connection %s\n", (*dbh)->name);
</span><span class="cx">
</span><span class="cx">                 switch ((*dbh)->type) {
</span><span class="lines">@@ -167,11 +174,11 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 
</span><del>-                switch_core_hash_delete(dbh_hash, (*dbh)->name);                
</del><ins>+                switch_core_hash_delete(sql_manager.dbh_hash, (*dbh)->name);                
</ins><span class="cx">                 switch_mutex_unlock((*dbh)->mutex);
</span><span class="cx">                 switch_core_destroy_memory_pool(&(*dbh)->pool);
</span><span class="cx">                 *dbh = NULL;
</span><del>-                switch_mutex_unlock(dbh_mutex);
</del><ins>+                switch_mutex_unlock(sql_manager.dbh_mutex);
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -185,9 +192,9 @@
</span><span class="cx">         switch_cache_db_handle_t *dbh = NULL;
</span><span class="cx">
</span><span class="cx">         snprintf(thread_str, sizeof(thread_str) - 1, "%lu", (unsigned long)(intptr_t)switch_thread_self());
</span><del>-        switch_mutex_lock(dbh_mutex);
</del><ins>+        switch_mutex_lock(sql_manager.dbh_mutex);
</ins><span class="cx">
</span><del>-        for (hi = switch_hash_first(NULL, dbh_hash); hi; hi = switch_hash_next(hi)) {
</del><ins>+        for (hi = switch_hash_first(NULL, sql_manager.dbh_hash); hi; hi = switch_hash_next(hi)) {
</ins><span class="cx">                 switch_hash_this(hi, &var, NULL, &val);
</span><span class="cx">                 key = (char *) var;
</span><span class="cx">                 if ((dbh = (switch_cache_db_handle_t *) val)) {
</span><span class="lines">@@ -202,7 +209,7 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        switch_mutex_unlock(dbh_mutex);
</del><ins>+        switch_mutex_unlock(sql_manager.dbh_mutex);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t)_switch_cache_db_get_db_handle(switch_cache_db_handle_t **dbh,
</span><span class="lines">@@ -246,8 +253,8 @@
</span><span class="cx">         snprintf(thread_str, sizeof(thread_str) - 1, "%s;thread=\"%lu\"", db_str, (unsigned long)(intptr_t)self);
</span><span class="cx">         snprintf(db_callsite_str, sizeof(db_callsite_str) - 1, "%s:%d", file, line);
</span><span class="cx">         
</span><del>-        switch_mutex_lock(dbh_mutex);
-        if ((new_dbh = switch_core_hash_find(dbh_hash, thread_str))) {
</del><ins>+        switch_mutex_lock(sql_manager.dbh_mutex);
+        if ((new_dbh = switch_core_hash_find(sql_manager.dbh_hash, thread_str))) {
</ins><span class="cx">                 switch_set_string(new_dbh->last_user, db_callsite_str);
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG10,
</span><span class="cx">                                                  "Reuse Cached DB handle %s [%s]\n", thread_str, switch_cache_db_type_name(new_dbh->type));
</span><span class="lines">@@ -260,7 +267,7 @@
</span><span class="cx">                 
</span><span class="cx">                 hash = switch_ci_hashfunc_default(db_str, &hlen);
</span><span class="cx">
</span><del>-                for (hi = switch_hash_first(NULL, dbh_hash); hi; hi = switch_hash_next(hi)) {
</del><ins>+                for (hi = switch_hash_first(NULL, sql_manager.dbh_hash); hi; hi = switch_hash_next(hi)) {
</ins><span class="cx">                         switch_hash_this(hi, &var, NULL, &val);
</span><span class="cx">                         key = (char *) var;
</span><span class="cx">                         
</span><span class="lines">@@ -337,14 +344,14 @@
</span><span class="cx">                 switch_set_string(new_dbh->creator, db_callsite_str);
</span><span class="cx">                 switch_mutex_lock(new_dbh->mutex);
</span><span class="cx">
</span><del>-                switch_core_hash_insert(dbh_hash, new_dbh->name, new_dbh);
</del><ins>+                switch_core_hash_insert(sql_manager.dbh_hash, new_dbh->name, new_dbh);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx"> end:
</span><span class="cx">
</span><span class="cx">         if (new_dbh) new_dbh->last_used = switch_epoch_time_now(NULL);
</span><span class="cx">
</span><del>-        switch_mutex_unlock(dbh_mutex);
</del><ins>+        switch_mutex_unlock(sql_manager.dbh_mutex);
</ins><span class="cx">
</span><span class="cx">         *dbh = new_dbh;
</span><span class="cx">
</span><span class="lines">@@ -357,6 +364,10 @@
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">         char *errmsg = NULL;
</span><span class="cx">
</span><ins>+        if (dbh->io_mutex) {
+                switch_mutex_lock(dbh->io_mutex);
+        }
+
</ins><span class="cx">         if (err) *err = NULL;
</span><span class="cx">         
</span><span class="cx">         switch (dbh->type) {
</span><span class="lines">@@ -386,6 +397,11 @@
</span><span class="cx">                         free(errmsg);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><ins>+
+
+        if (dbh->io_mutex) {
+                switch_mutex_unlock(dbh->io_mutex);
+        }
</ins><span class="cx">         
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="lines">@@ -456,6 +472,9 @@
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">
</span><ins>+        if (dbh->io_mutex) {
+                switch_mutex_lock(dbh->io_mutex);
+        }
</ins><span class="cx">
</span><span class="cx">         switch (dbh->type) {
</span><span class="cx">         default:
</span><span class="lines">@@ -465,6 +484,10 @@
</span><span class="cx">                 break;
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        if (dbh->io_mutex) {
+                switch_mutex_unlock(dbh->io_mutex);
+        }
+
</ins><span class="cx">         return status;
</span><span class="cx">
</span><span class="cx"> }
</span><span class="lines">@@ -475,6 +498,10 @@
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">
</span><span class="cx">
</span><ins>+        if (dbh->io_mutex) {
+                switch_mutex_lock(dbh->io_mutex);
+        }
+
</ins><span class="cx">         switch (dbh->type) {
</span><span class="cx">         case SCDB_TYPE_CORE_DB:
</span><span class="cx">                 {
</span><span class="lines">@@ -522,6 +549,10 @@
</span><span class="cx">
</span><span class="cx"> end:
</span><span class="cx">
</span><ins>+        if (dbh->io_mutex) {
+                switch_mutex_unlock(dbh->io_mutex);
+        }
+
</ins><span class="cx">         return status == SWITCH_STATUS_SUCCESS ? str : NULL;
</span><span class="cx">
</span><span class="cx"> }
</span><span class="lines">@@ -537,6 +568,10 @@
</span><span class="cx">                 retries = 1000;
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        if (dbh->io_mutex) {
+                switch_mutex_lock(dbh->io_mutex);
+        }
+
</ins><span class="cx">         while (retries > 0) {
</span><span class="cx">                 switch_cache_db_execute_sql_real(dbh, sql, &errmsg);
</span><span class="cx">                 if (errmsg) {
</span><span class="lines">@@ -554,6 +589,10 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        if (dbh->io_mutex) {
+                switch_mutex_unlock(dbh->io_mutex);
+        }
+
</ins><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -571,6 +610,10 @@
</span><span class="cx">                 retries = 1000;
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        if (dbh->io_mutex) {
+                switch_mutex_lock(dbh->io_mutex);
+        }
+
</ins><span class="cx"> again:
</span><span class="cx">
</span><span class="cx">         while (begin_retries > 0) {
</span><span class="lines">@@ -629,6 +672,11 @@
</span><span class="cx">
</span><span class="cx">         switch_cache_db_execute_sql_real(dbh, "COMMIT", NULL);
</span><span class="cx">
</span><ins>+        if (dbh->io_mutex) {
+                switch_mutex_unlock(dbh->io_mutex);
+        }
+
+
</ins><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -641,6 +689,9 @@
</span><span class="cx">
</span><span class="cx">         if (err) *err = NULL;
</span><span class="cx">
</span><ins>+        if (dbh->io_mutex) {
+                switch_mutex_lock(dbh->io_mutex);
+        }
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">         switch (dbh->type) {
</span><span class="lines">@@ -661,6 +712,10 @@
</span><span class="cx">                 break;
</span><span class="cx">         }
</span><span class="cx">         
</span><ins>+        if (dbh->io_mutex) {
+                switch_mutex_unlock(dbh->io_mutex);
+        }
+
</ins><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -668,6 +723,11 @@
</span><span class="cx"> {
</span><span class="cx">         char *errmsg;
</span><span class="cx">
</span><ins>+
+        if (dbh->io_mutex) {
+                switch_mutex_lock(dbh->io_mutex);
+        }
+
</ins><span class="cx">         switch (dbh->type) {
</span><span class="cx">         case SCDB_TYPE_ODBC:
</span><span class="cx">                 {
</span><span class="lines">@@ -707,17 +767,22 @@
</span><span class="cx">                 }
</span><span class="cx">                 break;
</span><span class="cx">         }
</span><ins>+
+
+        if (dbh->io_mutex) {
+                switch_mutex_unlock(dbh->io_mutex);
+        }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-#define SQLLEN 1024 * 64
</del><ins>+#define SQLLEN 1024 * 1024
</ins><span class="cx"> static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t * thread, void *obj)
</span><span class="cx"> {
</span><span class="cx">         void *pop;
</span><span class="cx">         uint32_t itterations = 0;
</span><span class="cx">         uint8_t trans = 0, nothing_in_queue = 0;
</span><del>-        uint32_t target = 50000;
</del><ins>+        uint32_t target = 100000;
</ins><span class="cx">         switch_size_t len = 0, sql_len = SQLLEN;
</span><span class="cx">         char *tmp, *sqlbuf = (char *) malloc(sql_len);
</span><span class="cx">         char *sql;
</span><span class="lines">@@ -1175,8 +1240,10 @@
</span><span class="cx">         sql_manager.memory_pool = pool;
</span><span class="cx">         sql_manager.manage = manage;
</span><span class="cx">         
</span><del>-        switch_mutex_init(&dbh_mutex, SWITCH_MUTEX_NESTED, sql_manager.memory_pool);
-        switch_core_hash_init(&dbh_hash, sql_manager.memory_pool);
</del><ins>+        switch_mutex_init(&sql_manager.dbh_mutex, SWITCH_MUTEX_NESTED, sql_manager.memory_pool);
+        switch_mutex_init(&sql_manager.io_mutex, SWITCH_MUTEX_NESTED, sql_manager.memory_pool);
+        
+        switch_core_hash_init(&sql_manager.dbh_hash, sql_manager.memory_pool);
</ins><span class="cx">
</span><span class="cx"> top:
</span><span class="cx">         
</span><span class="lines">@@ -1329,7 +1396,7 @@
</span><span class="cx">
</span><span class="cx">         sql_close(0);
</span><span class="cx">
</span><del>-        switch_core_hash_destroy(&dbh_hash);
</del><ins>+        switch_core_hash_destroy(&sql_manager.dbh_hash);
</ins><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1347,9 +1414,9 @@
</span><span class="cx">         char *pos1 = NULL;
</span><span class="cx">         char *pos2 = NULL;
</span><span class="cx">         
</span><del>-        switch_mutex_lock(dbh_mutex);
</del><ins>+        switch_mutex_lock(sql_manager.dbh_mutex);
</ins><span class="cx">         
</span><del>-        for (hi = switch_hash_first(NULL, dbh_hash); hi; hi = switch_hash_next(hi)) {
</del><ins>+        for (hi = switch_hash_first(NULL, sql_manager.dbh_hash); hi; hi = switch_hash_next(hi)) {
</ins><span class="cx">                 switch_hash_this(hi, &var, NULL, &val);
</span><span class="cx">                 key = (char *) var;
</span><span class="cx">
</span><span class="lines">@@ -1385,7 +1452,7 @@
</span><span class="cx">                                 dbh->last_user);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        switch_mutex_unlock(dbh_mutex);
</del><ins>+        switch_mutex_unlock(sql_manager.dbh_mutex);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /* For Emacs:
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>
</body>
</html>