[sr-dev] how to define an infinite while loop?
Daniel-Constantin Mierla
miconda at gmail.com
Wed Apr 7 18:25:47 CEST 2010
On 4/7/10 6:14 PM, Ovidiu Sas wrote:
> How about defining a new PV: '$true'.
> If we have a constant word in the while loop, then yes, it might be a
> missconfiguration and it is good to have the warning.
> Having a '$true' PV will mean that we want an infinite loop and
> there's no need to print the warning.
> The '$true' will make the config more easy to read as opposed to
> defining a variable just for the purpose of creating an infinite loop.
>
never used the while (true) loop, was it in 1.5? If yes, we can wrap the
warning log in #!KAMAILIO compat mode.
An optimization to Andrei's suggestion is to init the true var at
startup, to avoid assignment every cfg execution:
modparam("pv", "varset", "true=i:1")
Cheers,
Daniel
> Thanks,
> Ovidiu
>
> On Fri, Apr 2, 2010 at 4:53 AM, Andrei Pelinescu-Onciul
> <andrei at iptel.org> wrote:
>
>> On Apr 01, 2010 at 22:23, Ovidiu Sas<osas at voipembedded.com> wrote:
>>
>>> If I define an infinite loop like this:
>>> while( true ) {
>>> ...
>>> }
>>> the following warning is reported:
>>> WARNING:<core> [cfg.y:3307]: warning in config file
>>> /etc/kamailio/kamailio.cfg, line 4, column 9-12: constant value in
>>> while(...)
>>> The config file used for testing:
>>> #!KAMAILIO
>>>
>>> route{
>>> while( true ) {
>>> exit;
>>> }
>>> exit;
>>> }
>>>
>>>
>>> How can I define a simple infinite loop without getting a warning in the logs.
>>>
>>> I don't want to define a variable just for the while loop and test it.
>>> $var(true) = 1;
>>> while ($var(true)) {
>>> ...
>>> }
>>>
>>> Is there a specific PV like '$null' or a specific keyword?
>>>
>> No, you have to live with the warning.
>> In most cases infinite loops are a bug and hence we better have the
>> warning (this is a sip router and not a general programing language).
>>
>> Andrei
>>
>>
> _______________________________________________
> sr-dev mailing list
> sr-dev at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
>
--
Daniel-Constantin Mierla * http://www.asipto.com/ *
http://twitter.com/miconda *
http://www.linkedin.com/in/danielconstantinmierla
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-dev/attachments/20100407/51ad3413/attachment.htm>
More information about the sr-dev
mailing list