Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
b4c62153
提交
b4c62153
authored
10月 11, 2012
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add some convenience for db stuff
上级
4dae523b
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
99 行增加
和
0 行删除
+99
-0
switch_core.h
src/include/switch_core.h
+4
-0
switch_event.h
src/include/switch_event.h
+1
-0
switch_core_sqldb.c
src/switch_core_sqldb.c
+73
-0
switch_event.c
src/switch_event.c
+21
-0
没有找到文件。
src/include/switch_core.h
浏览文件 @
b4c62153
...
...
@@ -2207,6 +2207,8 @@ SWITCH_DECLARE(void) switch_core_sqldb_start_thread(void);
\}
*/
typedef
int
(
*
switch_db_event_callback_func_t
)
(
void
*
pArg
,
switch_event_t
*
event
);
#define CACHE_DB_LEN 256
typedef
enum
{
CDF_INUSE
=
(
1
<<
0
),
...
...
@@ -2427,6 +2429,8 @@ SWITCH_DECLARE(switch_status_t) switch_switch_sql_queue_manager_init(switch_sql_
SWITCH_DECLARE
(
switch_status_t
)
switch_switch_sql_queue_manager_start
(
switch_sql_queue_manager_t
*
qm
);
SWITCH_DECLARE
(
switch_status_t
)
switch_switch_sql_queue_manager_stop
(
switch_sql_queue_manager_t
*
qm
);
SWITCH_DECLARE
(
switch_status_t
)
switch_cache_db_execute_sql_event_callback
(
switch_cache_db_handle_t
*
dbh
,
const
char
*
sql
,
switch_db_event_callback_func_t
callback
,
void
*
pdata
,
char
**
err
);
SWITCH_DECLARE
(
pid_t
)
switch_fork
(
void
);
...
...
src/include/switch_event.h
浏览文件 @
b4c62153
...
...
@@ -315,6 +315,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_serialize(switch_event_t *event, ch
SWITCH_DECLARE
(
switch_status_t
)
switch_event_serialize_json
(
switch_event_t
*
event
,
char
**
str
);
SWITCH_DECLARE
(
switch_status_t
)
switch_event_create_json
(
switch_event_t
**
event
,
const
char
*
json
);
SWITCH_DECLARE
(
switch_status_t
)
switch_event_create_brackets
(
char
*
data
,
char
a
,
char
b
,
char
c
,
switch_event_t
**
event
,
char
**
new_data
,
switch_bool_t
dup
);
SWITCH_DECLARE
(
switch_status_t
)
switch_event_create_array_pair
(
switch_event_t
**
event
,
char
**
names
,
char
**
vals
,
int
len
);
#ifndef SWIG
/*!
...
...
src/switch_core_sqldb.c
浏览文件 @
b4c62153
...
...
@@ -982,6 +982,79 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans_full(sw
return
status
;
}
struct
helper
{
switch_db_event_callback_func_t
callback
;
void
*
pdata
;
};
static
int
helper_callback
(
void
*
pArg
,
int
argc
,
char
**
argv
,
char
**
columnNames
)
{
struct
helper
*
h
=
(
struct
helper
*
)
pArg
;
int
r
=
0
;
switch_event_t
*
event
;
switch_event_create_array_pair
(
&
event
,
columnNames
,
argv
,
argc
);
r
=
h
->
callback
(
h
->
pdata
,
event
);
switch_event_destroy
(
&
event
);
return
r
;
}
SWITCH_DECLARE
(
switch_status_t
)
switch_cache_db_execute_sql_event_callback
(
switch_cache_db_handle_t
*
dbh
,
const
char
*
sql
,
switch_db_event_callback_func_t
callback
,
void
*
pdata
,
char
**
err
)
{
switch_status_t
status
=
SWITCH_STATUS_FALSE
;
char
*
errmsg
=
NULL
;
switch_mutex_t
*
io_mutex
=
dbh
->
io_mutex
;
struct
helper
h
;
if
(
err
)
{
*
err
=
NULL
;
}
if
(
io_mutex
)
switch_mutex_lock
(
io_mutex
);
h
.
callback
=
callback
;
h
.
pdata
=
pdata
;
switch
(
dbh
->
type
)
{
case
SCDB_TYPE_PGSQL
:
{
status
=
switch_pgsql_handle_callback_exec
(
dbh
->
native_handle
.
pgsql_dbh
,
sql
,
helper_callback
,
&
h
,
err
);
}
break
;
case
SCDB_TYPE_ODBC
:
{
status
=
switch_odbc_handle_callback_exec
(
dbh
->
native_handle
.
odbc_dbh
,
sql
,
helper_callback
,
&
h
,
err
);
}
break
;
case
SCDB_TYPE_CORE_DB
:
{
int
ret
=
switch_core_db_exec
(
dbh
->
native_handle
.
core_db_dbh
,
sql
,
helper_callback
,
&
h
,
&
errmsg
);
if
(
ret
==
SWITCH_CORE_DB_OK
||
ret
==
SWITCH_CORE_DB_ABORT
)
{
status
=
SWITCH_STATUS_SUCCESS
;
}
if
(
errmsg
)
{
dbh
->
last_used
=
switch_epoch_time_now
(
NULL
)
-
(
SQL_CACHE_TIMEOUT
*
2
);
if
(
!
strstr
(
errmsg
,
"query abort"
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"SQL ERR: [%s] %s
\n
"
,
sql
,
errmsg
);
}
switch_core_db_free
(
errmsg
);
}
}
break
;
}
if
(
io_mutex
)
switch_mutex_unlock
(
io_mutex
);
return
status
;
}
SWITCH_DECLARE
(
switch_status_t
)
switch_cache_db_execute_sql_callback
(
switch_cache_db_handle_t
*
dbh
,
const
char
*
sql
,
switch_core_db_callback_func_t
callback
,
void
*
pdata
,
char
**
err
)
{
...
...
src/switch_event.c
浏览文件 @
b4c62153
...
...
@@ -1492,6 +1492,27 @@ SWITCH_DECLARE(switch_status_t) switch_event_serialize(switch_event_t *event, ch
return
SWITCH_STATUS_SUCCESS
;
}
SWITCH_DECLARE
(
switch_status_t
)
switch_event_create_array_pair
(
switch_event_t
**
event
,
char
**
names
,
char
**
vals
,
int
len
)
{
int
r
;
char
*
name
,
*
val
;
switch_event_create
(
event
,
SWITCH_EVENT_CLONE
);
for
(
r
=
0
;
r
<
len
;
r
++
)
{
val
=
switch_str_nil
(
vals
[
r
]);
name
=
names
[
r
];
if
(
zstr
(
name
))
{
name
=
"Unknown"
;
}
switch_event_add_header
(
*
event
,
SWITCH_STACK_BOTTOM
,
name
,
val
);
}
return
SWITCH_STATUS_SUCCESS
;
}
SWITCH_DECLARE
(
switch_status_t
)
switch_event_create_brackets
(
char
*
data
,
char
a
,
char
b
,
char
c
,
switch_event_t
**
event
,
char
**
new_data
,
switch_bool_t
dup
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论