Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
23fd8ebb
提交
23fd8ebb
authored
7月 02, 2010
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add optional exceptions to mod_distributor to list nodes to skip
上级
a7d8f866
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
36 行增加
和
10 行删除
+36
-10
mod_distributor.c
src/mod/applications/mod_distributor/mod_distributor.c
+36
-10
没有找到文件。
src/mod/applications/mod_distributor/mod_distributor.c
浏览文件 @
23fd8ebb
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
* Neal Horman <neal at wanlink dot com>
* Neal Horman <neal at wanlink dot com>
*
*
*
*
* mod_distributor.c --
Framework Demo Module
* mod_distributor.c --
Load distributor
*
*
*/
*/
#include <switch.h>
#include <switch.h>
...
@@ -240,14 +240,15 @@ static int reset_list(struct dist_list *list)
...
@@ -240,14 +240,15 @@ static int reset_list(struct dist_list *list)
return
0
;
return
0
;
}
}
static
struct
dist_node
*
find_next
(
struct
dist_list
*
list
)
static
struct
dist_node
*
find_next
(
struct
dist_list
*
list
,
int
etotal
,
char
**
exceptions
)
{
{
struct
dist_node
*
np
,
*
match
=
NULL
;
struct
dist_node
*
np
,
*
match
=
NULL
;
int
x
=
0
,
mx
=
0
;
int
x
=
0
,
mx
=
0
;
int
matches
=
0
,
loops
=
0
;
int
matches
=
0
,
loops
=
0
;
for
(;;)
{
for
(;;)
{
top:
if
(
++
loops
>
1000
)
{
if
(
++
loops
>
1000
)
{
break
;
break
;
}
}
...
@@ -259,7 +260,7 @@ static struct dist_node *find_next(struct dist_list *list)
...
@@ -259,7 +260,7 @@ static struct dist_node *find_next(struct dist_list *list)
match
=
NULL
;
match
=
NULL
;
for
(
np
=
list
->
nodes
;
np
;
np
=
np
->
next
)
{
for
(
np
=
list
->
nodes
;
np
;
np
=
np
->
next
)
{
if
(
np
->
cur_weight
<
list
->
target_weight
)
{
if
(
np
->
cur_weight
<
list
->
target_weight
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"%s %d/%d
\n
"
,
np
->
name
,
np
->
cur_weight
,
list
->
target_weight
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
10
,
"%s %d/%d
\n
"
,
np
->
name
,
np
->
cur_weight
,
list
->
target_weight
);
matches
++
;
matches
++
;
if
(
!
match
&&
x
>
list
->
last
)
{
if
(
!
match
&&
x
>
list
->
last
)
{
match
=
np
;
match
=
np
;
...
@@ -270,10 +271,23 @@ static struct dist_node *find_next(struct dist_list *list)
...
@@ -270,10 +271,23 @@ static struct dist_node *find_next(struct dist_list *list)
}
}
if
(
match
)
{
if
(
match
)
{
int
i
;
match
->
cur_weight
++
;
match
->
cur_weight
++
;
list
->
lastnode
=
match
;
list
->
lastnode
=
match
;
list
->
last
=
mx
;
list
->
last
=
mx
;
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Choose %s
\n
"
,
match
->
name
);
for
(
i
=
0
;
i
<
etotal
;
i
++
)
{
if
(
!
strcmp
(
match
->
name
,
exceptions
[
i
]))
{
if
(
matches
==
1
)
{
reset_list
(
list
);
}
goto
top
;
}
}
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG10
,
"Choose %s
\n
"
,
match
->
name
);
return
match
;
return
match
;
}
}
...
@@ -284,7 +298,7 @@ static struct dist_node *find_next(struct dist_list *list)
...
@@ -284,7 +298,7 @@ static struct dist_node *find_next(struct dist_list *list)
}
}
}
}
return
NULL
;
return
NULL
;
}
}
...
@@ -294,11 +308,21 @@ static char *dist_engine(const char *name)
...
@@ -294,11 +308,21 @@ static char *dist_engine(const char *name)
struct
dist_node
*
np
=
NULL
;
struct
dist_node
*
np
=
NULL
;
struct
dist_list
*
lp
;
struct
dist_list
*
lp
;
char
*
str
=
NULL
;
char
*
str
=
NULL
;
char
*
myname
=
strdup
(
name
);
char
*
except
;
int
argc
=
0
;
char
*
argv
[
100
]
=
{
0
};
if
((
except
=
strchr
(
myname
,
' '
)))
{
*
except
++
=
'\0'
;
argc
=
switch_split
(
except
,
' '
,
argv
);
}
switch_mutex_lock
(
globals
.
mod_lock
);
switch_mutex_lock
(
globals
.
mod_lock
);
for
(
lp
=
globals
.
list
;
lp
;
lp
=
lp
->
next
)
{
for
(
lp
=
globals
.
list
;
lp
;
lp
=
lp
->
next
)
{
if
(
!
strcasecmp
(
name
,
lp
->
name
))
{
if
(
!
strcasecmp
(
my
name
,
lp
->
name
))
{
np
=
find_next
(
lp
);
np
=
find_next
(
lp
,
argc
,
argv
);
break
;
break
;
}
}
}
}
...
@@ -308,6 +332,8 @@ static char *dist_engine(const char *name)
...
@@ -308,6 +332,8 @@ static char *dist_engine(const char *name)
}
}
switch_mutex_unlock
(
globals
.
mod_lock
);
switch_mutex_unlock
(
globals
.
mod_lock
);
free
(
myname
);
return
str
;
return
str
;
}
}
...
@@ -374,9 +400,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_distributor_load)
...
@@ -374,9 +400,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_distributor_load)
load_config
(
SWITCH_FALSE
);
load_config
(
SWITCH_FALSE
);
SWITCH_ADD_API
(
api_interface
,
"distributor"
,
"Distributor API"
,
distributor_function
,
"<list name>"
);
SWITCH_ADD_API
(
api_interface
,
"distributor"
,
"Distributor API"
,
distributor_function
,
"<list name>
[ <exception1> <exceptionN>]
"
);
SWITCH_ADD_API
(
api_interface
,
"distributor_ctl"
,
"Distributor API"
,
distributor_ctl_function
,
"[reload]"
);
SWITCH_ADD_API
(
api_interface
,
"distributor_ctl"
,
"Distributor API"
,
distributor_ctl_function
,
"[reload]"
);
SWITCH_ADD_APP
(
app_interface
,
"distributor"
,
"Distributor APP"
,
"Distributor APP"
,
distributor_exec
,
"<list name>"
,
SWITCH_ADD_APP
(
app_interface
,
"distributor"
,
"Distributor APP"
,
"Distributor APP"
,
distributor_exec
,
"<list name>
[ <exception1> <exceptionN>]
"
,
SAF_SUPPORT_NOMEDIA
|
SAF_ROUTING_EXEC
);
SAF_SUPPORT_NOMEDIA
|
SAF_ROUTING_EXEC
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论