Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
33efc5ee
提交
33efc5ee
authored
3月 30, 2007
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tweaks
git-svn-id:
http://svn.freeswitch.org/svn/freeswitch/trunk@4805
d0543943-73ff-0310-b7d9-9358b9ac24b2
上级
324f6b00
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
68 行增加
和
17 行删除
+68
-17
switch_scheduler.h
src/include/switch_scheduler.h
+4
-4
switch_types.h
src/include/switch_types.h
+2
-1
switch_utils.h
src/include/switch_utils.h
+13
-0
mod_commands.c
src/mod/applications/mod_commands/mod_commands.c
+29
-2
switch_core.c
src/switch_core.c
+1
-1
switch_scheduler.c
src/switch_scheduler.c
+19
-9
没有找到文件。
src/include/switch_scheduler.h
浏览文件 @
33efc5ee
...
@@ -67,16 +67,16 @@ SWITCH_DECLARE(uint32_t) switch_scheduler_add_task(time_t task_runtime,
...
@@ -67,16 +67,16 @@ SWITCH_DECLARE(uint32_t) switch_scheduler_add_task(time_t task_runtime,
/*!
/*!
\brief Delete a scheduled task
\brief Delete a scheduled task
\param task_id the id of the task
\param task_id the id of the task
\return
SWITCH_STATUS_SUCCESS if the task was deleted.
\return
the number of jobs deleted
*/
*/
SWITCH_DECLARE
(
switch_status
_t
)
switch_scheduler_del_task_id
(
uint32_t
task_id
);
SWITCH_DECLARE
(
uint32
_t
)
switch_scheduler_del_task_id
(
uint32_t
task_id
);
/*!
/*!
\brief Delete a scheduled task based on the group name
\brief Delete a scheduled task based on the group name
\param group the group name
\param group the group name
\return
SWITCH_STATUS_SUCCESS if any tasks were
deleted
\return
the number of jobs
deleted
*/
*/
SWITCH_DECLARE
(
switch_status
_t
)
switch_scheduler_del_task_group
(
char
*
group
);
SWITCH_DECLARE
(
uint32
_t
)
switch_scheduler_del_task_group
(
char
*
group
);
/*!
/*!
...
...
src/include/switch_types.h
浏览文件 @
33efc5ee
...
@@ -158,7 +158,8 @@ typedef enum {
...
@@ -158,7 +158,8 @@ typedef enum {
typedef
enum
{
typedef
enum
{
SSHF_NONE
=
0
,
SSHF_NONE
=
0
,
SSHF_OWN_THREAD
=
(
1
<<
0
),
SSHF_OWN_THREAD
=
(
1
<<
0
),
SSHF_FREE_ARG
=
(
1
<<
1
)
SSHF_FREE_ARG
=
(
1
<<
1
),
SSHF_NO_DEL
=
(
1
<<
2
)
}
switch_scheduler_flag_t
;
}
switch_scheduler_flag_t
;
typedef
enum
{
typedef
enum
{
...
...
src/include/switch_utils.h
浏览文件 @
33efc5ee
...
@@ -54,6 +54,19 @@ SWITCH_BEGIN_EXTERN_C
...
@@ -54,6 +54,19 @@ SWITCH_BEGIN_EXTERN_C
#else
#else
#define switch_is_file_path(file) ((*file == '/') || strstr(file, SWITCH_URL_SEPARATOR))
#define switch_is_file_path(file) ((*file == '/') || strstr(file, SWITCH_URL_SEPARATOR))
#endif
#endif
static
inline
switch_bool_t
switch_is_digit_string
(
char
*
s
)
{
while
(
s
&&
*
s
)
{
if
(
*
s
<
48
||
*
s
>
57
)
{
return
SWITCH_FALSE
;
}
s
++
;
}
return
SWITCH_TRUE
;
}
/*!
/*!
\brief Evaluate the truthfullness of a string expression
\brief Evaluate the truthfullness of a string expression
\param expr a string expression
\param expr a string expression
...
...
src/mod/applications/mod_commands/mod_commands.c
浏览文件 @
33efc5ee
...
@@ -705,6 +705,25 @@ static void sch_api_callback(switch_scheduler_task_t *task)
...
@@ -705,6 +705,25 @@ static void sch_api_callback(switch_scheduler_task_t *task)
switch_safe_free
(
stream
.
data
);
switch_safe_free
(
stream
.
data
);
}
}
static
switch_status_t
sched_del_function
(
char
*
cmd
,
switch_core_session_t
*
isession
,
switch_stream_handle_t
*
stream
)
{
uint32_t
cnt
=
0
;
if
(
switch_is_digit_string
(
cmd
))
{
int64_t
tmp
;
tmp
=
(
uint32_t
)
atoi
(
cmd
);
if
(
tmp
>
0
)
{
cnt
=
switch_scheduler_del_task_id
((
uint32_t
)
tmp
);
}
}
else
{
cnt
=
switch_scheduler_del_task_group
(
cmd
);
}
stream
->
write_function
(
stream
,
"DELETED: %u
\n
"
,
cnt
);
return
SWITCH_STATUS_SUCCESS
;
}
static
switch_status_t
sched_api_function
(
char
*
cmd
,
switch_core_session_t
*
isession
,
switch_stream_handle_t
*
stream
)
static
switch_status_t
sched_api_function
(
char
*
cmd
,
switch_core_session_t
*
isession
,
switch_stream_handle_t
*
stream
)
{
{
char
*
tm
=
NULL
,
*
dcmd
,
*
group
;
char
*
tm
=
NULL
,
*
dcmd
,
*
group
;
...
@@ -729,7 +748,7 @@ static switch_status_t sched_api_function(char *cmd, switch_core_session_t *ises
...
@@ -729,7 +748,7 @@ static switch_status_t sched_api_function(char *cmd, switch_core_session_t *ises
}
}
id
=
switch_scheduler_add_task
(
when
,
sch_api_callback
,
(
char
*
)
__SWITCH_FUNC__
,
group
,
0
,
strdup
(
dcmd
),
SSHF_FREE_ARG
);
id
=
switch_scheduler_add_task
(
when
,
sch_api_callback
,
(
char
*
)
__SWITCH_FUNC__
,
group
,
0
,
strdup
(
dcmd
),
SSHF_FREE_ARG
);
stream
->
write_function
(
stream
,
"A
dded task %u for command [%s] group [%s]
\n
"
,
id
,
dcmd
,
group
);
stream
->
write_function
(
stream
,
"A
DDED: %u
\n
"
,
id
);
goto
good
;
goto
good
;
}
}
}
}
...
@@ -895,12 +914,20 @@ static switch_status_t help_function(char *cmd, switch_core_session_t *session,
...
@@ -895,12 +914,20 @@ static switch_status_t help_function(char *cmd, switch_core_session_t *session,
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
static
switch_api_interface_t
sched_del_api_interface
=
{
/*.interface_name */
"sched_del"
,
/*.desc */
"Delete a Scheduled task"
,
/*.function */
sched_del_function
,
/*.syntax */
"<task_id>|<group_id>"
,
/*.next */
NULL
};
static
switch_api_interface_t
sched_api_api_interface
=
{
static
switch_api_interface_t
sched_api_api_interface
=
{
/*.interface_name */
"sched_api"
,
/*.interface_name */
"sched_api"
,
/*.desc */
"Schedule an api command"
,
/*.desc */
"Schedule an api command"
,
/*.function */
sched_api_function
,
/*.function */
sched_api_function
,
/*.syntax */
"[+]<time> <group_name> <command_string>"
,
/*.syntax */
"[+]<time> <group_name> <command_string>"
,
/*.next */
NULL
/*.next */
&
sched_del_api_interface
};
};
static
switch_api_interface_t
sched_transfer_api_interface
=
{
static
switch_api_interface_t
sched_transfer_api_interface
=
{
...
...
src/switch_core.c
浏览文件 @
33efc5ee
...
@@ -489,7 +489,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(char *console, const char **err
...
@@ -489,7 +489,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(char *console, const char **err
switch_scheduler_task_thread_start
();
switch_scheduler_task_thread_start
();
runtime
.
initiated
=
switch_time_now
();
runtime
.
initiated
=
switch_time_now
();
switch_scheduler_add_task
(
time
(
NULL
),
heartbeat_callback
,
"heartbeat"
,
"core"
,
0
,
NULL
,
SSHF_NONE
);
switch_scheduler_add_task
(
time
(
NULL
),
heartbeat_callback
,
"heartbeat"
,
"core"
,
0
,
NULL
,
SSHF_NONE
|
SSHF_NO_DEL
);
switch_uuid_get
(
&
uuid
);
switch_uuid_get
(
&
uuid
);
...
...
src/switch_scheduler.c
浏览文件 @
33efc5ee
...
@@ -187,15 +187,20 @@ SWITCH_DECLARE(uint32_t) switch_scheduler_add_task(time_t task_runtime,
...
@@ -187,15 +187,20 @@ SWITCH_DECLARE(uint32_t) switch_scheduler_add_task(time_t task_runtime,
return
container
->
task
.
task_id
;
return
container
->
task
.
task_id
;
}
}
SWITCH_DECLARE
(
switch_status
_t
)
switch_scheduler_del_task_id
(
uint32_t
task_id
)
SWITCH_DECLARE
(
uint32
_t
)
switch_scheduler_del_task_id
(
uint32_t
task_id
)
{
{
switch_scheduler_task_container_t
*
tp
;
switch_scheduler_task_container_t
*
tp
;
switch_status_t
status
=
SWITCH_STATUS_FALSE
;
switch_event_t
*
event
;
switch_event_t
*
event
;
uint32_t
delcnt
=
0
;
switch_mutex_lock
(
globals
.
task_mutex
);
switch_mutex_lock
(
globals
.
task_mutex
);
for
(
tp
=
globals
.
task_list
;
tp
;
tp
=
tp
->
next
)
{
for
(
tp
=
globals
.
task_list
;
tp
;
tp
=
tp
->
next
)
{
if
(
tp
->
task
.
task_id
==
task_id
)
{
if
(
tp
->
task
.
task_id
==
task_id
)
{
if
(
switch_test_flag
(
tp
,
SSHF_NO_DEL
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"Attempt made to delete undeleteable task #%u (group %s)
\n
"
,
tp
->
task
.
task_id
,
tp
->
task
.
group
);
break
;
}
tp
->
destroyed
++
;
tp
->
destroyed
++
;
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_DEL_SCHEDULE
)
==
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_DEL_SCHEDULE
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Task-ID"
,
"%u"
,
tp
->
task
.
task_id
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Task-ID"
,
"%u"
,
tp
->
task
.
task_id
);
...
@@ -204,24 +209,29 @@ SWITCH_DECLARE(switch_status_t) switch_scheduler_del_task_id(uint32_t task_id)
...
@@ -204,24 +209,29 @@ SWITCH_DECLARE(switch_status_t) switch_scheduler_del_task_id(uint32_t task_id)
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Task-Runtime"
,
"%"
SWITCH_INT64_T_FMT
,
tp
->
task
.
runtime
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Task-Runtime"
,
"%"
SWITCH_INT64_T_FMT
,
tp
->
task
.
runtime
);
switch_event_fire
(
&
event
);
switch_event_fire
(
&
event
);
}
}
status
=
SWITCH_STATUS_SUCCESS
;
delcnt
++
;
break
;
break
;
}
}
}
}
switch_mutex_unlock
(
globals
.
task_mutex
);
switch_mutex_unlock
(
globals
.
task_mutex
);
return
status
;
return
delcnt
;
}
}
SWITCH_DECLARE
(
switch_status
_t
)
switch_scheduler_del_task_group
(
char
*
group
)
SWITCH_DECLARE
(
uint32
_t
)
switch_scheduler_del_task_group
(
char
*
group
)
{
{
switch_scheduler_task_container_t
*
tp
;
switch_scheduler_task_container_t
*
tp
;
switch_status_t
status
=
SWITCH_STATUS_FALSE
;
switch_event_t
*
event
;
switch_event_t
*
event
;
uint32_t
delcnt
=
0
;
switch_mutex_lock
(
globals
.
task_mutex
);
switch_mutex_lock
(
globals
.
task_mutex
);
for
(
tp
=
globals
.
task_list
;
tp
;
tp
=
tp
->
next
)
{
for
(
tp
=
globals
.
task_list
;
tp
;
tp
=
tp
->
next
)
{
if
(
!
strcmp
(
tp
->
task
.
group
,
group
))
{
if
(
!
switch_strlen_zero
(
group
)
&&
!
strcmp
(
tp
->
task
.
group
,
group
))
{
if
(
switch_test_flag
(
tp
,
SSHF_NO_DEL
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"Attempt made to delete undeleteable task #%u (group %s)
\n
"
,
tp
->
task
.
task_id
,
group
);
continue
;
}
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_DEL_SCHEDULE
)
==
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_DEL_SCHEDULE
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Task-ID"
,
"%u"
,
tp
->
task
.
task_id
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Task-ID"
,
"%u"
,
tp
->
task
.
task_id
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Task-Desc"
,
"%s"
,
tp
->
desc
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Task-Desc"
,
"%s"
,
tp
->
desc
);
...
@@ -230,12 +240,12 @@ SWITCH_DECLARE(switch_status_t) switch_scheduler_del_task_group(char *group)
...
@@ -230,12 +240,12 @@ SWITCH_DECLARE(switch_status_t) switch_scheduler_del_task_group(char *group)
switch_event_fire
(
&
event
);
switch_event_fire
(
&
event
);
}
}
tp
->
destroyed
++
;
tp
->
destroyed
++
;
status
=
SWITCH_STATUS_SUCCESS
;
delcnt
++
;
}
}
}
}
switch_mutex_unlock
(
globals
.
task_mutex
);
switch_mutex_unlock
(
globals
.
task_mutex
);
return
status
;
return
delcnt
;
}
}
SWITCH_DECLARE
(
void
)
switch_scheduler_task_thread_start
(
void
)
SWITCH_DECLARE
(
void
)
switch_scheduler_task_thread_start
(
void
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论