[asterisk-users] New feature: calling all bug marshals

Philip Prindeville philipp_subx at redfish-solutions.com
Wed Dec 5 12:54:38 CST 2007


Tony Mountifield wrote:
> In article <15243.199.46.199.237.1196858285.squirrel at www.tailorhosting.com>,
> Ryan Burke <burke at tailorhosting.com> wrote:
>   
>> I just was looking over the app_waitutil.c and am confused you add 500 to
>> tv.tv_usec on the line "msec = (future - tv.tv_sec) * 1000 - ((tv.tv_usec
>> + 500) / 1000);"?
>>     
>
> It's just doing a standard "round to nearest" integer division, by adding
> half the divisor to the dividend before dividing. Without that, you just
> get "round down" instead.
>
> Cheers
> Tony
>   

That's right. ast_safe_sleep() has a resolution of msec, but 
gettimeofday() returns the time in usec,
so conversion to the nearest whole msec is necessary.

-Philip




More information about the asterisk-users mailing list