Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
33238099
提交
33238099
authored
7月 19, 2018
作者:
Anthony Minessale
提交者:
Muteesa Fred
7月 24, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-11259: [mod_perl] mod_perl tweaks #resolve
上级
9d0ad92d
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
77 行增加
和
54 行删除
+77
-54
freeswitch_perl.cpp
src/mod/languages/mod_perl/freeswitch_perl.cpp
+70
-54
freeswitch_perl.h
src/mod/languages/mod_perl/freeswitch_perl.h
+3
-0
mod_perl.c
src/mod/languages/mod_perl/mod_perl.c
+4
-0
没有找到文件。
src/mod/languages/mod_perl/freeswitch_perl.cpp
浏览文件 @
33238099
...
...
@@ -16,6 +16,8 @@ Session::Session():CoreSession()
Session
::
Session
(
char
*
uuid
,
CoreSession
*
a_leg
)
:
CoreSession
(
uuid
,
a_leg
)
{
init_me
();
switch_mutex_init
(
&
callback_mutex
,
SWITCH_MUTEX_NESTED
,
switch_core_session_get_pool
(
session
));
if
(
session
&&
allocated
)
{
suuid
=
switch_core_session_sprintf
(
session
,
"main::uuid_%s
\n
"
,
switch_core_session_get_uuid
(
session
));
for
(
char
*
p
=
suuid
;
p
&&
*
p
;
p
++
)
{
...
...
@@ -32,6 +34,8 @@ Session::Session(char *uuid, CoreSession *a_leg):CoreSession(uuid, a_leg)
Session
::
Session
(
switch_core_session_t
*
new_session
)
:
CoreSession
(
new_session
)
{
init_me
();
switch_mutex_init
(
&
callback_mutex
,
SWITCH_MUTEX_NESTED
,
switch_core_session_get_pool
(
session
));
if
(
session
)
{
suuid
=
switch_core_session_sprintf
(
session
,
"main::uuid_%s
\n
"
,
switch_core_session_get_uuid
(
session
));
for
(
char
*
p
=
suuid
;
p
&&
*
p
;
p
++
)
{
...
...
@@ -52,6 +56,10 @@ void Session::destroy(void)
return
;
}
switch_mutex_lock
(
callback_mutex
);
destroying
=
1
;
switch_mutex_unlock
(
callback_mutex
);
if
(
session
)
{
if
(
!
channel
)
{
channel
=
switch_core_session_get_channel
(
session
);
...
...
@@ -216,71 +224,79 @@ void Session::setInputCallback(char *cbfunc, char *funcargs)
switch_status_t
Session
::
run_dtmf_callback
(
void
*
input
,
switch_input_type_t
itype
)
{
switch_status_t
status
=
SWITCH_STATUS_SUCCESS
;
if
(
!
getPERL
())
{
return
SWITCH_STATUS_FALSE
;;
}
switch
(
itype
)
{
case
SWITCH_INPUT_TYPE_DTMF
:
{
switch_dtmf_t
*
dtmf
=
(
switch_dtmf_t
*
)
input
;
char
str
[
32
]
=
""
;
int
arg_count
=
2
;
HV
*
hash
;
SV
*
this_sv
;
char
*
code
;
if
(
!
(
hash
=
get_hv
(
"__dtmf"
,
TRUE
)))
{
abort
();
}
switch_mutex_lock
(
callback_mutex
);
if
(
!
destroying
)
{
switch
(
itype
)
{
case
SWITCH_INPUT_TYPE_DTMF
:
{
switch_dtmf_t
*
dtmf
=
(
switch_dtmf_t
*
)
input
;
char
str
[
32
]
=
""
;
int
arg_count
=
2
;
HV
*
hash
;
SV
*
this_sv
;
char
*
code
;
if
(
!
(
hash
=
get_hv
(
"__dtmf"
,
TRUE
)))
{
abort
();
}
str
[
0
]
=
dtmf
->
digit
;
this_sv
=
newSV
(
strlen
(
str
)
+
1
);
sv_setpv
(
this_sv
,
str
);
hv_store
(
hash
,
"digit"
,
5
,
this_sv
,
0
);
str
[
0
]
=
dtmf
->
digit
;
this_sv
=
newSV
(
strlen
(
str
)
+
1
);
sv_setpv
(
this_sv
,
str
);
hv_store
(
hash
,
"digit"
,
5
,
this_sv
,
0
);
switch_snprintf
(
str
,
sizeof
(
str
),
"%d"
,
dtmf
->
duration
);
this_sv
=
newSV
(
strlen
(
str
)
+
1
);
sv_setpv
(
this_sv
,
str
);
hv_store
(
hash
,
"duration"
,
8
,
this_sv
,
0
);
switch_snprintf
(
str
,
sizeof
(
str
),
"%d"
,
dtmf
->
duration
);
this_sv
=
newSV
(
strlen
(
str
)
+
1
);
sv_setpv
(
this_sv
,
str
);
hv_store
(
hash
,
"duration"
,
8
,
this_sv
,
0
);
code
=
switch_mprintf
(
"eval { $__RV = &%s($%s, 'dtmf',
\\
%%__dtmf, %s);};"
,
cb_function
,
suuid
,
switch_str_nil
(
cb_arg
));
Perl_eval_pv
(
my_perl
,
code
,
FALSE
);
free
(
code
);
code
=
switch_mprintf
(
"eval { $__RV = &%s($%s, 'dtmf',
\\
%%__dtmf, %s);};"
,
cb_function
,
suuid
,
switch_str_nil
(
cb_arg
));
Perl_eval_pv
(
my_perl
,
code
,
FALSE
);
free
(
code
);
return
process_callback_result
(
SvPV
(
get_sv
(
"__RV"
,
TRUE
),
n_a
));
}
break
;
case
SWITCH_INPUT_TYPE_EVENT
:
{
switch_event_t
*
event
=
(
switch_event_t
*
)
input
;
int
arg_count
=
2
;
char
*
code
;
switch_uuid_t
uuid
;
char
uuid_str
[
SWITCH_UUID_FORMATTED_LENGTH
+
1
];
char
var_name
[
SWITCH_UUID_FORMATTED_LENGTH
+
25
];
char
*
p
;
switch_uuid_get
(
&
uuid
);
switch_uuid_format
(
uuid_str
,
&
uuid
);
switch_snprintf
(
var_name
,
sizeof
(
var_name
),
"main::__event_%s"
,
uuid_str
);
for
(
p
=
var_name
;
p
&&
*
p
;
p
++
)
{
if
(
*
p
==
'-'
)
{
*
p
=
'_'
;
}
status
=
process_callback_result
(
SvPV
(
get_sv
(
"__RV"
,
TRUE
),
n_a
));
}
break
;
case
SWITCH_INPUT_TYPE_EVENT
:
{
switch_event_t
*
event
=
(
switch_event_t
*
)
input
;
int
arg_count
=
2
;
char
*
code
;
switch_uuid_t
uuid
;
char
uuid_str
[
SWITCH_UUID_FORMATTED_LENGTH
+
1
]
=
""
;
char
var_name
[
SWITCH_UUID_FORMATTED_LENGTH
+
25
]
=
""
;
char
*
p
;
switch_uuid_get
(
&
uuid
);
switch_uuid_format
(
uuid_str
,
&
uuid
);
switch_snprintf
(
var_name
,
sizeof
(
var_name
),
"__event_%s"
,
uuid_str
);
for
(
p
=
var_name
;
p
&&
*
p
;
p
++
)
{
if
(
*
p
==
'-'
)
{
*
p
=
'_'
;
}
}
mod_perl_conjure_event
(
my_perl
,
event
,
var_name
);
code
=
switch_mprintf
(
"eval {$__RV = &%s($%s, 'event', $%s, '%s');};$%s = undef;"
,
cb_function
,
suuid
,
var_name
,
switch_str_nil
(
cb_arg
),
var_name
);
Perl_eval_pv
(
my_perl
,
code
,
FALSE
);
free
(
code
);
mod_perl_conjure_event
(
my_perl
,
event
,
var_name
);
code
=
switch_mprintf
(
"eval {$__RV = &%s($%s, 'event', $%s, '%s');};$%s = undef;"
,
cb_function
,
suuid
,
var_name
,
switch_str_nil
(
cb_arg
),
var_name
);
Perl_eval_pv
(
my_perl
,
code
,
FALSE
);
free
(
code
);
return
process_callback_result
(
SvPV
(
get_sv
(
"__RV"
,
TRUE
),
n_a
));
status
=
process_callback_result
(
SvPV
(
get_sv
(
"__RV"
,
TRUE
),
n_a
));
}
break
;
}
break
;
}
return
SWITCH_STATUS_SUCCESS
;
switch_mutex_unlock
(
callback_mutex
);
return
status
;
}
src/mod/languages/mod_perl/freeswitch_perl.h
浏览文件 @
33238099
...
...
@@ -41,6 +41,9 @@ namespace PERL {
void
unsetInputCallback
(
void
);
void
setHangupHook
(
char
*
func
,
char
*
arg
=
NULL
);
bool
ready
();
switch_mutex_t
*
callback_mutex
;
int
destroying
=
0
;
int
event_idx
=
0
;
char
*
suuid
;
char
*
cb_function
;
char
*
cb_arg
;
...
...
src/mod/languages/mod_perl/mod_perl.c
浏览文件 @
33238099
...
...
@@ -143,7 +143,11 @@ static int perl_parse_and_execute(PerlInterpreter * my_perl, char *input_code, c
return
error
;
}
#ifdef DEBUG_PERL
#define HACK_CLEAN_CODE "eval{foreach my $kl(keys %main::) {eval{print qq'DEBUG: ' . $kl . '/' . $$kl . '/' . $$$kl . qq'\n';undef($$kl);} if (defined($$kl) && ($kl =~ /^\\w+[\\w\\d_]+$/))}}"
#else
#define HACK_CLEAN_CODE "eval{foreach my $kl(keys %main::) {eval{undef($$kl);} if (defined($$kl) && ($kl =~ /^\\w+[\\w\\d_]+$/))}}"
#endif
static
void
destroy_perl
(
PerlInterpreter
**
to_destroy
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论