Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
2044a749
提交
2044a749
authored
3月 01, 2011
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-3105 try this patch
上级
b041edc8
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
36 行增加
和
55 行删除
+36
-55
switch_core_sqldb.c
src/switch_core_sqldb.c
+36
-55
没有找到文件。
src/switch_core_sqldb.c
浏览文件 @
2044a749
...
...
@@ -431,13 +431,13 @@ static switch_status_t switch_cache_db_execute_sql_real(switch_cache_db_handle_t
switch_status_t
status
=
SWITCH_STATUS_FALSE
;
char
*
errmsg
=
NULL
;
char
*
tmp
=
NULL
;
switch_mutex_t
*
io_mutex
=
dbh
->
io_mutex
;
if
(
io_mutex
)
switch_mutex_lock
(
io_mutex
);
if
(
dbh
->
io_mutex
)
{
switch_mutex_lock
(
dbh
->
io_mutex
);
}
if
(
err
)
if
(
err
)
{
*
err
=
NULL
;
}
switch
(
dbh
->
type
)
{
case
SCDB_TYPE_ODBC
:
...
...
@@ -469,9 +469,7 @@ static switch_status_t switch_cache_db_execute_sql_real(switch_cache_db_handle_t
}
if
(
dbh
->
io_mutex
)
{
switch_mutex_unlock
(
dbh
->
io_mutex
);
}
if
(
io_mutex
)
switch_mutex_unlock
(
io_mutex
);
return
status
;
}
...
...
@@ -556,10 +554,9 @@ static switch_status_t switch_cache_db_execute_sql_chunked(switch_cache_db_handl
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
;
switch_mutex_t
*
io_mutex
=
dbh
->
io_mutex
;
if
(
dbh
->
io_mutex
)
{
switch_mutex_lock
(
dbh
->
io_mutex
);
}
if
(
io_mutex
)
switch_mutex_lock
(
io_mutex
);
switch
(
dbh
->
type
)
{
default
:
...
...
@@ -569,9 +566,7 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql(switch_cache_db_hand
break
;
}
if
(
dbh
->
io_mutex
)
{
switch_mutex_unlock
(
dbh
->
io_mutex
);
}
if
(
io_mutex
)
switch_mutex_unlock
(
io_mutex
);
return
status
;
...
...
@@ -599,11 +594,9 @@ SWITCH_DECLARE(int) switch_cache_db_affected_rows(switch_cache_db_handle_t *dbh)
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
;
switch_mutex_t
*
io_mutex
=
dbh
->
io_mutex
;
if
(
dbh
->
io_mutex
)
{
switch_mutex_lock
(
dbh
->
io_mutex
);
}
if
(
io_mutex
)
switch_mutex_lock
(
io_mutex
);
switch
(
dbh
->
type
)
{
case
SCDB_TYPE_CORE_DB
:
...
...
@@ -612,7 +605,7 @@ SWITCH_DECLARE(char *) switch_cache_db_execute_sql2str(switch_cache_db_handle_t
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
);
return
NULL
;
goto
end
;
}
else
{
int
running
=
1
;
int
colcount
;
...
...
@@ -652,9 +645,7 @@ SWITCH_DECLARE(char *) switch_cache_db_execute_sql2str(switch_cache_db_handle_t
end
:
if
(
dbh
->
io_mutex
)
{
switch_mutex_unlock
(
dbh
->
io_mutex
);
}
if
(
io_mutex
)
switch_mutex_unlock
(
io_mutex
);
return
status
==
SWITCH_STATUS_SUCCESS
?
str
:
NULL
;
...
...
@@ -665,18 +656,20 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute(switch_cache_
char
*
errmsg
=
NULL
;
switch_status_t
status
=
SWITCH_STATUS_FALSE
;
uint8_t
forever
=
0
;
switch_mutex_t
*
io_mutex
=
dbh
->
io_mutex
;
if
(
!
retries
)
{
forever
=
1
;
retries
=
1000
;
}
if
(
dbh
->
io_mutex
)
{
switch_mutex_lock
(
dbh
->
io_mutex
);
}
while
(
retries
>
0
)
{
if
(
io_mutex
)
switch_mutex_lock
(
io_mutex
);
switch_cache_db_execute_sql_real
(
dbh
,
sql
,
&
errmsg
);
if
(
io_mutex
)
switch_mutex_unlock
(
io_mutex
);
if
(
errmsg
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"SQL ERR [%s]
\n
"
,
errmsg
);
switch_safe_free
(
errmsg
);
...
...
@@ -691,11 +684,7 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute(switch_cache_
break
;
}
}
if
(
dbh
->
io_mutex
)
{
switch_mutex_unlock
(
dbh
->
io_mutex
);
}
return
status
;
}
...
...
@@ -707,15 +696,14 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_
uint8_t
forever
=
0
;
unsigned
begin_retries
=
100
;
uint8_t
again
=
0
;
switch_mutex_t
*
io_mutex
=
dbh
->
io_mutex
;
if
(
!
retries
)
{
forever
=
1
;
retries
=
1000
;
}
if
(
dbh
->
io_mutex
)
{
switch_mutex_lock
(
dbh
->
io_mutex
);
}
if
(
io_mutex
)
switch_mutex_lock
(
io_mutex
);
again
:
...
...
@@ -726,6 +714,7 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_
switch_cache_db_execute_sql_real
(
dbh
,
"BEGIN"
,
&
errmsg
);
}
else
{
switch_odbc_status_t
result
;
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
);
...
...
@@ -753,23 +742,23 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_
goto
again
;
}
switch_yield
(
100000
);
if
(
begin_retries
==
0
)
{
goto
done
;
}
}
else
{
break
;
continue
;
}
break
;
}
while
(
retries
>
0
)
{
switch_cache_db_execute_sql
(
dbh
,
sql
,
&
errmsg
);
if
(
errmsg
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"SQL ERR [%s]
\n
"
,
errmsg
);
free
(
errmsg
);
...
...
@@ -795,10 +784,7 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_
switch_odbc_SQLSetAutoCommitAttr
(
dbh
->
native_handle
.
odbc_dbh
,
1
);
}
if
(
dbh
->
io_mutex
)
{
switch_mutex_unlock
(
dbh
->
io_mutex
);
}
if
(
io_mutex
)
switch_mutex_unlock
(
io_mutex
);
return
status
;
}
...
...
@@ -808,14 +794,14 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql_callback(switch_cach
{
switch_status_t
status
=
SWITCH_STATUS_FALSE
;
char
*
errmsg
=
NULL
;
switch_mutex_t
*
io_mutex
=
dbh
->
io_mutex
;
if
(
err
)
if
(
err
)
{
*
err
=
NULL
;
if
(
dbh
->
io_mutex
)
{
switch_mutex_lock
(
dbh
->
io_mutex
);
}
if
(
io_mutex
)
switch_mutex_lock
(
io_mutex
);
switch
(
dbh
->
type
)
{
case
SCDB_TYPE_ODBC
:
...
...
@@ -836,9 +822,7 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql_callback(switch_cach
break
;
}
if
(
dbh
->
io_mutex
)
{
switch_mutex_unlock
(
dbh
->
io_mutex
);
}
if
(
io_mutex
)
switch_mutex_unlock
(
io_mutex
);
return
status
;
}
...
...
@@ -848,15 +832,14 @@ SWITCH_DECLARE(switch_bool_t) switch_cache_db_test_reactive(switch_cache_db_hand
{
char
*
errmsg
;
switch_bool_t
r
=
SWITCH_TRUE
;
switch_mutex_t
*
io_mutex
=
dbh
->
io_mutex
;
if
(
!
switch_test_flag
((
&
runtime
),
SCF_AUTO_SCHEMAS
))
{
switch_cache_db_execute_sql
(
dbh
,
(
char
*
)
test_sql
,
NULL
);
return
SWITCH_TRUE
;
}
if
(
dbh
->
io_mutex
)
{
switch_mutex_lock
(
dbh
->
io_mutex
);
}
if
(
io_mutex
)
switch_mutex_lock
(
io_mutex
);
switch
(
dbh
->
type
)
{
case
SCDB_TYPE_ODBC
:
...
...
@@ -901,9 +884,7 @@ SWITCH_DECLARE(switch_bool_t) switch_cache_db_test_reactive(switch_cache_db_hand
}
if
(
dbh
->
io_mutex
)
{
switch_mutex_unlock
(
dbh
->
io_mutex
);
}
if
(
io_mutex
)
switch_mutex_unlock
(
io_mutex
);
return
r
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论