32 vs 64-bit ngx_current_msec
Igor Sysoev
igor at sysoev.ru
Wed May 5 18:19:38 MSD 2010
On Wed, May 05, 2010 at 06:03:19PM +0400, Peter Leonov wrote:
> Hello,
>
> The size of ngx_current_msec depends on the platform as far as it is typedefed via ngx_uint_t.
> On the 64-bit it is enough to store the current msecs without an overflow. But on 32-bits it isn't.
>
> At the ngx_times.c:87
>
> ngx_current_msec = (ngx_msec_t) sec * 1000 + msec;
>
> and it's good and usable on the 64-bit machine, but fails on the 32-bit box giving a garbled value.
>
> One workaround I'v found is to do like so:
>
> (uint64_t) ngx_cached_time->sec * 1000 + ngx_cached_time->msec
>
> if the full msecs value is needed is't ok.
> Is this a right way to do?
Yes, this is the right way.
ngx_current_msec is used only to find time difference.
--
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx-devel
mailing list