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?
Thanks, Ovidiu Sas
On 04/01/2010 10:23 PM, Ovidiu Sas wrote:
How can I define a simple infinite loop without getting a warning in the logs.
How does
while(1 == 1)
stack up?
I think 1 == 1 will be evaluated on each loop. I really liked the old way: while( true ) { ... } It was nice and easy to read.
Thanks, Ovidiu
On Thu, Apr 1, 2010 at 10:27 PM, Alex Balashov abalashov@evaristesys.com wrote:
On 04/01/2010 10:23 PM, Ovidiu Sas wrote:
How can I define a simple infinite loop without getting a warning in the logs.
How does
while(1 == 1)
stack up?
-- Alex Balashov - Principal Evariste Systems LLC 1170 Peachtree Street 12th Floor, Suite 1200 Atlanta, GA 30309 Tel: +1-678-954-0670 Fax: +1-404-961-1892 Web: http://www.evaristesys.com/
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
On 04/01/2010 10:39 PM, Ovidiu Sas wrote:
I think 1 == 1 will be evaluated on each loop.
This may be true, but I am not convinced it is a very high-overhead operation. :-)
On Apr 01, 2010 at 22:27, Alex Balashov abalashov@evaristesys.com wrote:
On 04/01/2010 10:23 PM, Ovidiu Sas wrote:
How can I define a simple infinite loop without getting a warning in the logs.
How does
while(1 == 1)
stack up?
It wouldn't work, is optimised away to while(1) and you should get the same warning. Not even starting without optimisations (-O 0) would help, since the check is for a constant expression. The lowest overhead would be $var(x)=1; while($var(x)) {...}.
Andrei
Ovidiu Sas writes:
How can I define a simple infinite loop without getting a warning in the logs.
ovidiu,
i asked this exactly same question last year and at that time andrei was not willing to remove the warning. may be he could reconsider now when there is more than me asking for it.
-- juha
On Apr 01, 2010 at 22:23, Ovidiu Sas osas@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
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.
Thanks, Ovidiu
On Fri, Apr 2, 2010 at 4:53 AM, Andrei Pelinescu-Onciul andrei@iptel.org wrote:
On Apr 01, 2010 at 22:23, Ovidiu Sas osas@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
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@iptel.org wrote:
On Apr 01, 2010 at 22:23, Ovidiu Sasosas@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@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
Yes, it was in 1.5 and it was really handy. The modparam("pv", "varset", "true=i:1") seems to do the trick. It is an extra line in the config but seems to be fine.
Thanks, Ovidiu
On Wed, Apr 7, 2010 at 12:25 PM, Daniel-Constantin Mierla miconda@gmail.com wrote:
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@iptel.org wrote:
On Apr 01, 2010 at 22:23, Ovidiu Sas osas@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@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
On 4/7/10 7:01 PM, Ovidiu Sas wrote:
Yes, it was in 1.5 and it was really handy.
ok, I will add that to the missing compat list to sort out.
The modparam("pv", "varset", "true=i:1") seems to do the trick. It is an extra line in the config but seems to be fine.
Anyhow we can add $true that will return integer 1, as well as $false if people find them useful, it is something trivial.
Cheers, Daniel
Thanks, Ovidiu
On Wed, Apr 7, 2010 at 12:25 PM, Daniel-Constantin Mierla miconda@gmail.com wrote:
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@iptel.org wrote:
On Apr 01, 2010 at 22:23, Ovidiu Sasosas@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@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
Actually, the modparam doesn't work. And I got these errors with the following simple config:
#!KAMAILIO
mpath="/usr/lib/kamailio/modules_k/:/usr/lib/kamailio/modules/" loadmodule "xlog.so" loadmodule "pv.so" modparam("pv", "varset", "true=i:1")
route{ xlog("L_INFO","$true\n"); }
ERROR: <core> [pvapi.c:501]: error searching pvar "true" ERROR: <core> [pvapi.c:705]: wrong char [e/101] in [$true ] at [4 (0)] ERROR: xlog [xlog.c:305]: wrong format[$true ]! ERROR: <core> [route.c:1026]: fixing failed (code=-1) at cfg:/etc/kamailio/kamailio.cfg:10
I haven't used the varset before, so maybe I'm doing something wrong here ...
On Wed, Apr 7, 2010 at 1:01 PM, Ovidiu Sas osas@voipembedded.com wrote:
Yes, it was in 1.5 and it was really handy. The modparam("pv", "varset", "true=i:1") seems to do the trick. It is an extra line in the config but seems to be fine.
Thanks, Ovidiu
On Wed, Apr 7, 2010 at 12:25 PM, Daniel-Constantin Mierla miconda@gmail.com wrote:
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@iptel.org wrote:
On Apr 01, 2010 at 22:23, Ovidiu Sas osas@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@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
Ohh ... it is $var(true) and not $true .... I think having a $true pvar would be nice. But I would like to have the $true pvar for all flavors, not only for KAMAILIO flavor.
Thanks, Ovidiu
On Wed, Apr 7, 2010 at 2:02 PM, Ovidiu Sas osas@voipembedded.com wrote:
Actually, the modparam doesn't work. And I got these errors with the following simple config:
#!KAMAILIO
mpath="/usr/lib/kamailio/modules_k/:/usr/lib/kamailio/modules/" loadmodule "xlog.so" loadmodule "pv.so" modparam("pv", "varset", "true=i:1")
route{ xlog("L_INFO","$true\n"); }
ERROR: <core> [pvapi.c:501]: error searching pvar "true" ERROR: <core> [pvapi.c:705]: wrong char [e/101] in [$true ] at [4 (0)] ERROR: xlog [xlog.c:305]: wrong format[$true ]! ERROR: <core> [route.c:1026]: fixing failed (code=-1) at cfg:/etc/kamailio/kamailio.cfg:10
I haven't used the varset before, so maybe I'm doing something wrong here ...
On Wed, Apr 7, 2010 at 1:01 PM, Ovidiu Sas osas@voipembedded.com wrote:
Yes, it was in 1.5 and it was really handy. The modparam("pv", "varset", "true=i:1") seems to do the trick. It is an extra line in the config but seems to be fine.
Thanks, Ovidiu
On Wed, Apr 7, 2010 at 12:25 PM, Daniel-Constantin Mierla miconda@gmail.com wrote:
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@iptel.org wrote:
On Apr 01, 2010 at 22:23, Ovidiu Sas osas@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@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
Ovidiu Sas writes:
Ohh ... it is $var(true) and not $true .... I think having a $true pvar would be nice. But I would like to have the $true pvar for all flavors, not only for KAMAILIO flavor.
ovidiu,
i have not defined
#!KAMAILIO
and $var(true) works. i don't know what the default flavor is.
-- juha
Yes, $var(true) works. I was asking for a new PV: '$true' to be implemented in the core and be visible for all flavors.
I would like to be able to do 'while ( $true ) {}' instead of 'while ( $var(true) ) {}'. And I would like to do this regardless of flavor.
And speaking of flavors, we should have a page on the wiki describing all the subtle differences between flavors (maybe there is one, but I couldn't find it).
Thanks, Ovidiu
On Wed, Apr 7, 2010 at 2:07 PM, Juha Heinanen jh@tutpro.com wrote:
Ovidiu Sas writes:
> Ohh ... it is $var(true) and not $true .... > I think having a $true pvar would be nice. > But I would like to have the $true pvar for all flavors, not only for > KAMAILIO flavor.
ovidiu,
i have not defined
#!KAMAILIO
and $var(true) works. i don't know what the default flavor is.
-- juha
On 4/7/10 8:18 PM, Ovidiu Sas wrote:
Yes, $var(true) works. I was asking for a new PV: '$true' to be implemented in the core and be visible for all flavors.
$true as PV will be added to pv module and will be visible to all flavours.
I was refering to #!KAMAILIO as an option to disable the warning which happens now for 'while (true)' case.
I would like to be able to do 'while ( $true ) {}' instead of 'while ( $var(true) ) {}'. And I would like to do this regardless of flavor.
And speaking of flavors, we should have a page on the wiki describing all the subtle differences between flavors (maybe there is one, but I couldn't find it).
Not a wiki, but there are some pages describing what is Kamailio 3.0 in the context of SIP Router project: http://sip-router.org/kamailio-release/ http://www.kamailio.org/w/kamailio-sip-router-releases/
A wiki page would be easier to maintain by community.
Cheers, Daniel
Thanks, Ovidiu
On Wed, Apr 7, 2010 at 2:07 PM, Juha Heinanenjh@tutpro.com wrote:
Ovidiu Sas writes:
Ohh ... it is $var(true) and not $true .... I think having a $true pvar would be nice. But I would like to have the $true pvar for all flavors, not only for KAMAILIO flavor.
ovidiu,
i have not defined
#!KAMAILIO
and $var(true) works. i don't know what the default flavor is.
-- juha
If we will add the $true to the pv module, then we should leave the warning as is. We have a workaround for 3.0.x and we will have $true in >= 3.1.x.
Thanks, Ovidiu
On Wed, Apr 7, 2010 at 2:36 PM, Daniel-Constantin Mierla miconda@gmail.com wrote:
On 4/7/10 8:18 PM, Ovidiu Sas wrote:
Yes, $var(true) works. I was asking for a new PV: '$true' to be implemented in the core and be visible for all flavors.
$true as PV will be added to pv module and will be visible to all flavours.
I was refering to #!KAMAILIO as an option to disable the warning which happens now for 'while (true)' case.
I would like to be able to do 'while ( $true ) {}' instead of 'while ( $var(true) ) {}'. And I would like to do this regardless of flavor.
And speaking of flavors, we should have a page on the wiki describing all the subtle differences between flavors (maybe there is one, but I couldn't find it).
Not a wiki, but there are some pages describing what is Kamailio 3.0 in the context of SIP Router project: http://sip-router.org/kamailio-release/ http://www.kamailio.org/w/kamailio-sip-router-releases/
A wiki page would be easier to maintain by community.
Cheers, Daniel
Thanks, Ovidiu
On Wed, Apr 7, 2010 at 2:07 PM, Juha Heinanenjh@tutpro.com wrote:
Ovidiu Sas writes:
> Ohh ... it is $var(true) and not $true .... > I think having a $true pvar would be nice. > But I would like to have the $true pvar for all flavors, not only for > KAMAILIO flavor.
ovidiu,
i have not defined
#!KAMAILIO
and $var(true) works. i don't know what the default flavor is.
-- juha
-- Daniel-Constantin Mierla * http://www.asipto.com/ * http://twitter.com/miconda * http://www.linkedin.com/in/danielconstantinmierla