[Freeswitch-svn] [commit] r12225 - in freeswitch/trunk/src: . mod/languages/mod_perl mod/languages/mod_spidermonkey
FreeSWITCH SVN
anthm at freeswitch.org
Sat Feb 21 14:50:35 PST 2009
Author: anthm
Date: Sat Feb 21 16:50:35 2009
New Revision: 12225
Log:
fix some language issues and move media bug removal to hangup state
Modified:
freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.cpp
freeswitch/trunk/src/mod/languages/mod_perl/mod_perl.c
freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
freeswitch/trunk/src/switch_channel.c
freeswitch/trunk/src/switch_ivr_play_say.c
Modified: freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.cpp (original)
+++ freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.cpp Sat Feb 21 16:50:35 2009
@@ -214,7 +214,7 @@
HV *hash;
SV *this_sv;
char *code;
-
+
if (!(hash = get_hv("__dtmf", TRUE))) {
abort();
}
@@ -228,8 +228,8 @@
this_sv = newSV(strlen(str) + 1);
sv_setpv(this_sv, str);
hv_store(hash, "duration", 8, this_sv, 0);
-
- code = switch_mprintf("$__RV = %s($%s, 'dtmf', \\%%__dtmf, %s);", cb_function, suuid, switch_str_nil(cb_arg));
+
+ 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);
@@ -241,11 +241,25 @@
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 = '_';
+ }
+ }
- mod_perl_conjure_event(my_perl, event, "__Input_Event__");
-
- code = switch_mprintf("$__RV = %s($%s, 'event', $__Input_Event__, %s);", cb_function, suuid, switch_str_nil(cb_arg));
- Perl_eval_pv(my_perl, code, TRUE);
+ 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));
Modified: freeswitch/trunk/src/mod/languages/mod_perl/mod_perl.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_perl/mod_perl.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_perl/mod_perl.c Sat Feb 21 16:50:35 2009
@@ -140,7 +140,7 @@
return error;
}
-#define HACK_CLEAN_CODE "foreach my $kl(keys %main::) {undef($$kl) if (defined($$kl) && ($kl =~ /^\\w+[\\w\\d_]+$/))}"
+#define HACK_CLEAN_CODE "eval{foreach my $kl(keys %main::) {eval{undef($$kl);} if (defined($$kl) && ($kl =~ /^\\w+[\\w\\d_]+$/))}}"
static void destroy_perl(PerlInterpreter ** to_destroy)
{
@@ -434,18 +434,16 @@
char *account = switch_event_get_header(event, "message-account");
if (account) {
- char *path, *cmd;
-
- path = switch_mprintf("%s%smwi.pl", SWITCH_GLOBAL_dirs.script_dir, SWITCH_PATH_SEPARATOR);
- switch_assert(path != NULL);
+ char path[512], *cmd;
+ switch_snprintf(path, sizeof(path), "%s%smwi.pl", SWITCH_GLOBAL_dirs.script_dir, SWITCH_PATH_SEPARATOR);
+
if (switch_file_exists(path, NULL) == SWITCH_STATUS_SUCCESS) {
cmd = switch_mprintf("%s %s", path, account);
switch_assert(cmd != NULL);
perl_thread(cmd);
switch_safe_free(cmd);
}
- switch_safe_free(path);
}
}
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Sat Feb 21 16:50:35 2009
@@ -1100,11 +1100,26 @@
jsval ret, nval, *rval = &nval;
JSContext *cx = cb_state->cx;
JSObject *obj = cb_state->obj;
+ switch_uuid_t uuid;
+ char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
+ char var_name[SWITCH_UUID_FORMATTED_LENGTH + 25];
+ char *p;
METHOD_SANITY_CHECK();
jss->stack_depth++;
+
+ 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 = '_';
+ }
+ }
+
if (cb_state->jss_a && cb_state->jss_a->session && cb_state->jss_a->session == session) {
argv[argc++] = OBJECT_TO_JSVAL(cb_state->session_obj_a);
} else if (cb_state->jss_b && cb_state->jss_b->session && cb_state->jss_b->session == session) {
@@ -1116,7 +1131,7 @@
switch (itype) {
case SWITCH_INPUT_TYPE_EVENT:
if ((event = (switch_event_t *) input)) {
- if ((Event = new_js_event(event, "_XX_EVENT_XX_", cb_state->cx, cb_state->obj))) {
+ if ((Event = new_js_event(event, var_name, cb_state->cx, cb_state->obj))) {
argv[argc++] = STRING_TO_JSVAL(JS_NewStringCopyZ(cb_state->cx, "event"));
argv[argc++] = OBJECT_TO_JSVAL(Event);
}
@@ -1131,7 +1146,7 @@
switch_dtmf_t *dtmf = (switch_dtmf_t *) input;
if (dtmf) {
- if ((Event = new_js_dtmf(dtmf, "_XX_DTMF_XX_", cb_state->cx, cb_state->obj))) {
+ if ((Event = new_js_dtmf(dtmf, var_name, cb_state->cx, cb_state->obj))) {
argv[argc++] = STRING_TO_JSVAL(JS_NewStringCopyZ(cb_state->cx, "dtmf"));
argv[argc++] = OBJECT_TO_JSVAL(Event);
} else {
@@ -1175,11 +1190,12 @@
switch_file_handle_t *fh = cb_state->extra;
struct js_session *jss = cb_state->session_state;
+ switch_dtmf_t *wtfdtmf = (switch_dtmf_t *) input;
+
if ((status = js_common_callback(session, input, itype, buf, buflen)) != SWITCH_STATUS_SUCCESS) {
return status;
}
-
if ((ret = JS_GetStringBytes(JS_ValueToString(cb_state->cx, cb_state->ret)))) {
if (!strncasecmp(ret, "speed", 5)) {
char *p;
Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c (original)
+++ freeswitch/trunk/src/switch_channel.c Sat Feb 21 16:50:35 2009
@@ -397,6 +397,7 @@
SWITCH_DECLARE(void) switch_channel_flush_dtmf(switch_channel_t *channel)
{
void *pop;
+
switch_mutex_lock(channel->dtmf_mutex);
while (switch_queue_trypop(channel->dtmf_queue, &pop) == SWITCH_STATUS_SUCCESS) {
switch_safe_free(pop);
@@ -1562,6 +1563,7 @@
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_NOTICE, "Hangup %s [%s] [%s]\n",
channel->name, state_names[last_state], switch_channel_cause2str(channel->hangup_cause));
+ switch_core_media_bug_remove_all(channel->session);
switch_channel_set_variable(channel, "hangup_cause", switch_channel_cause2str(channel->hangup_cause));
switch_channel_presence(channel, "unavailable", switch_channel_cause2str(channel->hangup_cause), NULL);
Modified: freeswitch/trunk/src/switch_ivr_play_say.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_play_say.c (original)
+++ freeswitch/trunk/src/switch_ivr_play_say.c Sat Feb 21 16:50:35 2009
@@ -1059,6 +1059,8 @@
switch_channel_dequeue_dtmf(channel, &dtmf);
if (args->input_callback) {
status = args->input_callback(session, (void *) &dtmf, SWITCH_INPUT_TYPE_DTMF, args->buf, args->buflen);
+ printf("CORE %c %d\n", dtmf.digit, status);
+
} else {
*((char *) args->buf) = dtmf.digit;
status = SWITCH_STATUS_BREAK;
More information about the Freeswitch-svn
mailing list