mirror of
https://github.com/nginx/nginx.git
synced 2025-06-13 06:12:44 +08:00
slot number must be incremented once per second only,
ngx_time_update() set msec in an wrong slot
This commit is contained in:
parent
a19ed3eddd
commit
c3d106a9bc
@ -70,12 +70,6 @@ ngx_time_update(time_t sec, ngx_uint_t msec)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slot == NGX_TIME_SLOTS) {
|
|
||||||
slot = 0;
|
|
||||||
} else {
|
|
||||||
slot++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sec == 0) {
|
if (sec == 0) {
|
||||||
ngx_gettimeofday(&tv);
|
ngx_gettimeofday(&tv);
|
||||||
|
|
||||||
@ -87,14 +81,22 @@ ngx_time_update(time_t sec, ngx_uint_t msec)
|
|||||||
|
|
||||||
tp = &cached_time[slot];
|
tp = &cached_time[slot];
|
||||||
|
|
||||||
tp->msec = msec;
|
|
||||||
|
|
||||||
if (tp->sec == sec) {
|
if (tp->sec == sec) {
|
||||||
|
tp->msec = msec;
|
||||||
ngx_unlock(&ngx_time_lock);
|
ngx_unlock(&ngx_time_lock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (slot == NGX_TIME_SLOTS) {
|
||||||
|
slot = 0;
|
||||||
|
} else {
|
||||||
|
slot++;
|
||||||
|
}
|
||||||
|
|
||||||
|
tp = &cached_time[slot];
|
||||||
|
|
||||||
tp->sec = sec;
|
tp->sec = sec;
|
||||||
|
tp->msec = msec;
|
||||||
|
|
||||||
ngx_gmtime(sec, &gmt);
|
ngx_gmtime(sec, &gmt);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user