Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
203f727e
提交
203f727e
authored
1月 31, 2013
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add async select feature to sql queue manager api
上级
f0bf3b91
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
97 行增加
和
4 行删除
+97
-4
switch_core.h
src/include/switch_core.h
+2
-2
switch_core_sqldb.c
src/switch_core_sqldb.c
+95
-2
没有找到文件。
src/include/switch_core.h
浏览文件 @
203f727e
...
...
@@ -2226,7 +2226,7 @@ SWITCH_DECLARE(void) switch_core_sqldb_resume(void);
\}
*/
typedef
int
(
*
switch_db_event_callback_func_t
)
(
void
*
pArg
,
switch_event_t
*
event
);
typedef
int
(
*
switch_
core_
db_event_callback_func_t
)
(
void
*
pArg
,
switch_event_t
*
event
);
#define CACHE_DB_LEN 256
typedef
enum
{
...
...
@@ -2461,7 +2461,7 @@ SWITCH_DECLARE(switch_status_t) switch_sql_queue_manager_init_name(const char *n
SWITCH_DECLARE
(
switch_status_t
)
switch_sql_queue_manager_start
(
switch_sql_queue_manager_t
*
qm
);
SWITCH_DECLARE
(
switch_status_t
)
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
);
const
char
*
sql
,
switch_
core_
db_event_callback_func_t
callback
,
void
*
pdata
,
char
**
err
);
SWITCH_DECLARE
(
pid_t
)
switch_fork
(
void
);
...
...
src/switch_core_sqldb.c
浏览文件 @
203f727e
...
...
@@ -1017,7 +1017,7 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans_full(sw
}
struct
helper
{
switch_db_event_callback_func_t
callback
;
switch_
core_
db_event_callback_func_t
callback
;
void
*
pdata
;
};
...
...
@@ -1037,7 +1037,7 @@ static int helper_callback(void *pArg, int argc, char **argv, char **columnNames
}
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
)
const
char
*
sql
,
switch_
core_
db_event_callback_func_t
callback
,
void
*
pdata
,
char
**
err
)
{
switch_status_t
status
=
SWITCH_STATUS_FALSE
;
char
*
errmsg
=
NULL
;
...
...
@@ -1287,6 +1287,99 @@ static uint32_t qm_ttl(switch_sql_queue_manager_t *qm)
return
ttl
;
}
struct
db_job
{
switch_sql_queue_manager_t
*
qm
;
char
*
sql
;
switch_core_db_callback_func_t
callback
;
switch_core_db_event_callback_func_t
event_callback
;
void
*
pdata
;
int
event
;
switch_memory_pool_t
*
pool
;
};
static
void
*
SWITCH_THREAD_FUNC
sql_in_thread
(
switch_thread_t
*
thread
,
void
*
obj
)
{
struct
db_job
*
job
=
(
struct
db_job
*
)
obj
;
switch_memory_pool_t
*
pool
=
job
->
pool
;
char
*
err
=
NULL
;
switch_cache_db_handle_t
*
dbh
;
if
(
switch_cache_db_get_db_handle_dsn
(
&
dbh
,
job
->
qm
->
dsn
)
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Cannot connect DSN %s
\n
"
,
job
->
qm
->
dsn
);
return
NULL
;
}
if
(
job
->
callback
)
{
switch_cache_db_execute_sql_callback
(
dbh
,
job
->
sql
,
job
->
callback
,
job
->
pdata
,
&
err
);
}
else
if
(
job
->
event_callback
)
{
switch_cache_db_execute_sql_event_callback
(
dbh
,
job
->
sql
,
job
->
event_callback
,
job
->
pdata
,
&
err
);
}
if
(
err
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"SQL ERR: [%s] %s
\n
"
,
job
->
sql
,
err
);
free
(
err
);
}
switch_cache_db_release_db_handle
(
&
dbh
);
if
(
pool
)
{
switch_core_destroy_memory_pool
(
&
pool
);
}
return
NULL
;
}
static
switch_thread_data_t
*
new_job
(
switch_sql_queue_manager_t
*
qm
,
const
char
*
sql
,
switch_core_db_callback_func_t
callback
,
switch_core_db_event_callback_func_t
event_callback
,
void
*
pdata
)
{
switch_memory_pool_t
*
pool
;
switch_thread_data_t
*
td
;
struct
db_job
*
job
;
switch_core_new_memory_pool
(
&
pool
);
td
=
switch_core_alloc
(
pool
,
sizeof
(
*
td
));
job
=
switch_core_alloc
(
pool
,
sizeof
(
*
job
));
td
->
func
=
sql_in_thread
;
td
->
obj
=
job
;
job
->
sql
=
switch_core_strdup
(
pool
,
sql
);
job
->
qm
=
qm
;
if
(
callback
)
{
job
->
callback
=
callback
;
}
else
if
(
event_callback
)
{
job
->
event_callback
=
event_callback
;
}
job
->
pdata
=
pdata
;
job
->
pool
=
pool
;
return
td
;
}
SWITCH_DECLARE
(
void
)
switch_sql_queue_manger_execute_sql_callback
(
switch_sql_queue_manager_t
*
qm
,
const
char
*
sql
,
switch_core_db_callback_func_t
callback
,
void
*
pdata
)
{
switch_thread_data_t
*
td
;
if
((
td
=
new_job
(
qm
,
sql
,
callback
,
NULL
,
pdata
)))
{
switch_thread_pool_launch_thread
(
&
td
);
}
}
SWITCH_DECLARE
(
void
)
switch_sql_queue_manger_execute_sql_event_callback
(
switch_sql_queue_manager_t
*
qm
,
const
char
*
sql
,
switch_core_db_event_callback_func_t
callback
,
void
*
pdata
)
{
switch_thread_data_t
*
td
;
if
((
td
=
new_job
(
qm
,
sql
,
NULL
,
callback
,
pdata
)))
{
switch_thread_pool_launch_thread
(
&
td
);
}
}
SWITCH_DECLARE
(
int
)
switch_sql_queue_manager_size
(
switch_sql_queue_manager_t
*
qm
,
uint32_t
index
)
{
int
size
=
0
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论