Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
00cf5aed
提交
00cf5aed
authored
11月 02, 2011
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make auto unpark choose the one waiting the longest instead of the earliest ext val
上级
fe3e9356
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
45 行增加
和
0 行删除
+45
-0
mod_valet_parking.c
src/mod/applications/mod_valet_parking/mod_valet_parking.c
+45
-0
没有找到文件。
src/mod/applications/mod_valet_parking/mod_valet_parking.c
浏览文件 @
00cf5aed
...
...
@@ -46,6 +46,7 @@ typedef struct {
char
uuid
[
SWITCH_UUID_FORMATTED_LENGTH
+
1
];
time_t
timeout
;
int
bridged
;
time_t
start_time
;
}
valet_token_t
;
typedef
struct
{
...
...
@@ -153,6 +154,34 @@ static void check_timeouts(void)
}
static
int
find_longest
(
valet_lot_t
*
lot
,
int
min
,
int
max
)
{
switch_hash_index_t
*
i_hi
;
const
void
*
i_var
;
void
*
i_val
;
valet_token_t
*
token
;
int
longest
=
0
,
cur
=
0
,
longest_ext
=
0
;
time_t
now
=
switch_epoch_time_now
(
NULL
);
switch_mutex_lock
(
lot
->
mutex
);
for
(
i_hi
=
switch_hash_first
(
NULL
,
lot
->
hash
);
i_hi
;
i_hi
=
switch_hash_next
(
i_hi
))
{
int
i
;
switch_hash_this
(
i_hi
,
&
i_var
,
NULL
,
&
i_val
);
token
=
(
valet_token_t
*
)
i_val
;
cur
=
(
now
-
token
->
start_time
);
i
=
atoi
(
token
->
ext
);
if
(
cur
>
longest
&&
i
>=
min
&&
i
<=
max
)
{
longest
=
cur
;
longest_ext
=
i
;
}
}
switch_mutex_unlock
(
lot
->
mutex
);
return
longest_ext
;
}
static
valet_token_t
*
next_id
(
switch_core_session_t
*
session
,
valet_lot_t
*
lot
,
int
min
,
int
max
,
int
in
)
{
int
i
,
r
=
0
;
...
...
@@ -164,6 +193,20 @@ static valet_token_t *next_id(switch_core_session_t *session, valet_lot_t *lot,
}
switch_mutex_lock
(
globals
.
mutex
);
if
(
!
in
)
{
int
longest
=
find_longest
(
lot
,
min
,
max
);
if
(
longest
>
0
)
{
switch_snprintf
(
buf
,
sizeof
(
buf
),
"%d"
,
longest
);
switch_mutex_lock
(
lot
->
mutex
);
token
=
(
valet_token_t
*
)
switch_core_hash_find
(
lot
->
hash
,
buf
);
switch_mutex_unlock
(
lot
->
mutex
);
if
(
token
)
{
goto
end
;
}
}
}
for
(
i
=
min
;
(
i
<
max
||
max
==
0
);
i
++
)
{
switch_snprintf
(
buf
,
sizeof
(
buf
),
"%d"
,
i
);
switch_mutex_lock
(
lot
->
mutex
);
...
...
@@ -187,6 +230,7 @@ static valet_token_t *next_id(switch_core_session_t *session, valet_lot_t *lot,
switch_zmalloc
(
token
,
sizeof
(
*
token
));
switch_set_string
(
token
->
uuid
,
switch_core_session_get_uuid
(
session
));
switch_set_string
(
token
->
ext
,
buf
);
token
->
start_time
=
switch_epoch_time_now
(
NULL
);
switch_mutex_lock
(
lot
->
mutex
);
switch_core_hash_insert
(
lot
->
hash
,
buf
,
token
);
switch_mutex_unlock
(
lot
->
mutex
);
...
...
@@ -505,6 +549,7 @@ SWITCH_STANDARD_APP(valet_parking_function)
}
switch_set_string
(
token
->
uuid
,
switch_core_session_get_uuid
(
session
));
switch_set_string
(
token
->
ext
,
ext
);
token
->
start_time
=
switch_epoch_time_now
(
NULL
);
switch_mutex_lock
(
lot
->
mutex
);
switch_core_hash_insert
(
lot
->
hash
,
ext
,
token
);
switch_mutex_unlock
(
lot
->
mutex
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论