[Freeswitch-dev] patch for switch_ivr_sleep break behavior

Steven Ayre steveayre at gmail.com
Mon Jun 27 16:37:10 MSD 2011


This is probably best filed as a Patch Jira ticket (
http://jira.freeswitch.org/), and it can be looked at and discussed by the
core developers there. That makes it easier to track and gives a ticket
number than can be put in any commit messages.

Thanks for the contribution. :)

-Steve


On 23 June 2011 19:43, Steve Richardson <steve at comrex.com> wrote:

> I noticed that the dialplan tools "sleep" function would not respond to
> "break" if the call did not have ready media (e.g., if it was still
> ringing and not bridged anywhere).
>
> The dptools sleep is just a wrapper call for switch_ivr_sleep(), and I
> made a small patch for it to look for a break in the case where the
> media was not ready.
>
> I don't know if this has a negative effect on other uses of
> switch_ivr_sleep() in freeswitch, but for my application this allows me
> to break a sleeping channel when the media is not ready, allowing it to
> proceed.  Instead of yielding for the full sleep time, it yields in
> small increments and checks for break after each yield.  I chose 20ms,
> but my application would probably tolerate 100ms without much impact.  I
> don't know if there's a more elegant way to do this, but I'm certainly
> open to suggestion.
>
> Patch follows for your consideration:
>
>
> diff --git a/src/switch_ivr.c b/src/switch_ivr.c
> index 92eb97e..6c1202a 100644
> --- a/src/switch_ivr.c
> +++ b/src/switch_ivr.c
> @@ -151,7 +151,15 @@ SWITCH_DECLARE(switch_status_t)
> switch_ivr_sleep(switch_core_session_t *session,
>          */
>
>         if (!switch_channel_media_ready(channel)) {
> -               switch_yield(ms * 1000);
> +
> +               for (elapsed=0; elapsed<(ms/20); elapsed++) {
> +                       if (switch_channel_test_flag(channel, CF_BREAK)) {
> +                               switch_channel_clear_flag(channel,
> CF_BREAK);
> +                               return SWITCH_STATUS_BREAK;
> +                       }
> +
> +                       switch_yield(20 * 1000);
> +               }
>                 return SWITCH_STATUS_SUCCESS;
>         }
>
>
>
> regards,
> Steve
>
> --
> *Stephen Richardson
> Senior Software Engineer*
> Comrex Corporation
> 19 Pine Rd
> Devens MA 01434 USA
> v 978.784.1764
> f 978.784.1717
> steve at comrex.com <mailto:steve at comrex.com>
> http://www.comrex.com/
>
> _______________________________________________
> Join us at ClueCon 2011, Aug 9-11, Chicago
> http://www.cluecon.com 877-7-4ACLUE
>
> FreeSWITCH-dev mailing list
> FreeSWITCH-dev at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev
> http://www.freeswitch.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-dev/attachments/20110627/1c43ad4c/attachment.html 


More information about the FreeSWITCH-dev mailing list