]> git.kaiwu.me - nginx.git/commitdiff
Fixed possible use of old cached times if runtime went backwards.
authorMaxim Dounin <mdounin@mdounin.ru>
Fri, 3 Aug 2012 09:10:39 +0000 (09:10 +0000)
committerMaxim Dounin <mdounin@mdounin.ru>
Fri, 3 Aug 2012 09:10:39 +0000 (09:10 +0000)
If ngx_time_sigsafe_update() updated only ngx_cached_err_log_time, and
then clock was adjusted backwards, the cached_time[slot].sec might
accidentally match current seconds on next ngx_time_update() call,
resulting in various cached times not being updated.

Fix is to clear the cached_time[slot].sec to explicitly mark cached times
are stale and need updating.

src/core/ngx_times.c

index ed1bf64bc082013961cbdccd010d2f015ecf9d6a..77490faf0452e63d996b63bea346ddeadac44c1c 100644 (file)
@@ -211,6 +211,10 @@ ngx_time_sigsafe_update(void)
         slot++;
     }
 
+    tp = &cached_time[slot];
+
+    tp->sec = 0;
+
     ngx_gmtime(sec + cached_gmtoff * 60, &tm);
 
     p = &cached_err_log_time[slot][0];