<!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][15891] </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=15891">15891</a></dd>
<dt>Author</dt> <dd>anthm</dd>
<dt>Date</dt> <dd>2009-12-10 18:28:54 -0600 (Thu, 10 Dec 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>stop race condition in sofia where we tried to send an ack on a dead call and turn off early hangup by default (if you dont know that that is, good, do not document this)</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunksrcincludeswitch_coreh">freeswitch/trunk/src/include/switch_core.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_typesh">freeswitch/trunk/src/include/switch_types.h</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_dptoolsmod_dptoolsc">freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofiac">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_channelc">freeswitch/trunk/src/switch_channel.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_corec">freeswitch/trunk/src/switch_core.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_state_machinec">freeswitch/trunk/src/switch_core_state_machine.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_cppcpp">freeswitch/trunk/src/switch_cpp.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunksrcincludeswitch_coreh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_core.h (15890 => 15891)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_core.h        2009-12-11 00:13:50 UTC (rev 15890)
+++ freeswitch/trunk/src/include/switch_core.h        2009-12-11 00:28:54 UTC (rev 15891)
</span><span class="lines">@@ -615,7 +615,7 @@
</span><span class="cx"> 
</span><span class="cx"> SWITCH_DECLARE(void) switch_core_session_destroy_state(switch_core_session_t *session);
</span><span class="cx"> SWITCH_DECLARE(void) switch_core_session_reporting_state(switch_core_session_t *session);
</span><del>-SWITCH_DECLARE(void) switch_core_session_hangup_state(switch_core_session_t *session);
</del><ins>+SWITCH_DECLARE(void) switch_core_session_hangup_state(switch_core_session_t *session, switch_bool_t force);
</ins><span class="cx"> 
</span><span class="cx"> /*! 
</span><span class="cx">   \brief Provide the total number of sessions
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_typesh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_types.h (15890 => 15891)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_types.h        2009-12-11 00:13:50 UTC (rev 15890)
+++ freeswitch/trunk/src/include/switch_types.h        2009-12-11 00:28:54 UTC (rev 15891)
</span><span class="lines">@@ -241,7 +241,8 @@
</span><span class="cx">         SCF_VG = (1 &lt;&lt; 3),
</span><span class="cx">         SCF_RESTART = (1 &lt;&lt; 4),
</span><span class="cx">         SCF_SHUTDOWN_REQUESTED = (1 &lt;&lt; 5),
</span><del>-        SCF_USE_AUTO_NAT = (1 &lt;&lt; 6)
</del><ins>+        SCF_USE_AUTO_NAT = (1 &lt;&lt; 6),
+        SCF_EARLY_HANGUP = (1 &lt;&lt; 7)
</ins><span class="cx"> } switch_core_flag_enum_t;
</span><span class="cx"> typedef uint32_t switch_core_flag_t;
</span><span class="cx"> 
</span><span class="lines">@@ -946,6 +947,7 @@
</span><span class="cx">         CF_BYPASS_MEDIA_AFTER_BRIDGE,
</span><span class="cx">         CF_LEG_HOLDING,
</span><span class="cx">         CF_BROADCAST_DROP_MEDIA,
</span><ins>+        CF_EARLY_HANGUP,
</ins><span class="cx">         /* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */
</span><span class="cx">         CF_FLAG_MAX
</span><span class="cx"> } switch_channel_flag_t;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_dptoolsmod_dptoolsc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (15890 => 15891)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c        2009-12-11 00:13:50 UTC (rev 15890)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c        2009-12-11 00:28:54 UTC (rev 15891)
</span><span class="lines">@@ -2787,6 +2787,11 @@
</span><span class="cx">         switch_channel_set_flag(switch_core_session_get_channel(session), CF_VERBOSE_EVENTS);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+SWITCH_STANDARD_APP(early_hangup_function)
+{
+        switch_channel_set_flag(switch_core_session_get_channel(session), CF_EARLY_HANGUP);
+}
+
</ins><span class="cx"> #define WAIT_FOR_SILENCE_SYNTAX &quot;&lt;silence_thresh&gt; &lt;silence_hits&gt; &lt;listen_hits&gt; &lt;timeout_ms&gt; [&lt;file&gt;]&quot;
</span><span class="cx"> SWITCH_STANDARD_APP(wait_for_silence_function)
</span><span class="cx"> {
</span><span class="lines">@@ -2939,6 +2944,7 @@
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;check_acl&quot;, &quot;Check an ip against an ACL list&quot;, &quot;Check an ip against an ACL list&quot;, check_acl_function,
</span><span class="cx">                                    &quot;&lt;ip&gt; &lt;acl | cidr&gt; [&lt;hangup_cause&gt;]&quot;, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;verbose_events&quot;, &quot;Make ALL Events verbose.&quot;, &quot;Make ALL Events verbose.&quot;, verbose_events_function, &quot;&quot;, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</span><ins>+        SWITCH_ADD_APP(app_interface, &quot;early_hangup&quot;, &quot;Enable early hangup&quot;, &quot;&quot;, early_hangup_function, &quot;&quot;, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</ins><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;sleep&quot;, &quot;Pause a channel&quot;, SLEEP_LONG_DESC, sleep_function, &quot;&lt;pausemilliseconds&gt;&quot;, SAF_SUPPORT_NOMEDIA);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;delay_echo&quot;, &quot;echo audio at a specified delay&quot;, &quot;Delay n ms&quot;, delay_function, &quot;&lt;delay ms&gt;&quot;, SAF_NONE);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, &quot;strftime&quot;, &quot;strftime&quot;, &quot;strftime&quot;, strftime_function, &quot;[&lt;epoch&gt;|]&lt;format string&gt;&quot;, SAF_SUPPORT_NOMEDIA);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofiac"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (15890 => 15891)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c        2009-12-11 00:13:50 UTC (rev 15890)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c        2009-12-11 00:28:54 UTC (rev 15891)
</span><span class="lines">@@ -3833,6 +3833,7 @@
</span><span class="cx">         case nua_callstate_completed:
</span><span class="cx">         case nua_callstate_received:
</span><span class="cx">         case nua_callstate_proceeding:
</span><ins>+        case nua_callstate_completing:
</ins><span class="cx">                 if (!(session &amp;&amp; channel &amp;&amp; tech_pvt)) goto done;
</span><span class="cx">                 break;
</span><span class="cx">         default:
</span><span class="lines">@@ -3890,9 +3891,9 @@
</span><span class="cx">                 break;
</span><span class="cx">         case nua_callstate_completing:
</span><span class="cx">                 nua_ack(nh,
</span><del>-                                TAG_IF(tech_pvt &amp;&amp; !zstr(tech_pvt-&gt;user_via), SIPTAG_VIA_STR(tech_pvt-&gt;user_via)),
</del><ins>+                                TAG_IF(!zstr(tech_pvt-&gt;user_via), SIPTAG_VIA_STR(tech_pvt-&gt;user_via)),
</ins><span class="cx">                                 TAG_END());
</span><del>-                break;
</del><ins>+                goto done;
</ins><span class="cx">         case nua_callstate_received:
</span><span class="cx">                 if (!sofia_test_flag(tech_pvt, TFLAG_SDP)) {
</span><span class="cx">                         if (r_sdp &amp;&amp; !sofia_test_flag(tech_pvt, TFLAG_SDP)) {
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_channelc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_channel.c (15890 => 15891)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_channel.c        2009-12-11 00:13:50 UTC (rev 15890)
+++ freeswitch/trunk/src/switch_channel.c        2009-12-11 00:28:54 UTC (rev 15891)
</span><span class="lines">@@ -1911,7 +1911,7 @@
</span><span class="cx"> 
</span><span class="cx">                 switch_core_session_kill_channel(channel-&gt;session, SWITCH_SIG_KILL);
</span><span class="cx">                 switch_core_session_signal_state_change(channel-&gt;session);
</span><del>-                switch_core_session_hangup_state(channel-&gt;session);
</del><ins>+                switch_core_session_hangup_state(channel-&gt;session, SWITCH_FALSE);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         return channel-&gt;state;
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_corec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core.c (15890 => 15891)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core.c        2009-12-11 00:13:50 UTC (rev 15890)
+++ freeswitch/trunk/src/switch_core.c        2009-12-11 00:28:54 UTC (rev 15891)
</span><span class="lines">@@ -1382,6 +1382,8 @@
</span><span class="cx">                                         if (tmp &gt; -1 &amp;&amp; tmp &lt; 11) {
</span><span class="cx">                                                 switch_core_session_ctl(SCSC_DEBUG_LEVEL, &amp;tmp);
</span><span class="cx">                                         }
</span><ins>+                                } else if (!strcasecmp(var, &quot;enable-early-hangup&quot;) &amp;&amp; switch_true(val)) {
+                                        switch_set_flag((&amp;runtime), SCF_EARLY_HANGUP);
</ins><span class="cx">                                 } else if (!strcasecmp(var, &quot;colorize-console&quot;) &amp;&amp; switch_true(val)) {
</span><span class="cx">                                         runtime.colorize_console = SWITCH_TRUE;
</span><span class="cx">                                 } else if (!strcasecmp(var, &quot;mailer-app&quot;) &amp;&amp; !zstr(val)) {
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_state_machinec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_state_machine.c (15890 => 15891)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_state_machine.c        2009-12-11 00:13:50 UTC (rev 15890)
+++ freeswitch/trunk/src/switch_core_state_machine.c        2009-12-11 00:28:54 UTC (rev 15891)
</span><span class="lines">@@ -329,7 +329,7 @@
</span><span class="cx">                                 goto done;
</span><span class="cx">                         case CS_HANGUP:        /* Deactivate and end the thread */
</span><span class="cx">                                 {
</span><del>-                                        switch_core_session_hangup_state(session);                                
</del><ins>+                                        switch_core_session_hangup_state(session, SWITCH_TRUE);                                
</ins><span class="cx">                                         switch_channel_set_state(session-&gt;channel, CS_REPORTING);
</span><span class="cx">                                 }
</span><span class="cx"> 
</span><span class="lines">@@ -437,7 +437,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-SWITCH_DECLARE(void) switch_core_session_hangup_state(switch_core_session_t *session)
</del><ins>+SWITCH_DECLARE(void) switch_core_session_hangup_state(switch_core_session_t *session, switch_bool_t force)
</ins><span class="cx"> {
</span><span class="cx">         const char *hook_var;
</span><span class="cx">         switch_core_session_t *use_session = NULL;
</span><span class="lines">@@ -454,15 +454,21 @@
</span><span class="cx">         const switch_state_handler_table_t *driver_state_handler = NULL;
</span><span class="cx">         const switch_state_handler_table_t *application_state_handler = NULL;
</span><span class="cx"> 
</span><ins>+        
+        if (!force) {
+                if (!switch_channel_test_flag(session-&gt;channel, CF_EARLY_HANGUP) &amp;&amp; !switch_test_flag((&amp;runtime), SCF_EARLY_HANGUP)) {
+                        return;
+                }
</ins><span class="cx"> 
</span><del>-        if (switch_thread_self() != session-&gt;thread_id) {
-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s thread mismatch skipping state handler.\n&quot;, 
-                                                  switch_channel_get_name(session-&gt;channel));
-                return;
</del><ins>+                if (switch_thread_self() != session-&gt;thread_id) {
+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG10, &quot;%s thread mismatch skipping state handler.\n&quot;, 
+                                                          switch_channel_get_name(session-&gt;channel));
+                        return;
+                }
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (switch_test_flag(session, SSF_HANGUP)) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s handler already called, skipping state handler.\n&quot;,
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG10, &quot;%s handler already called, skipping state handler.\n&quot;,
</ins><span class="cx">                                                   switch_channel_get_name(session-&gt;channel));
</span><span class="cx">                 return;
</span><span class="cx">         }
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_cppcpp"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_cpp.cpp (15890 => 15891)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_cpp.cpp        2009-12-11 00:13:50 UTC (rev 15890)
+++ freeswitch/trunk/src/switch_cpp.cpp        2009-12-11 00:28:54 UTC (rev 15891)
</span><span class="lines">@@ -569,7 +569,7 @@
</span><span class="cx">         sanity_check_noreturn;        
</span><span class="cx">         this-&gt;begin_allow_threads();
</span><span class="cx">         if (switch_channel_down(channel)) {
</span><del>-                switch_core_session_hangup_state(session);
</del><ins>+                switch_core_session_hangup_state(session, SWITCH_FALSE);
</ins><span class="cx">         }
</span><span class="cx">         this-&gt;end_allow_threads();
</span><span class="cx"> }
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>

</body>
</html>