comparison src/core/ngx_times.c @ 891:8a3ba663be1a

slot number must be incremented once per second only, ngx_time_update() set msec in an wrong slot
author Igor Sysoev <igor@sysoev.ru>
date Wed, 06 Dec 2006 14:25:20 +0000
parents 9c2f3ed7a247
children 1b8111df8051
comparison
equal deleted inserted replaced
890:6356b34cf027 891:8a3ba663be1a
68 68
69 if (!ngx_trylock(&ngx_time_lock)) { 69 if (!ngx_trylock(&ngx_time_lock)) {
70 return; 70 return;
71 } 71 }
72 72
73 if (sec == 0) {
74 ngx_gettimeofday(&tv);
75
76 sec = tv.tv_sec;
77 msec = tv.tv_usec / 1000;
78 }
79
80 ngx_current_msec = (ngx_msec_t) sec * 1000 + msec;
81
82 tp = &cached_time[slot];
83
84 if (tp->sec == sec) {
85 tp->msec = msec;
86 ngx_unlock(&ngx_time_lock);
87 return;
88 }
89
73 if (slot == NGX_TIME_SLOTS) { 90 if (slot == NGX_TIME_SLOTS) {
74 slot = 0; 91 slot = 0;
75 } else { 92 } else {
76 slot++; 93 slot++;
77 } 94 }
78 95
79 if (sec == 0) {
80 ngx_gettimeofday(&tv);
81
82 sec = tv.tv_sec;
83 msec = tv.tv_usec / 1000;
84 }
85
86 ngx_current_msec = (ngx_msec_t) sec * 1000 + msec;
87
88 tp = &cached_time[slot]; 96 tp = &cached_time[slot];
89 97
98 tp->sec = sec;
90 tp->msec = msec; 99 tp->msec = msec;
91
92 if (tp->sec == sec) {
93 ngx_unlock(&ngx_time_lock);
94 return;
95 }
96
97 tp->sec = sec;
98 100
99 ngx_gmtime(sec, &gmt); 101 ngx_gmtime(sec, &gmt);
100 102
101 103
102 p0 = cached_http_time[slot]; 104 p0 = cached_http_time[slot];