32 vs 64-bit ngx_current_msec

Peter Leonov gojpeg at gmail.com
Wed May 5 18:03:19 MSD 2010


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?

Thanks,
Peter.


More information about the nginx-devel mailing list