git pull and try again ... again, it&#39;d be good if you can join IRC or ping me on google talk to discuss this.<div><br clear="all">Moises Silva<br>Senior Software Engineer<br>Sangoma Technologies Inc. | 50 McIntosh Drive, Suite 120, Markham ON L3R 9T3 Canada<br>
t. 1 905 474 1990 x 128 | e. <a href="mailto:moy@sangoma.com">moy@sangoma.com</a><br>
<br><br><div class="gmail_quote">On Mon, Jun 7, 2010 at 7:29 PM, Moises Silva <span dir="ltr">&lt;<a href="mailto:moises.silva@gmail.com">moises.silva@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<div><br></div><div>Yes, I see the race now. Locking in the analog module is, in my opinion, lacking a refactoring, but I&#39;ve tried to not touch much the analog module since I don&#39;t have much time to test it.</div>


<div><br></div><div>Before showing you where the problem is, here is a brief explanation of the process for an outgoing call.</div><div><br></div><div>When FreeSWITCH wants to place a call it will call the .outgoing_channel function pointer of the FreeTDM module, which points to channel_outgoing_channel in mod_freetdm.c line 1037. That function is called in the caller thread (assuming there is a caller), the caller may be a SIP endpoint, other analog channel or whatever technology FS supports. At this point ftdm_channel_call_place() will be called, which is pretty much a wrapper for the FTDM signaling module outgoing_call function pointer (span-&gt;outgoing_call) that is set depending on the signaling for that channel. In this case is analog_fxs_outgoing_call(). In the case of analog, this spawns a new thread, meaning the analog stack spawns a thread per call (where all current ISDN stacks have just 1 thread per span handling the signaling for all calls in that span at once).</div>


<div><br></div><div>The problem right here is that ftdm_channel_open_chan is using ftdm_mutex_trylock(), and with the new code, the channel sometimes will be locked by a few microseconds by the outgoing routine, which, if at that particular moment ftdm_channel_open_chan is called by the service thread (ftdm_analog_channel_run), it will fail the whole call. This is legacy code I have leaved pretty much untouched, but I think I will get rid of it and use a regular ftdm_mutex_lock().</div>


<div><br></div><div>You can give that a try (just change trylock for lock ... or wait for me, I am cooking some changes now that are cleaning up some old and duplicated code when opening channels/requesting channels, should be ready tomorrow.</div>

<div><div class="im"><br clear="all">Moises Silva<br>
Senior Software Engineer<br>Sangoma Technologies Inc. | 50 McIntosh Drive, Suite 120, Markham ON L3R 9T3 Canada<br>t. 1 905 474 1990 x 128 | e. <a href="mailto:moy@sangoma.com" target="_blank">moy@sangoma.com</a><br>
<br><br></div><div><div></div><div class="h5"><div class="gmail_quote">On Mon, Jun 7, 2010 at 4:17 PM,  <span dir="ltr">&lt;<a href="mailto:devel@thom.fr.eu.org" target="_blank">devel@thom.fr.eu.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">










<div lang="FR" link="blue" vlink="purple">

<div>

<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:#1F497D">I’m in the process of testing the patch, and I have some
troubles with FXS now.</span></p>

<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:#1F497D"> </span></p>

<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:#1F497D">When bridging a call onto an FXS channel, the bridge fails. What
seem to happen is the lock acquired in ftmod_analog.c line 83 is not released (seems
it is not) before ftdm_analog_channel_run calls ftdm_channel_open_chan which in
turn tries to acquire and fails the same lock.</span></p>

<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:#1F497D"> </span></p>

<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:#1F497D">If I add a 500ms delay (ftdm_sleep) at the entrance of
ftdm_analog_channel_run, the problem disappears.</span></p>

<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:#1F497D">There seem to be a race condition here, but as I have no idea
how threads are scheduled (nor within mod_freetdm neither in overall
freeswitch) this is beyond my skills. However (I get the same kind of
scheduling problems when trying to thread the MWI function) I’d be glad to
learn how that works, so if you have any pointers…</span></p>

<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:#1F497D"> </span></p>

<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;color:#1F497D">François</span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>

<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">

<p class="MsoNormal"><b><span style="font-size:10.0pt">De :</span></b><span style="font-size:10.0pt">
<a href="mailto:freeswitch-dev-bounces@lists.freeswitch.org" target="_blank">freeswitch-dev-bounces@lists.freeswitch.org</a>
[mailto:<a href="mailto:freeswitch-dev-bounces@lists.freeswitch.org" target="_blank">freeswitch-dev-bounces@lists.freeswitch.org</a>] <b>De la part de</b>
Moises Silva<br>
<b>Envoyé :</b> jeudi 3 juin 2010 23:35</span></p><div><div></div><div><br>
<b>À :</b> <a href="mailto:freeswitch-dev@lists.freeswitch.org" target="_blank">freeswitch-dev@lists.freeswitch.org</a><br>
<b>Objet :</b> Re: [Freeswitch-dev] FXS bridged on FXO ports and DTMF</div></div><p></p>

</div><div><div></div><div>

<p class="MsoNormal"> </p>

<p class="MsoNormal" style="margin-bottom:12.0pt">Something is f&#39;d up there
badly. I cannot reproduce this in my A200.<br>
<br>
Can you give me more details of how are you wiring things up?<br>
<br>
Also do &quot;git pull&quot;, I just improved the DTMF logging to aid in in
debugging. Reproduce the problem and pastebin the resulting logs.<br>
<br>
Regarding your MWI patch. I added some comments on JIRA.<br>
<br clear="all">
Moises Silva<br>
Senior Software Engineer<br>
Sangoma Technologies Inc. | 50 McIntosh Drive, Suite 120, Markham ON L3R 9T3
Canada<br>
t. 1 905 474 1990 x 128 | e. <a href="mailto:moy@sangoma.com" target="_blank">moy@sangoma.com</a><br>
<br>
</p>

<div>

<p class="MsoNormal">On Thu, Jun 3, 2010 at 6:46 AM, François Legal &lt;<a href="mailto:devel@thom.fr.eu.org" target="_blank">devel@thom.fr.eu.org</a>&gt; wrote:</p>

<p>So now using latest git and wanpipe is even worse compared to snapshot from
last week. freetdm now also detects and queue the DTMF from the dialed number.</p>

<p>The new patch is available.</p>

<div>

<div>

<p>On Wed, 2 Jun 2010 16:26:49 -0400, Moises Silva &lt;<a href="mailto:moises.silva@gmail.com" target="_blank">moises.silva@gmail.com</a>&gt;
wrote:</p>

<blockquote style="border:none;border-left:solid #1010FF 1.5pt;padding:0cm 0cm 0cm 4.0pt;margin-left:3.75pt;margin-top:5.0pt;margin-bottom:5.0pt">

<p style="margin-bottom:12.0pt">I&#39;m going to test this DTMF scenario now and
let you know.<br>
<br>
In the meantime, would it be much to ask a patch that I can apply using git
apply?? The patch still fails to apply using git, I see you are still using
svn, try git plz.<br>
<br>
The code looks good though :-)<br>
<br>
Moises Silva<br>
Senior Software Engineer<br>
Sangoma Technologies Inc. | 50 McIntosh Drive, Suite 120, Markham ON L3R 9T3
Canada<br>
t. 1 905 474 1990 x 128 | e. <a href="mailto:moy@sangoma.com" target="_blank">moy@sangoma.com</a><br>
<br>
</p>

<div>

<p class="MsoNormal">On Wed, Jun 2, 2010 at 4:19 PM, &lt;<a href="mailto:devel@thom.fr.eu.org" target="_blank">devel@thom.fr.eu.org</a>&gt;
wrote:</p>

<div>

<div>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">I just updated to 3.5.11 and the result
is the same.</span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>

<div>

<p class="MsoNormal"><b><span style="font-size:10.0pt">De :</span></b><span style="font-size:10.0pt"> <a href="mailto:freeswitch-dev-bounces@lists.freeswitch.org" target="_blank">freeswitch-dev-bounces@lists.freeswitch.org</a>
[mailto:<a href="mailto:freeswitch-dev-bounces@lists.freeswitch.org" target="_blank">freeswitch-dev-bounces@lists.freeswitch.org</a>] <b>De la part
de</b> Moises Silva<br>
<b>Envoyé :</b> mercredi 2 juin 2010 21:35<br>
<b>À :</b> <a href="mailto:freeswitch-dev@lists.freeswitch.org" target="_blank">freeswitch-dev@lists.freeswitch.org</a><br>
<b>Objet :</b> Re: [Freeswitch-dev] FXS bridged on FXO ports and DTMF</span></p>

</div>

<div>

<div>

<p class="MsoNormal"> </p>

<p class="MsoNormal" style="margin-bottom:12.0pt">I
believe the problem was that the driver enabled even outgoing DTMF detection on
the chip  ( which does not make much sense by default since you only care
about incoming ) and was fixed a few months ago<br>
<br>
Do you still see this behavior? which driver version?<br>
<br>
Moises Silva<br>
Senior Software Engineer<br>
Sangoma Technologies Inc. | 50 McIntosh Drive, Suite 120, Markham ON L3R 9T3
Canada<br>
t. 1 905 474 1990 x 128 | e. <a href="mailto:moy@sangoma.com" target="_blank">moy@sangoma.com</a></p>

<div>

<p class="MsoNormal">On
Wed, Jun 2, 2010 at 3:22 PM, &lt;<a href="mailto:devel@thom.fr.eu.org" target="_blank">devel@thom.fr.eu.org</a>&gt; wrote:</p>

<div>

<div>

<p class="MsoNormal">I
come back on this topic as I did not find a clean/good solution to this
problem.</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">As
reminder, the problem occurs when an FXS channel is bridged on an FXO channel
(seen with sangoma A400 hardware with HW DTMF detection).</p>

<p class="MsoNormal">The
problem is that each leg of the bridge is detecting the inband DTMF, and so
freeswitch sends each detected DTMF from one leg to the other, and so on and so
forth (as each leg detects the DTMF again and again).</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">I
guess what would be needed for these cases is some application that would
prevent detected DTMF to be sent to the other leg.</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">Can
anybody give me a hint on whether or not such application exists, and if not, a
starting point to try to create one.</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">Thanks</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">François</p>

<p class="MsoNormal"> </p>

</div>

</div>

<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
_______________________________________________<br>
FreeSWITCH-dev mailing list<br>
<a href="mailto:FreeSWITCH-dev@lists.freeswitch.org" target="_blank">FreeSWITCH-dev@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a></p>

</div>

<p class="MsoNormal"> </p>

</div>

</div>

</div>

</div>

<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
_______________________________________________<br>
FreeSWITCH-dev mailing list<br>
<a href="mailto:FreeSWITCH-dev@lists.freeswitch.org" target="_blank">FreeSWITCH-dev@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a></p>

</div>

<p class="MsoNormal"> </p>

</blockquote>

</div>

</div>

<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
_______________________________________________<br>
FreeSWITCH-dev mailing list<br>
<a href="mailto:FreeSWITCH-dev@lists.freeswitch.org" target="_blank">FreeSWITCH-dev@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a></p>

</div>

<p class="MsoNormal"> </p>

</div></div></div>

</div>


<br>_______________________________________________<br>
FreeSWITCH-dev mailing list<br>
<a href="mailto:FreeSWITCH-dev@lists.freeswitch.org" target="_blank">FreeSWITCH-dev@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br></div></div></div>
</blockquote></div><br></div>