[Asterisk-Users] Strange variable chopping from AGI's

John Todd jtodd at loligo.com
Mon Dec 8 14:31:11 MST 2003


AGI's are resulting in unusual behaviors.  Can someone please tell me 
if this is my inappropriate use of AGI's, inappropriate use of 
Time::HiRes, or a bug with *:

I call this script twice:

#!/usr/bin/perl
use Time::HiRes qw( gettimeofday );
($seconds, $microseconds) = gettimeofday;
$hirestime = sprintf("%s","$seconds$microseconds");
print "SET VARIABLE HIRESTIMESTAMP $hirestime\n";


I run this script twice, once before a bunch of stuff, and once 
after, in order to perform a crude version of time measurement. 
However, the script sometimes (1 out of 20?  40?) will return with 
fewer digits in the output of the AGI, which means that when I do my 
subtraction, the numbers come out negative or wildy incorrect.  I'm 
throwing 5 calls into the outgoing spool at once during these tests. 
What's going on here with AGI return values getting chopped? 
Sometimes the first column gets chopped, sometimes the second column 
gets chopped.  Numbers can and do end in "0", so this is not an issue 
of the digits being dropped due to ending with "0" or "00".

Other notes: if I swap out priority 5 with other non-agi 
applications, there is no difference in results.

[foo]
exten => _X.,1,AbsoluteTimeout(4)
exten => _X.,2,AGI(/home/jtodd/agi/timer1)
exten => _X.,3,SetVar(STARTTIME=${HIRESTIMESTAMP})
exten => _X.,4,NoOp(${HIRESTIMESTAMP})
exten => _X.,5,AGI(some-harmless-other-agi-here)
exten => _X.,6,AGI(/home/jtodd/agi/timer1)
exten => _X.,7,NoOp(${HIRESTIMESTAMP})
exten => _X.,8,SetVar(ENDTIME=${HIRESTIMESTAMP})
exten => _X.,9,SetVar(DURATION=$[${ENDTIME} - ${STARTTIME}])
exten => _X.,10,System(echo ${STARTTIME} ${ENDTIME} ${DURATION} >> /tmp/tests)
exten => _X.,11,Hangup


example output:

start time       end time         duration (endtime-starttime)
1070917681581683 1070917681942384 360701
1070917681666607 1070917681968283 301676
1070918477712530 1070918478137011 424481
1070917681788671 1070917681998254 209583
1070917681837624 107091768221563 -963825913616061  <- error!



JT



More information about the asterisk-users mailing list