Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
68d1c32a
提交
68d1c32a
authored
9月 07, 2010
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FSCORE-668
上级
e3eff816
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
28 行增加
和
19 行删除
+28
-19
switch_core_sqldb.c
src/switch_core_sqldb.c
+28
-19
没有找到文件。
src/switch_core_sqldb.c
浏览文件 @
68d1c32a
...
@@ -35,6 +35,8 @@
...
@@ -35,6 +35,8 @@
#include <switch.h>
#include <switch.h>
#include "private/switch_core_pvt.h"
#include "private/switch_core_pvt.h"
#define SQLLEN 32768
static
struct
{
static
struct
{
switch_cache_db_handle_t
*
event_db
;
switch_cache_db_handle_t
*
event_db
;
switch_queue_t
*
sql_queue
[
2
];
switch_queue_t
*
sql_queue
[
2
];
...
@@ -537,7 +539,7 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql(switch_cache_db_hand
...
@@ -537,7 +539,7 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql(switch_cache_db_hand
switch
(
dbh
->
type
)
{
switch
(
dbh
->
type
)
{
default
:
default
:
{
{
status
=
switch_cache_db_execute_sql_chunked
(
dbh
,
(
char
*
)
sql
,
32768
,
err
);
status
=
switch_cache_db_execute_sql_chunked
(
dbh
,
(
char
*
)
sql
,
SQLLEN
,
err
);
}
}
break
;
break
;
}
}
...
@@ -845,7 +847,7 @@ SWITCH_DECLARE(switch_bool_t) switch_cache_db_test_reactive(switch_cache_db_hand
...
@@ -845,7 +847,7 @@ SWITCH_DECLARE(switch_bool_t) switch_cache_db_test_reactive(switch_cache_db_hand
#define SQLLEN 1024 * 1024
static
void
*
SWITCH_THREAD_FUNC
switch_core_sql_thread
(
switch_thread_t
*
thread
,
void
*
obj
)
static
void
*
SWITCH_THREAD_FUNC
switch_core_sql_thread
(
switch_thread_t
*
thread
,
void
*
obj
)
{
{
void
*
pop
;
void
*
pop
;
...
@@ -853,13 +855,14 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread,
...
@@ -853,13 +855,14 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread,
uint8_t
trans
=
0
,
nothing_in_queue
=
0
;
uint8_t
trans
=
0
,
nothing_in_queue
=
0
;
uint32_t
target
=
100000
;
uint32_t
target
=
100000
;
switch_size_t
len
=
0
,
sql_len
=
SQLLEN
;
switch_size_t
len
=
0
,
sql_len
=
SQLLEN
;
char
*
tmp
,
*
sqlbuf
=
(
char
*
)
malloc
(
sql_len
);
char
*
sqlbuf
=
(
char
*
)
malloc
(
sql_len
);
char
*
sql
;
char
*
sql
=
NULL
;
switch_size_t
newlen
;
switch_size_t
newlen
;
int
lc
=
0
;
int
lc
=
0
;
uint32_t
loops
=
0
,
sec
=
0
;
uint32_t
loops
=
0
,
sec
=
0
;
uint32_t
l1
=
1000
;
uint32_t
l1
=
1000
;
uint32_t
sanity
=
120
;
uint32_t
sanity
=
120
;
int
item_remained
=
0
;
switch_assert
(
sqlbuf
);
switch_assert
(
sqlbuf
);
...
@@ -897,10 +900,17 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread,
...
@@ -897,10 +900,17 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread,
continue
;
continue
;
}
}
if
(
switch_queue_trypop
(
sql_manager
.
sql_queue
[
0
],
&
pop
)
==
SWITCH_STATUS_SUCCESS
||
//printf("SIZE %d %d\n", switch_queue_size(sql_manager.sql_queue[0]), switch_queue_size(sql_manager.sql_queue[1]));
if
(
item_remained
||
switch_queue_trypop
(
sql_manager
.
sql_queue
[
0
],
&
pop
)
==
SWITCH_STATUS_SUCCESS
||
switch_queue_trypop
(
sql_manager
.
sql_queue
[
1
],
&
pop
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_queue_trypop
(
sql_manager
.
sql_queue
[
1
],
&
pop
)
==
SWITCH_STATUS_SUCCESS
)
{
sql
=
(
char
*
)
pop
;
if
(
item_remained
)
{
item_remained
=
0
;
}
else
{
sql
=
(
char
*
)
pop
;
}
if
(
sql
)
{
if
(
sql
)
{
newlen
=
strlen
(
sql
)
+
2
;
newlen
=
strlen
(
sql
)
+
2
;
...
@@ -911,20 +921,18 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread,
...
@@ -911,20 +921,18 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread,
/* ignore abnormally large strings sql strings as potential buffer overflow */
/* ignore abnormally large strings sql strings as potential buffer overflow */
if
(
newlen
<
SQLLEN
)
{
if
(
newlen
<
SQLLEN
)
{
itterations
++
;
itterations
++
;
if
(
len
+
newlen
>
sql_len
)
{
sql_len
=
len
+
SQLLEN
;
if
(
len
+
newlen
<
sql_len
)
{
if
(
!
(
tmp
=
realloc
(
sqlbuf
,
sql_len
)))
{
sprintf
(
sqlbuf
+
len
,
"%s;
\n
"
,
sql
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"SQL thread ending on mem err
\n
"
);
len
+=
newlen
;
abort
();
}
else
{
break
;
item_remained
=
1
;
}
sqlbuf
=
tmp
;
}
}
sprintf
(
sqlbuf
+
len
,
"%s;
\n
"
,
sql
);
len
+=
newlen
;
}
}
free
(
sql
);
if
(
!
item_remained
)
{
free
(
sql
);
}
}
else
{
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_NOTICE
,
"SQL thread ending
\n
"
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_NOTICE
,
"SQL thread ending
\n
"
);
break
;
break
;
...
@@ -934,7 +942,8 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread,
...
@@ -934,7 +942,8 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread,
}
}
if
(
trans
&&
((
itterations
==
target
)
||
(
nothing_in_queue
&&
++
lc
>=
500
)))
{
if
((
item_remained
||
(
trans
&&
((
itterations
==
target
)
||
(
nothing_in_queue
&&
++
lc
>=
500
))))
&&
(
sql_manager
.
event_db
->
native_handle
.
core_db_dbh
))
{
if
(
switch_cache_db_persistant_execute_trans
(
sql_manager
.
event_db
,
sqlbuf
,
1
)
!=
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_cache_db_persistant_execute_trans
(
sql_manager
.
event_db
,
sqlbuf
,
1
)
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"SQL thread unable to commit transaction, records lost!
\n
"
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"SQL thread unable to commit transaction, records lost!
\n
"
);
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论