switch_cache_db_handle_t *dbh = NULL;
- if (!(dbh = cc_get_db_handle())) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB\n");
- return NULL;
- }
-
if (mutex) {
switch_mutex_lock(mutex);
} else {
switch_mutex_lock(globals.mutex);
}
+ if (!(dbh = cc_get_db_handle())) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB\n");
+ goto end;
+ }
+
ret = switch_cache_db_execute_sql2str(dbh, sql, resbuf, len, NULL);
+end:
+ switch_cache_db_release_db_handle(&dbh);
+
if (mutex) {
switch_mutex_unlock(mutex);
} else {
switch_mutex_unlock(globals.mutex);
}
- switch_cache_db_release_db_handle(&dbh);
-
return ret;
}