From c3d106a9bcf8d498138a2138a6fba447fb0532bc Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Wed, 6 Dec 2006 14:25:20 +0000 Subject: [PATCH] slot number must be incremented once per second only, ngx_time_update() set msec in an wrong slot --- src/core/ngx_times.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/core/ngx_times.c b/src/core/ngx_times.c index 88a9e98c9..f6e618a65 100644 --- a/src/core/ngx_times.c +++ b/src/core/ngx_times.c @@ -70,12 +70,6 @@ ngx_time_update(time_t sec, ngx_uint_t msec) return; } - if (slot == NGX_TIME_SLOTS) { - slot = 0; - } else { - slot++; - } - if (sec == 0) { ngx_gettimeofday(&tv); @@ -87,14 +81,22 @@ ngx_time_update(time_t sec, ngx_uint_t msec) tp = &cached_time[slot]; - tp->msec = msec; - if (tp->sec == sec) { + tp->msec = msec; ngx_unlock(&ngx_time_lock); return; } + if (slot == NGX_TIME_SLOTS) { + slot = 0; + } else { + slot++; + } + + tp = &cached_time[slot]; + tp->sec = sec; + tp->msec = msec; ngx_gmtime(sec, &gmt);