<h1>Project "FreeSWITCH Source" received a push.</h1>
<h2>branch: master updated</h2>
<pre>
via: 2044a749cf131d4765078212883f17af19cff57b (commit)
from: b041edc8581d5d6729c3a8068df426a9e2ac70da (commit)
</pre>= COMMIT LOG ===========================================================
<div class="highlight"><pre>committer: Anthony Minessale
comments:
FS-3105 try this patch
<span style="color: #000080; font-weight: bold">diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c</span>
<span style="color: #000080; font-weight: bold">index 8841fcc..386fb76 100644</span>
<span style="color: #A00000">--- a/src/switch_core_sqldb.c</span>
<span style="color: #00A000">+++ b/src/switch_core_sqldb.c</span>
<span style="color: #800080; font-weight: bold">@@ -431,13 +431,13 @@ static switch_status_t switch_cache_db_execute_sql_real(switch_cache_db_handle_t</span>
        switch_status_t status = SWITCH_STATUS_FALSE;
        char *errmsg = NULL;
        char *tmp = NULL;
<span style="color: #00A000">+        switch_mutex_t *io_mutex = dbh->io_mutex;</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        if (io_mutex) switch_mutex_lock(io_mutex);</span>
<span style="color: #A00000">-        if (dbh->io_mutex) {</span>
<span style="color: #A00000">-                switch_mutex_lock(dbh->io_mutex);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (err)</span>
<span style="color: #00A000">+        if (err) {</span>
                *err = NULL;
<span style="color: #00A000">+        }</span>
        switch (dbh->type) {
        case SCDB_TYPE_ODBC:
<span style="color: #800080; font-weight: bold">@@ -469,9 +469,7 @@ static switch_status_t switch_cache_db_execute_sql_real(switch_cache_db_handle_t</span>
        }
<span style="color: #A00000">-        if (dbh->io_mutex) {</span>
<span style="color: #A00000">-                switch_mutex_unlock(dbh->io_mutex);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #00A000">+        if (io_mutex) switch_mutex_unlock(io_mutex);</span>
        return status;
}
<span style="color: #800080; font-weight: bold">@@ -556,10 +554,9 @@ static switch_status_t switch_cache_db_execute_sql_chunked(switch_cache_db_handl</span>
SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql(switch_cache_db_handle_t *dbh, char *sql, char **err)
{
        switch_status_t status = SWITCH_STATUS_FALSE;
<span style="color: #00A000">+        switch_mutex_t *io_mutex = dbh->io_mutex;</span>
<span style="color: #A00000">-        if (dbh->io_mutex) {</span>
<span style="color: #A00000">-                switch_mutex_lock(dbh->io_mutex);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #00A000">+        if (io_mutex) switch_mutex_lock(io_mutex);</span>
        switch (dbh->type) {
        default:
<span style="color: #800080; font-weight: bold">@@ -569,9 +566,7 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql(switch_cache_db_hand</span>
                break;
        }
<span style="color: #A00000">-        if (dbh->io_mutex) {</span>
<span style="color: #A00000">-                switch_mutex_unlock(dbh->io_mutex);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #00A000">+        if (io_mutex) switch_mutex_unlock(io_mutex);</span>
        return status;
<span style="color: #800080; font-weight: bold">@@ -599,11 +594,9 @@ SWITCH_DECLARE(int) switch_cache_db_affected_rows(switch_cache_db_handle_t *dbh)</span>
SWITCH_DECLARE(char *) switch_cache_db_execute_sql2str(switch_cache_db_handle_t *dbh, char *sql, char *str, size_t len, char **err)
{
        switch_status_t status = SWITCH_STATUS_FALSE;
<span style="color: #00A000">+        switch_mutex_t *io_mutex = dbh->io_mutex;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (dbh->io_mutex) {</span>
<span style="color: #A00000">-                switch_mutex_lock(dbh->io_mutex);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #00A000">+        if (io_mutex) switch_mutex_lock(io_mutex);</span>
        switch (dbh->type) {
        case SCDB_TYPE_CORE_DB:
<span style="color: #800080; font-weight: bold">@@ -612,7 +605,7 @@ SWITCH_DECLARE(char *) switch_cache_db_execute_sql2str(switch_cache_db_handle_t</span>
                        if (switch_core_db_prepare(dbh->native_handle.core_db_dbh, sql, -1, &stmt, 0)) {
                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Statement Error [%s]!\n", sql);
<span style="color: #A00000">-                                return NULL;</span>
<span style="color: #00A000">+                                goto end;</span>
                        } else {
                                int running = 1;
                                int colcount;
<span style="color: #800080; font-weight: bold">@@ -652,9 +645,7 @@ SWITCH_DECLARE(char *) switch_cache_db_execute_sql2str(switch_cache_db_handle_t</span>
end:
<span style="color: #A00000">-        if (dbh->io_mutex) {</span>
<span style="color: #A00000">-                switch_mutex_unlock(dbh->io_mutex);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #00A000">+        if (io_mutex) switch_mutex_unlock(io_mutex);</span>
        return status == SWITCH_STATUS_SUCCESS ? str : NULL;
<span style="color: #800080; font-weight: bold">@@ -665,18 +656,20 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute(switch_cache_</span>
        char *errmsg = NULL;
        switch_status_t status = SWITCH_STATUS_FALSE;
        uint8_t forever = 0;
<span style="color: #00A000">+        switch_mutex_t *io_mutex = dbh->io_mutex;</span>
        if (!retries) {
                forever = 1;
                retries = 1000;
        }
<span style="color: #A00000">-        if (dbh->io_mutex) {</span>
<span style="color: #A00000">-                switch_mutex_lock(dbh->io_mutex);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
        while (retries > 0) {
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                if (io_mutex) switch_mutex_lock(io_mutex);</span>
                switch_cache_db_execute_sql_real(dbh, sql, &errmsg);
<span style="color: #00A000">+                if (io_mutex) switch_mutex_unlock(io_mutex);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                </span>
                if (errmsg) {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR [%s]\n", errmsg);
                        switch_safe_free(errmsg);
<span style="color: #800080; font-weight: bold">@@ -691,11 +684,7 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute(switch_cache_</span>
                        break;
                }
        }
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (dbh->io_mutex) {</span>
<span style="color: #A00000">-                switch_mutex_unlock(dbh->io_mutex);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #00A000">+        </span>
        return status;
}
<span style="color: #800080; font-weight: bold">@@ -707,15 +696,14 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_</span>
        uint8_t forever = 0;
        unsigned begin_retries = 100;
        uint8_t again = 0;
<span style="color: #00A000">+        switch_mutex_t *io_mutex = dbh->io_mutex;</span>
        if (!retries) {
                forever = 1;
                retries = 1000;
        }
<span style="color: #A00000">-        if (dbh->io_mutex) {</span>
<span style="color: #A00000">-                switch_mutex_lock(dbh->io_mutex);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #00A000">+        if (io_mutex) switch_mutex_lock(io_mutex);</span>
again:
<span style="color: #800080; font-weight: bold">@@ -726,6 +714,7 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_</span>
                        switch_cache_db_execute_sql_real(dbh, "BEGIN", &errmsg);
                } else {
                        switch_odbc_status_t result;
<span style="color: #00A000">+</span>
                        if ((result = switch_odbc_SQLSetAutoCommitAttr(dbh->native_handle.odbc_dbh, 0)) != SWITCH_ODBC_SUCCESS) {
                                char tmp[100];
                                switch_snprintf(tmp, sizeof(tmp), "%s-%i", "Unable to Set AutoCommit Off", result);
<span style="color: #800080; font-weight: bold">@@ -753,23 +742,23 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_</span>
                                goto again;
                        }
<span style="color: #A00000">-</span>
<span style="color: #00A000">+                        </span>
                        switch_yield(100000);
                        if (begin_retries == 0) {
                                goto done;
                        }
<span style="color: #A00000">-                } else {</span>
<span style="color: #A00000">-                        break;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        continue;</span>
                }
<span style="color: #00A000">+                break;</span>
        }
        while (retries > 0) {
                switch_cache_db_execute_sql(dbh, sql, &errmsg);
<span style="color: #A00000">-</span>
                if (errmsg) {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR [%s]\n", errmsg);
                        free(errmsg);
<span style="color: #800080; font-weight: bold">@@ -795,10 +784,7 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_</span>
                switch_odbc_SQLSetAutoCommitAttr(dbh->native_handle.odbc_dbh, 1);
        }
<span style="color: #A00000">-        if (dbh->io_mutex) {</span>
<span style="color: #A00000">-                switch_mutex_unlock(dbh->io_mutex);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #00A000">+        if (io_mutex) switch_mutex_unlock(io_mutex);</span>
        return status;
}
<span style="color: #800080; font-weight: bold">@@ -808,14 +794,14 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql_callback(switch_cach</span>
{
        switch_status_t status = SWITCH_STATUS_FALSE;
        char *errmsg = NULL;
<span style="color: #00A000">+        switch_mutex_t *io_mutex = dbh->io_mutex;</span>
<span style="color: #A00000">-        if (err)</span>
<span style="color: #00A000">+        if (err) {</span>
                *err = NULL;
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (dbh->io_mutex) {</span>
<span style="color: #A00000">-                switch_mutex_lock(dbh->io_mutex);</span>
        }
<span style="color: #00A000">+        if (io_mutex) switch_mutex_lock(io_mutex);</span>
<span style="color: #00A000">+</span>
        switch (dbh->type) {
        case SCDB_TYPE_ODBC:
<span style="color: #800080; font-weight: bold">@@ -836,9 +822,7 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql_callback(switch_cach</span>
                break;
        }
<span style="color: #A00000">-        if (dbh->io_mutex) {</span>
<span style="color: #A00000">-                switch_mutex_unlock(dbh->io_mutex);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #00A000">+        if (io_mutex) switch_mutex_unlock(io_mutex);</span>
        return status;
}
<span style="color: #800080; font-weight: bold">@@ -848,15 +832,14 @@ SWITCH_DECLARE(switch_bool_t) switch_cache_db_test_reactive(switch_cache_db_hand</span>
{
        char *errmsg;
        switch_bool_t r = SWITCH_TRUE;
<span style="color: #00A000">+        switch_mutex_t *io_mutex = dbh->io_mutex;</span>
        if (!switch_test_flag((&runtime), SCF_AUTO_SCHEMAS)) {
                switch_cache_db_execute_sql(dbh, (char *)test_sql, NULL);
                return SWITCH_TRUE;
        }
<span style="color: #A00000">-        if (dbh->io_mutex) {</span>
<span style="color: #A00000">-                switch_mutex_lock(dbh->io_mutex);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #00A000">+        if (io_mutex) switch_mutex_lock(io_mutex);</span>
        switch (dbh->type) {
        case SCDB_TYPE_ODBC:
<span style="color: #800080; font-weight: bold">@@ -901,9 +884,7 @@ SWITCH_DECLARE(switch_bool_t) switch_cache_db_test_reactive(switch_cache_db_hand</span>
        }
<span style="color: #A00000">-        if (dbh->io_mutex) {</span>
<span style="color: #A00000">-                switch_mutex_unlock(dbh->io_mutex);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #00A000">+        if (io_mutex) switch_mutex_unlock(io_mutex);</span>
        return r;
}
</pre></div>
========================================================================<pre>
Summary of changes:
src/switch_core_sqldb.c | 91 ++++++++++++++++++----------------------------
1 files changed, 36 insertions(+), 55 deletions(-)
</pre>
<p>this email was generated because of /git/your-repo.git/hooks/post-receive by the file /git-core/contrib/hooks/post-receive-email<br />
For more info, see <a href="http://blog.chomperstomp.com/?p=630">http://blog.chomperstomp.com/?p=630</a>
-- <br />
FreeSWITCH Source</p>