<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][15919] </title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=15919">15919</a></dd>
<dt>Author</dt> <dd>anthm</dd>
<dt>Date</dt> <dd>2009-12-11 15:51:10 -0600 (Fri, 11 Dec 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre><a href="http://jira.freeswitch.org/browse/MODAPP-376">MODAPP-376</a> 3rd time's a charm</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_dptoolsmod_dptoolsc">freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_sessionc">freeswitch/trunk/src/switch_core_session.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_ivrc">freeswitch/trunk/src/switch_ivr.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_ivr_bridgec">freeswitch/trunk/src/switch_ivr_bridge.c</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunksrcmodapplicationsmod_dptoolsmod_dptoolsc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (15918 => 15919)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c        2009-12-11 21:50:29 UTC (rev 15918)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c        2009-12-11 21:51:10 UTC (rev 15919)
</span><span class="lines">@@ -1578,31 +1578,40 @@
</span><span class="cx">         switch_channel_clear_flag(peer_channel, CF_INNER_BRIDGE);
</span><span class="cx">         switch_channel_clear_flag(channel, CF_INNER_BRIDGE);
</span><span class="cx">
</span><del>-        if (switch_channel_down(peer_channel)) {
</del><ins>+        if (zstr(bond) && switch_channel_down(peer_channel)) {
</ins><span class="cx">                 switch_core_session_rwunlock(peer_session);
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (bond) {
</span><span class="cx">                 char buf[128] = "";
</span><ins>+                int br = 0;
</ins><span class="cx">
</span><del>-                if (!switch_channel_ready(channel)) {
-                        switch_ivr_uuid_bridge(switch_core_session_get_uuid(peer_session), bond);
-                } else if ((b_session = switch_core_session_locate(bond))) {
-                        switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
-                        switch_snprintf(buf, sizeof(buf), "%s %s", switch_core_session_get_uuid(peer_session), switch_core_session_get_uuid(session));
-                        switch_channel_set_variable(b_channel, "xfer_uuids", buf);
</del><ins>+                switch_channel_set_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE, bond);
</ins><span class="cx">
</span><del>-                        switch_snprintf(buf, sizeof(buf), "%s %s", switch_core_session_get_uuid(peer_session), bond);
-                        switch_channel_set_variable(channel, "xfer_uuids", buf);
</del><ins>+                if (!switch_channel_down(peer_channel)) {
+                        if (!switch_channel_ready(channel)) {
+                                switch_ivr_uuid_bridge(switch_core_session_get_uuid(peer_session), bond);
+                                br++;
+                        } else if ((b_session = switch_core_session_locate(bond))) {
+                                switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
+                                switch_snprintf(buf, sizeof(buf), "%s %s", switch_core_session_get_uuid(peer_session), switch_core_session_get_uuid(session));
+                                switch_channel_set_variable(b_channel, "xfer_uuids", buf);
+                                
+                                switch_snprintf(buf, sizeof(buf), "%s %s", switch_core_session_get_uuid(peer_session), bond);
+                                switch_channel_set_variable(channel, "xfer_uuids", buf);
+                                
+                                switch_core_event_hook_add_state_change(session, hanguphook);
+                                switch_core_event_hook_add_state_change(b_session, hanguphook);
+                                
+                                switch_core_session_rwunlock(b_session);
+                        }
+                }
</ins><span class="cx">
</span><del>-                        switch_core_event_hook_add_state_change(session, hanguphook);
-                        switch_core_event_hook_add_state_change(b_session, hanguphook);
-
-                        switch_core_session_rwunlock(b_session);
</del><ins>+                if (!br) {
+                        switch_ivr_uuid_bridge(switch_core_session_get_uuid(session), bond);
</ins><span class="cx">                 }
</span><del>-
-                switch_channel_set_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE, bond);
</del><ins>+                
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_core_session_rwunlock(peer_session);
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_sessionc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_session.c (15918 => 15919)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_session.c        2009-12-11 21:50:29 UTC (rev 15918)
+++ freeswitch/trunk/src/switch_core_session.c        2009-12-11 21:51:10 UTC (rev 15919)
</span><span class="lines">@@ -1472,11 +1472,16 @@
</span><span class="cx">
</span><span class="cx">         if ((application_interface = switch_loadable_module_get_application_interface(app)) == 0) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Application %s\n", app);
</span><ins>+                goto end;
</ins><span class="cx">         } else if (application_interface->flags) {
</span><span class="cx">                 *flags = application_interface->flags;
</span><span class="cx">                 status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        UNPROTECT_INTERFACE(application_interface);
+
+ end:
+
</ins><span class="cx">         return status;
</span><span class="cx">
</span><span class="cx"> }
</span><span class="lines">@@ -1524,6 +1529,7 @@
</span><span class="cx">         switch_core_session_exec(session, application_interface, arg);
</span><span class="cx">
</span><span class="cx"> done:
</span><ins>+
</ins><span class="cx">         UNPROTECT_INTERFACE(application_interface);
</span><span class="cx">         
</span><span class="cx">         return status;
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_ivrc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_ivr.c (15918 => 15919)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_ivr.c        2009-12-11 21:50:29 UTC (rev 15918)
+++ freeswitch/trunk/src/switch_ivr.c        2009-12-11 21:51:10 UTC (rev 15919)
</span><span class="lines">@@ -501,7 +501,6 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (cmd_hash == CMD_EXECUTE) {
</span><del>-                switch_application_interface_t *application_interface;
</del><span class="cx">                 char *app_name = switch_event_get_header(event, "execute-app-name");
</span><span class="cx">                 char *app_arg = switch_event_get_header(event, "execute-app-arg");
</span><span class="cx">                 char *loop_h = switch_event_get_header(event, "loops");
</span><span class="lines">@@ -513,61 +512,60 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (app_name) {
</span><del>-                        if ((application_interface = switch_loadable_module_get_application_interface(app_name))) {
-                                if (application_interface->application_function) {
-                                        int x;
-                                        const char *b_uuid = NULL;
-                                        switch_core_session_t *b_session = NULL;
</del><ins>+                        int x;
+                        const char *b_uuid = NULL;
+                        switch_core_session_t *b_session = NULL;
</ins><span class="cx">
</span><del>-                                        switch_channel_clear_flag(channel, CF_STOP_BROADCAST);
-                                        switch_channel_set_flag(channel, CF_BROADCAST);
-                                        if (hold_bleg && switch_true(hold_bleg)) {
-                                                if ((b_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
-                                                        const char *stream;
-                                                        b_uuid = switch_core_session_strdup(session, b_uuid);
</del><ins>+                        switch_channel_clear_flag(channel, CF_STOP_BROADCAST);
+                        switch_channel_set_flag(channel, CF_BROADCAST);
+                        if (hold_bleg && switch_true(hold_bleg)) {
+                                if ((b_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
+                                        const char *stream;
+                                        b_uuid = switch_core_session_strdup(session, b_uuid);
</ins><span class="cx">
</span><del>-                                                        if (!(stream = switch_channel_get_variable_partner(channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
-                                                                stream = switch_channel_get_variable(channel, SWITCH_HOLD_MUSIC_VARIABLE);
-                                                        }
-
-                                                        if (stream && switch_is_moh(stream)) {
-                                                                if ((b_session = switch_core_session_locate(b_uuid))) {
-                                                                        switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
-                                                                        switch_ivr_broadcast(b_uuid, stream, SMF_ECHO_ALEG | SMF_LOOP);
-                                                                        switch_channel_wait_for_flag(b_channel, CF_BROADCAST, SWITCH_TRUE, 5000, NULL);
-                                                                        switch_core_session_rwunlock(b_session);
-                                                                }
-                                                        } else {
-                                                                b_uuid = NULL;
-                                                        }
-                                                }
</del><ins>+                                        if (!(stream = switch_channel_get_variable_partner(channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
+                                                stream = switch_channel_get_variable(channel, SWITCH_HOLD_MUSIC_VARIABLE);
</ins><span class="cx">                                         }
</span><del>-                                        for (x = 0; x < loops || loops < 0; x++) {
-                                                switch_time_t b4, aftr;
</del><span class="cx">
</span><del>-                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Command Execute %s(%s)\n",
-                                                                                 switch_channel_get_name(channel), app_name, switch_str_nil(app_arg));
-                                                b4 = switch_micro_time_now();
-                                                switch_core_session_exec(session, application_interface, app_arg);
-                                                aftr = switch_micro_time_now();
-                                                if (!switch_channel_ready(channel) || switch_channel_test_flag(channel, CF_STOP_BROADCAST) || aftr - b4 < 500000) {
-                                                        break;
-                                                }
-                                        }
-
-                                        if (b_uuid) {
</del><ins>+                                        if (stream && switch_is_moh(stream)) {
</ins><span class="cx">                                                 if ((b_session = switch_core_session_locate(b_uuid))) {
</span><span class="cx">                                                         switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
</span><del>-                                                        switch_channel_stop_broadcast(b_channel);
-                                                        switch_channel_wait_for_flag(b_channel, CF_BROADCAST, SWITCH_FALSE, 5000, NULL);
</del><ins>+                                                        switch_ivr_broadcast(b_uuid, stream, SMF_ECHO_ALEG | SMF_LOOP);
+                                                        switch_channel_wait_for_flag(b_channel, CF_BROADCAST, SWITCH_TRUE, 5000, NULL);
</ins><span class="cx">                                                         switch_core_session_rwunlock(b_session);
</span><span class="cx">                                                 }
</span><ins>+                                        } else {
+                                                b_uuid = NULL;
</ins><span class="cx">                                         }
</span><ins>+                                }
+                        }
</ins><span class="cx">
</span><del>-                                        switch_channel_clear_flag(channel, CF_BROADCAST);
</del><ins>+                        for (x = 0; x < loops || loops < 0; x++) {
+                                switch_time_t b4, aftr;
+
+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Command Execute %s(%s)\n",
+                                                                 switch_channel_get_name(channel), app_name, switch_str_nil(app_arg));
+                                b4 = switch_micro_time_now();
+                                if (switch_core_session_execute_application(session, app_name, app_arg) != SWITCH_STATUS_SUCCESS) {
+                                        goto done;
</ins><span class="cx">                                 }
</span><del>-                                UNPROTECT_INTERFACE(application_interface);
</del><ins>+
+                                aftr = switch_micro_time_now();
+                                if (!switch_channel_ready(channel) || switch_channel_test_flag(channel, CF_STOP_BROADCAST) || aftr - b4 < 500000) {
+                                        break;
+                                }
</ins><span class="cx">                         }
</span><ins>+
+                        if (b_uuid) {
+                                if ((b_session = switch_core_session_locate(b_uuid))) {
+                                        switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
+                                        switch_channel_stop_broadcast(b_channel);
+                                        switch_channel_wait_for_flag(b_channel, CF_BROADCAST, SWITCH_FALSE, 5000, NULL);
+                                        switch_core_session_rwunlock(b_session);
+                                }
+                        }
+                        
+                        switch_channel_clear_flag(channel, CF_BROADCAST);
</ins><span class="cx">                 }
</span><span class="cx">         } else if (cmd_hash == CMD_UNICAST) {
</span><span class="cx">                 char *local_ip = switch_event_get_header(event, "local-ip");
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_ivr_bridgec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_ivr_bridge.c (15918 => 15919)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_ivr_bridge.c        2009-12-11 21:50:29 UTC (rev 15918)
+++ freeswitch/trunk/src/switch_ivr_bridge.c        2009-12-11 21:51:10 UTC (rev 15919)
</span><span class="lines">@@ -637,7 +637,8 @@
</span><span class="cx">         }
</span><span class="cx">         
</span><span class="cx">         if (switch_channel_get_state(channel) == CS_EXCHANGE_MEDIA) {
</span><del>-                switch_channel_set_state(channel, CS_RESET);
</del><ins>+                switch_channel_set_variable(channel, "park_timeout", "3");
+                switch_channel_set_state(channel, CS_PARK);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_FALSE;
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>
</body>
</html>