Mercurial > hg > nginx-quic
annotate src/core/ngx_times.c @ 8292:e24e5650d7b4 quic
QUIC: distinguish reserved transport parameters in logging.
18.1. Reserved Transport Parameters
Transport parameters with an identifier of the form "31 * N + 27" for
integer values of N are reserved to exercise the requirement that
unknown transport parameters be ignored. These transport parameters
have no semantics, and can carry arbitrary values.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Wed, 10 Feb 2021 14:10:14 +0300 |
parents | 81fae70d6cb8 |
children | 9e7de0547f09 |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
4412 | 4 * Copyright (C) Nginx, Inc. |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
5 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
6 |
178
a8ff48d26cca
nginx-0.0.1-2003-11-11-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
a8ff48d26cca
nginx-0.0.1-2003-11-11-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
a8ff48d26cca
nginx-0.0.1-2003-11-11-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_core.h> |
a8ff48d26cca
nginx-0.0.1-2003-11-11-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
a8ff48d26cca
nginx-0.0.1-2003-11-11-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
7222
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
12 static ngx_msec_t ngx_monotonic_time(time_t sec, ngx_uint_t msec); |
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
13 |
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
14 |
370
54f76b0b8dca
nginx-0.0.7-2004-06-27-22:01:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
15 /* |
563 | 16 * The time may be updated by signal handler or by several threads. |
17 * The time update operations are rare and require to hold the ngx_time_lock. | |
18 * The time read operations are frequent, so they are lock-free and get time | |
19 * values and strings from the current slot. Thus thread may get the corrupted | |
20 * values only if it is preempted while copying and then it is not scheduled | |
21 * to run more than NGX_TIME_SLOTS seconds. | |
370
54f76b0b8dca
nginx-0.0.7-2004-06-27-22:01:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
22 */ |
54f76b0b8dca
nginx-0.0.7-2004-06-27-22:01:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
23 |
563 | 24 #define NGX_TIME_SLOTS 64 |
370
54f76b0b8dca
nginx-0.0.7-2004-06-27-22:01:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
25 |
932
1b8111df8051
the initial slot is out of array
Igor Sysoev <igor@sysoev.ru>
parents:
891
diff
changeset
|
26 static ngx_uint_t slot; |
563 | 27 static ngx_atomic_t ngx_time_lock; |
370
54f76b0b8dca
nginx-0.0.7-2004-06-27-22:01:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
28 |
563 | 29 volatile ngx_msec_t ngx_current_msec; |
30 volatile ngx_time_t *ngx_cached_time; | |
31 volatile ngx_str_t ngx_cached_err_log_time; | |
32 volatile ngx_str_t ngx_cached_http_time; | |
33 volatile ngx_str_t ngx_cached_http_log_time; | |
3873 | 34 volatile ngx_str_t ngx_cached_http_log_iso8601; |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
4782
diff
changeset
|
35 volatile ngx_str_t ngx_cached_syslog_time; |
182
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
36 |
3475
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
37 #if !(NGX_WIN32) |
3474
d4c4cfdffe30
*) use previously cached GMT offset value to update time from a signal handler
Igor Sysoev <igor@sysoev.ru>
parents:
2220
diff
changeset
|
38 |
d4c4cfdffe30
*) use previously cached GMT offset value to update time from a signal handler
Igor Sysoev <igor@sysoev.ru>
parents:
2220
diff
changeset
|
39 /* |
4572
67653855682e
Fixed spelling in multiline C comments.
Ruslan Ermilov <ru@nginx.com>
parents:
4499
diff
changeset
|
40 * localtime() and localtime_r() are not Async-Signal-Safe functions, therefore, |
3475
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
41 * they must not be called by a signal handler, so we use the cached |
3474
d4c4cfdffe30
*) use previously cached GMT offset value to update time from a signal handler
Igor Sysoev <igor@sysoev.ru>
parents:
2220
diff
changeset
|
42 * GMT offset value. Fortunately the value is changed only two times a year. |
d4c4cfdffe30
*) use previously cached GMT offset value to update time from a signal handler
Igor Sysoev <igor@sysoev.ru>
parents:
2220
diff
changeset
|
43 */ |
d4c4cfdffe30
*) use previously cached GMT offset value to update time from a signal handler
Igor Sysoev <igor@sysoev.ru>
parents:
2220
diff
changeset
|
44 |
d4c4cfdffe30
*) use previously cached GMT offset value to update time from a signal handler
Igor Sysoev <igor@sysoev.ru>
parents:
2220
diff
changeset
|
45 static ngx_int_t cached_gmtoff; |
d4c4cfdffe30
*) use previously cached GMT offset value to update time from a signal handler
Igor Sysoev <igor@sysoev.ru>
parents:
2220
diff
changeset
|
46 #endif |
d4c4cfdffe30
*) use previously cached GMT offset value to update time from a signal handler
Igor Sysoev <igor@sysoev.ru>
parents:
2220
diff
changeset
|
47 |
563 | 48 static ngx_time_t cached_time[NGX_TIME_SLOTS]; |
49 static u_char cached_err_log_time[NGX_TIME_SLOTS] | |
50 [sizeof("1970/09/28 12:00:00")]; | |
51 static u_char cached_http_time[NGX_TIME_SLOTS] | |
52 [sizeof("Mon, 28 Sep 1970 06:00:00 GMT")]; | |
53 static u_char cached_http_log_time[NGX_TIME_SLOTS] | |
54 [sizeof("28/Sep/1970:12:00:00 +0600")]; | |
3873 | 55 static u_char cached_http_log_iso8601[NGX_TIME_SLOTS] |
56 [sizeof("1970-09-28T12:00:00+06:00")]; | |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
4782
diff
changeset
|
57 static u_char cached_syslog_time[NGX_TIME_SLOTS] |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
4782
diff
changeset
|
58 [sizeof("Sep 28 12:00:00")]; |
178
a8ff48d26cca
nginx-0.0.1-2003-11-11-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
59 |
a8ff48d26cca
nginx-0.0.1-2003-11-11-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
60 |
326
8733703a37f3
nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
324
diff
changeset
|
61 static char *week[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; |
182
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
62 static char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", |
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
63 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; |
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
64 |
501 | 65 void |
66 ngx_time_init(void) | |
182
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
67 { |
370
54f76b0b8dca
nginx-0.0.7-2004-06-27-22:01:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
68 ngx_cached_err_log_time.len = sizeof("1970/09/28 12:00:00") - 1; |
54f76b0b8dca
nginx-0.0.7-2004-06-27-22:01:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
69 ngx_cached_http_time.len = sizeof("Mon, 28 Sep 1970 06:00:00 GMT") - 1; |
54f76b0b8dca
nginx-0.0.7-2004-06-27-22:01:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
70 ngx_cached_http_log_time.len = sizeof("28/Sep/1970:12:00:00 +0600") - 1; |
3873 | 71 ngx_cached_http_log_iso8601.len = sizeof("1970-09-28T12:00:00+06:00") - 1; |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
4782
diff
changeset
|
72 ngx_cached_syslog_time.len = sizeof("Sep 28 12:00:00") - 1; |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
73 |
370
54f76b0b8dca
nginx-0.0.7-2004-06-27-22:01:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
74 ngx_cached_time = &cached_time[0]; |
205
4a9a2b1dd6fa
nginx-0.0.1-2003-12-04-17:53:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
75 |
3475
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
76 ngx_time_update(); |
270
7bb9562216ce
nginx-0.0.2-2004-02-25-23:16:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
266
diff
changeset
|
77 } |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
78 |
270
7bb9562216ce
nginx-0.0.2-2004-02-25-23:16:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
266
diff
changeset
|
79 |
563 | 80 void |
3475
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
81 ngx_time_update(void) |
270
7bb9562216ce
nginx-0.0.2-2004-02-25-23:16:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
266
diff
changeset
|
82 { |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
4782
diff
changeset
|
83 u_char *p0, *p1, *p2, *p3, *p4; |
563 | 84 ngx_tm_t tm, gmt; |
3474
d4c4cfdffe30
*) use previously cached GMT offset value to update time from a signal handler
Igor Sysoev <igor@sysoev.ru>
parents:
2220
diff
changeset
|
85 time_t sec; |
d4c4cfdffe30
*) use previously cached GMT offset value to update time from a signal handler
Igor Sysoev <igor@sysoev.ru>
parents:
2220
diff
changeset
|
86 ngx_uint_t msec; |
563 | 87 ngx_time_t *tp; |
88 struct timeval tv; | |
182
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
89 |
563 | 90 if (!ngx_trylock(&ngx_time_lock)) { |
271
e16dfb9b9afa
nginx-0.0.2-2004-02-26-20:10:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
270
diff
changeset
|
91 return; |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
92 } |
370
54f76b0b8dca
nginx-0.0.7-2004-06-27-22:01:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
93 |
3474
d4c4cfdffe30
*) use previously cached GMT offset value to update time from a signal handler
Igor Sysoev <igor@sysoev.ru>
parents:
2220
diff
changeset
|
94 ngx_gettimeofday(&tv); |
563 | 95 |
3474
d4c4cfdffe30
*) use previously cached GMT offset value to update time from a signal handler
Igor Sysoev <igor@sysoev.ru>
parents:
2220
diff
changeset
|
96 sec = tv.tv_sec; |
d4c4cfdffe30
*) use previously cached GMT offset value to update time from a signal handler
Igor Sysoev <igor@sysoev.ru>
parents:
2220
diff
changeset
|
97 msec = tv.tv_usec / 1000; |
563 | 98 |
7222
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
99 ngx_current_msec = ngx_monotonic_time(sec, msec); |
563 | 100 |
101 tp = &cached_time[slot]; | |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
102 |
563 | 103 if (tp->sec == sec) { |
891
8a3ba663be1a
slot number must be incremented once per second only,
Igor Sysoev <igor@sysoev.ru>
parents:
563
diff
changeset
|
104 tp->msec = msec; |
563 | 105 ngx_unlock(&ngx_time_lock); |
106 return; | |
107 } | |
370
54f76b0b8dca
nginx-0.0.7-2004-06-27-22:01:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
358
diff
changeset
|
108 |
1086
a62d30719ea1
fix segfault if nginx was build with -O2 -fomit-frame-pointer,
Igor Sysoev <igor@sysoev.ru>
parents:
1081
diff
changeset
|
109 if (slot == NGX_TIME_SLOTS - 1) { |
891
8a3ba663be1a
slot number must be incremented once per second only,
Igor Sysoev <igor@sysoev.ru>
parents:
563
diff
changeset
|
110 slot = 0; |
8a3ba663be1a
slot number must be incremented once per second only,
Igor Sysoev <igor@sysoev.ru>
parents:
563
diff
changeset
|
111 } else { |
8a3ba663be1a
slot number must be incremented once per second only,
Igor Sysoev <igor@sysoev.ru>
parents:
563
diff
changeset
|
112 slot++; |
8a3ba663be1a
slot number must be incremented once per second only,
Igor Sysoev <igor@sysoev.ru>
parents:
563
diff
changeset
|
113 } |
8a3ba663be1a
slot number must be incremented once per second only,
Igor Sysoev <igor@sysoev.ru>
parents:
563
diff
changeset
|
114 |
8a3ba663be1a
slot number must be incremented once per second only,
Igor Sysoev <igor@sysoev.ru>
parents:
563
diff
changeset
|
115 tp = &cached_time[slot]; |
8a3ba663be1a
slot number must be incremented once per second only,
Igor Sysoev <igor@sysoev.ru>
parents:
563
diff
changeset
|
116 |
563 | 117 tp->sec = sec; |
891
8a3ba663be1a
slot number must be incremented once per second only,
Igor Sysoev <igor@sysoev.ru>
parents:
563
diff
changeset
|
118 tp->msec = msec; |
563 | 119 |
120 ngx_gmtime(sec, &gmt); | |
181
811bdd2af794
nginx-0.0.1-2003-11-12-20:25:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
180
diff
changeset
|
121 |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
122 |
1081
4cf9d9b644f7
fix segfault if nginx was build with -O2 -fomit-frame-pointer
Igor Sysoev <igor@sysoev.ru>
parents:
932
diff
changeset
|
123 p0 = &cached_http_time[slot][0]; |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
124 |
563 | 125 (void) ngx_sprintf(p0, "%s, %02d %s %4d %02d:%02d:%02d GMT", |
126 week[gmt.ngx_tm_wday], gmt.ngx_tm_mday, | |
127 months[gmt.ngx_tm_mon - 1], gmt.ngx_tm_year, | |
128 gmt.ngx_tm_hour, gmt.ngx_tm_min, gmt.ngx_tm_sec); | |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
129 |
469 | 130 #if (NGX_HAVE_GETTIMEZONE) |
358
0a03c921c81d
nginx-0.0.7-2004-06-17-21:18:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
326
diff
changeset
|
131 |
563 | 132 tp->gmtoff = ngx_gettimezone(); |
133 ngx_gmtime(sec + tp->gmtoff * 60, &tm); | |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
134 |
3475
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
135 #elif (NGX_HAVE_GMTOFF) |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
136 |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
137 ngx_localtime(sec, &tm); |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
138 cached_gmtoff = (ngx_int_t) (tm.ngx_tm_gmtoff / 60); |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
139 tp->gmtoff = cached_gmtoff; |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
140 |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
141 #else |
178
a8ff48d26cca
nginx-0.0.1-2003-11-11-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
142 |
3475
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
143 ngx_localtime(sec, &tm); |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
144 cached_gmtoff = ngx_timezone(tm.ngx_tm_isdst); |
3474
d4c4cfdffe30
*) use previously cached GMT offset value to update time from a signal handler
Igor Sysoev <igor@sysoev.ru>
parents:
2220
diff
changeset
|
145 tp->gmtoff = cached_gmtoff; |
178
a8ff48d26cca
nginx-0.0.1-2003-11-11-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
146 |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
147 #endif |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
148 |
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
149 |
1081
4cf9d9b644f7
fix segfault if nginx was build with -O2 -fomit-frame-pointer
Igor Sysoev <igor@sysoev.ru>
parents:
932
diff
changeset
|
150 p1 = &cached_err_log_time[slot][0]; |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
151 |
563 | 152 (void) ngx_sprintf(p1, "%4d/%02d/%02d %02d:%02d:%02d", |
517 | 153 tm.ngx_tm_year, tm.ngx_tm_mon, |
154 tm.ngx_tm_mday, tm.ngx_tm_hour, | |
155 tm.ngx_tm_min, tm.ngx_tm_sec); | |
182
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
156 |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
157 |
1081
4cf9d9b644f7
fix segfault if nginx was build with -O2 -fomit-frame-pointer
Igor Sysoev <igor@sysoev.ru>
parents:
932
diff
changeset
|
158 p2 = &cached_http_log_time[slot][0]; |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
159 |
6481
40bea39731d7
Fixed format specifiers in ngx_sprintf().
Sergey Kandaurov <pluknet@nginx.com>
parents:
5702
diff
changeset
|
160 (void) ngx_sprintf(p2, "%02d/%s/%d:%02d:%02d:%02d %c%02i%02i", |
517 | 161 tm.ngx_tm_mday, months[tm.ngx_tm_mon - 1], |
162 tm.ngx_tm_year, tm.ngx_tm_hour, | |
163 tm.ngx_tm_min, tm.ngx_tm_sec, | |
563 | 164 tp->gmtoff < 0 ? '-' : '+', |
165 ngx_abs(tp->gmtoff / 60), ngx_abs(tp->gmtoff % 60)); | |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
166 |
3873 | 167 p3 = &cached_http_log_iso8601[slot][0]; |
168 | |
6481
40bea39731d7
Fixed format specifiers in ngx_sprintf().
Sergey Kandaurov <pluknet@nginx.com>
parents:
5702
diff
changeset
|
169 (void) ngx_sprintf(p3, "%4d-%02d-%02dT%02d:%02d:%02d%c%02i:%02i", |
3873 | 170 tm.ngx_tm_year, tm.ngx_tm_mon, |
171 tm.ngx_tm_mday, tm.ngx_tm_hour, | |
172 tm.ngx_tm_min, tm.ngx_tm_sec, | |
173 tp->gmtoff < 0 ? '-' : '+', | |
174 ngx_abs(tp->gmtoff / 60), ngx_abs(tp->gmtoff % 60)); | |
175 | |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
4782
diff
changeset
|
176 p4 = &cached_syslog_time[slot][0]; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
4782
diff
changeset
|
177 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
4782
diff
changeset
|
178 (void) ngx_sprintf(p4, "%s %2d %02d:%02d:%02d", |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
4782
diff
changeset
|
179 months[tm.ngx_tm_mon - 1], tm.ngx_tm_mday, |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
4782
diff
changeset
|
180 tm.ngx_tm_hour, tm.ngx_tm_min, tm.ngx_tm_sec); |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
181 |
563 | 182 ngx_memory_barrier(); |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
245
diff
changeset
|
183 |
563 | 184 ngx_cached_time = tp; |
185 ngx_cached_http_time.data = p0; | |
186 ngx_cached_err_log_time.data = p1; | |
187 ngx_cached_http_log_time.data = p2; | |
3873 | 188 ngx_cached_http_log_iso8601.data = p3; |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
4782
diff
changeset
|
189 ngx_cached_syslog_time.data = p4; |
563 | 190 |
191 ngx_unlock(&ngx_time_lock); | |
178
a8ff48d26cca
nginx-0.0.1-2003-11-11-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
192 } |
182
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
193 |
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
194 |
7222
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
195 static ngx_msec_t |
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
196 ngx_monotonic_time(time_t sec, ngx_uint_t msec) |
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
197 { |
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
198 #if (NGX_HAVE_CLOCK_MONOTONIC) |
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
199 struct timespec ts; |
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
200 |
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
201 #if defined(CLOCK_MONOTONIC_FAST) |
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
202 clock_gettime(CLOCK_MONOTONIC_FAST, &ts); |
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
203 |
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
204 #elif defined(CLOCK_MONOTONIC_COARSE) |
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
205 clock_gettime(CLOCK_MONOTONIC_COARSE, &ts); |
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
206 |
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
207 #else |
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
208 clock_gettime(CLOCK_MONOTONIC, &ts); |
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
209 #endif |
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
210 |
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
211 sec = ts.tv_sec; |
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
212 msec = ts.tv_nsec / 1000000; |
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
213 |
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
214 #endif |
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
215 |
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
216 return (ngx_msec_t) sec * 1000 + msec; |
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
217 } |
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
218 |
81fae70d6cb8
Core: ngx_current_msec now uses monotonic time if available.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7104
diff
changeset
|
219 |
3475
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
220 #if !(NGX_WIN32) |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
221 |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
222 void |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
223 ngx_time_sigsafe_update(void) |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
224 { |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
4782
diff
changeset
|
225 u_char *p, *p2; |
3475
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
226 ngx_tm_t tm; |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
227 time_t sec; |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
228 ngx_time_t *tp; |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
229 struct timeval tv; |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
230 |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
231 if (!ngx_trylock(&ngx_time_lock)) { |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
232 return; |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
233 } |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
234 |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
235 ngx_gettimeofday(&tv); |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
236 |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
237 sec = tv.tv_sec; |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
238 |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
239 tp = &cached_time[slot]; |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
240 |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
241 if (tp->sec == sec) { |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
242 ngx_unlock(&ngx_time_lock); |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
243 return; |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
244 } |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
245 |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
246 if (slot == NGX_TIME_SLOTS - 1) { |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
247 slot = 0; |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
248 } else { |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
249 slot++; |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
250 } |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
251 |
4782
e23892a0c917
Fixed possible use of old cached times if runtime went backwards.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
252 tp = &cached_time[slot]; |
e23892a0c917
Fixed possible use of old cached times if runtime went backwards.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
253 |
e23892a0c917
Fixed possible use of old cached times if runtime went backwards.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
254 tp->sec = 0; |
e23892a0c917
Fixed possible use of old cached times if runtime went backwards.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
255 |
3475
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
256 ngx_gmtime(sec + cached_gmtoff * 60, &tm); |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
257 |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
258 p = &cached_err_log_time[slot][0]; |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
259 |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
260 (void) ngx_sprintf(p, "%4d/%02d/%02d %02d:%02d:%02d", |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
261 tm.ngx_tm_year, tm.ngx_tm_mon, |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
262 tm.ngx_tm_mday, tm.ngx_tm_hour, |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
263 tm.ngx_tm_min, tm.ngx_tm_sec); |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
264 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
4782
diff
changeset
|
265 p2 = &cached_syslog_time[slot][0]; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
4782
diff
changeset
|
266 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
4782
diff
changeset
|
267 (void) ngx_sprintf(p2, "%s %2d %02d:%02d:%02d", |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
4782
diff
changeset
|
268 months[tm.ngx_tm_mon - 1], tm.ngx_tm_mday, |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
4782
diff
changeset
|
269 tm.ngx_tm_hour, tm.ngx_tm_min, tm.ngx_tm_sec); |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
4782
diff
changeset
|
270 |
3475
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
271 ngx_memory_barrier(); |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
272 |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
273 ngx_cached_err_log_time.data = p; |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
4782
diff
changeset
|
274 ngx_cached_syslog_time.data = p2; |
3475
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
275 |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
276 ngx_unlock(&ngx_time_lock); |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
277 } |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
278 |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
279 #endif |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
280 |
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
281 |
501 | 282 u_char * |
283 ngx_http_time(u_char *buf, time_t t) | |
182
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
284 { |
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
285 ngx_tm_t tm; |
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
286 |
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
287 ngx_gmtime(t, &tm); |
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
288 |
455 | 289 return ngx_sprintf(buf, "%s, %02d %s %4d %02d:%02d:%02d GMT", |
290 week[tm.ngx_tm_wday], | |
291 tm.ngx_tm_mday, | |
292 months[tm.ngx_tm_mon - 1], | |
293 tm.ngx_tm_year, | |
294 tm.ngx_tm_hour, | |
295 tm.ngx_tm_min, | |
296 tm.ngx_tm_sec); | |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
388
diff
changeset
|
297 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
388
diff
changeset
|
298 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
388
diff
changeset
|
299 |
501 | 300 u_char * |
301 ngx_http_cookie_time(u_char *buf, time_t t) | |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
388
diff
changeset
|
302 { |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
388
diff
changeset
|
303 ngx_tm_t tm; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
388
diff
changeset
|
304 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
388
diff
changeset
|
305 ngx_gmtime(t, &tm); |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
388
diff
changeset
|
306 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
388
diff
changeset
|
307 /* |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
388
diff
changeset
|
308 * Netscape 3.x does not understand 4-digit years at all and |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
388
diff
changeset
|
309 * 2-digit years more than "37" |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
388
diff
changeset
|
310 */ |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
388
diff
changeset
|
311 |
455 | 312 return ngx_sprintf(buf, |
313 (tm.ngx_tm_year > 2037) ? | |
314 "%s, %02d-%s-%d %02d:%02d:%02d GMT": | |
315 "%s, %02d-%s-%02d %02d:%02d:%02d GMT", | |
316 week[tm.ngx_tm_wday], | |
317 tm.ngx_tm_mday, | |
318 months[tm.ngx_tm_mon - 1], | |
319 (tm.ngx_tm_year > 2037) ? tm.ngx_tm_year: | |
320 tm.ngx_tm_year % 100, | |
321 tm.ngx_tm_hour, | |
322 tm.ngx_tm_min, | |
323 tm.ngx_tm_sec); | |
182
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
324 } |
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
325 |
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
326 |
501 | 327 void |
328 ngx_gmtime(time_t t, ngx_tm_t *tp) | |
182
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
329 { |
1970
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
330 ngx_int_t yday; |
7103
644d0457782a
Fixed ngx_gmtime() on 32-bit platforms with 64-bit time_t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7102
diff
changeset
|
331 ngx_uint_t sec, min, hour, mday, mon, year, wday, days, leap; |
182
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
332 |
1874
085e536d856d
treat time_t as unsigned time
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
333 /* the calculation is valid for positive time_t only */ |
1970
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
334 |
7103
644d0457782a
Fixed ngx_gmtime() on 32-bit platforms with 64-bit time_t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7102
diff
changeset
|
335 if (t < 0) { |
644d0457782a
Fixed ngx_gmtime() on 32-bit platforms with 64-bit time_t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7102
diff
changeset
|
336 t = 0; |
644d0457782a
Fixed ngx_gmtime() on 32-bit platforms with 64-bit time_t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7102
diff
changeset
|
337 } |
1874
085e536d856d
treat time_t as unsigned time
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
338 |
7103
644d0457782a
Fixed ngx_gmtime() on 32-bit platforms with 64-bit time_t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7102
diff
changeset
|
339 days = t / 86400; |
644d0457782a
Fixed ngx_gmtime() on 32-bit platforms with 64-bit time_t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7102
diff
changeset
|
340 sec = t % 86400; |
182
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
341 |
7104
cdbcb73239ee
Introduced time truncation to December 31, 9999 (ticket #1368).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7103
diff
changeset
|
342 /* |
cdbcb73239ee
Introduced time truncation to December 31, 9999 (ticket #1368).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7103
diff
changeset
|
343 * no more than 4 year digits supported, |
cdbcb73239ee
Introduced time truncation to December 31, 9999 (ticket #1368).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7103
diff
changeset
|
344 * truncate to December 31, 9999, 23:59:59 |
cdbcb73239ee
Introduced time truncation to December 31, 9999 (ticket #1368).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7103
diff
changeset
|
345 */ |
cdbcb73239ee
Introduced time truncation to December 31, 9999 (ticket #1368).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7103
diff
changeset
|
346 |
cdbcb73239ee
Introduced time truncation to December 31, 9999 (ticket #1368).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7103
diff
changeset
|
347 if (days > 2932896) { |
cdbcb73239ee
Introduced time truncation to December 31, 9999 (ticket #1368).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7103
diff
changeset
|
348 days = 2932896; |
cdbcb73239ee
Introduced time truncation to December 31, 9999 (ticket #1368).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7103
diff
changeset
|
349 sec = 86399; |
cdbcb73239ee
Introduced time truncation to December 31, 9999 (ticket #1368).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7103
diff
changeset
|
350 } |
cdbcb73239ee
Introduced time truncation to December 31, 9999 (ticket #1368).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7103
diff
changeset
|
351 |
4499
778ef9c3fd2d
Fixed spelling in single-line comments.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
352 /* January 1, 1970 was Thursday */ |
1970
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
353 |
182
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
354 wday = (4 + days) % 7; |
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
355 |
7103
644d0457782a
Fixed ngx_gmtime() on 32-bit platforms with 64-bit time_t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7102
diff
changeset
|
356 hour = sec / 3600; |
644d0457782a
Fixed ngx_gmtime() on 32-bit platforms with 64-bit time_t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7102
diff
changeset
|
357 sec %= 3600; |
644d0457782a
Fixed ngx_gmtime() on 32-bit platforms with 64-bit time_t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7102
diff
changeset
|
358 min = sec / 60; |
644d0457782a
Fixed ngx_gmtime() on 32-bit platforms with 64-bit time_t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7102
diff
changeset
|
359 sec %= 60; |
182
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
360 |
1970
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
361 /* |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
362 * the algorithm based on Gauss' formula, |
7102
63699a40e2ff
Fixed reference to time parsing code after 8b6fa4842133.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6481
diff
changeset
|
363 * see src/core/ngx_parse_time.c |
1970
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
364 */ |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
365 |
1970
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
366 /* days since March 1, 1 BC */ |
182
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
367 days = days - (31 + 28) + 719527; |
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
368 |
1970
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
369 /* |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
370 * The "days" should be adjusted to 1 only, however, some March 1st's go |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
371 * to previous year, so we adjust them to 2. This causes also shift of the |
4572
67653855682e
Fixed spelling in multiline C comments.
Ruslan Ermilov <ru@nginx.com>
parents:
4499
diff
changeset
|
372 * last February days to next year, but we catch the case when "yday" |
1970
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
373 * becomes negative. |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
374 */ |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
375 |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
376 year = (days + 2) * 400 / (365 * 400 + 100 - 4 + 1); |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
377 |
182
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
378 yday = days - (365 * year + year / 4 - year / 100 + year / 400); |
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
379 |
1970
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
380 if (yday < 0) { |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
381 leap = (year % 4 == 0) && (year % 100 || (year % 400 == 0)); |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
382 yday = 365 + leap + yday; |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
383 year--; |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
384 } |
182
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
385 |
1970
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
386 /* |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
387 * The empirical formula that maps "yday" to month. |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
388 * There are at least 10 variants, some of them are: |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
389 * mon = (yday + 31) * 15 / 459 |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
390 * mon = (yday + 31) * 17 / 520 |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
391 * mon = (yday + 31) * 20 / 612 |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
392 */ |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
393 |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
394 mon = (yday + 31) * 10 / 306; |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
395 |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
396 /* the Gauss' formula that evaluates days before the month */ |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
397 |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
398 mday = yday - (367 * mon / 12 - 30) + 1; |
182
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
399 |
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
400 if (yday >= 306) { |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
433
diff
changeset
|
401 |
1970
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
402 year++; |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
403 mon -= 10; |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
404 |
297
ee394e997c77
nginx-0.0.3-2004-03-29-21:43:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
405 /* |
324
0ab66f4b6c4d
nginx-0.0.3-2004-04-22-00:13:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
406 * there is no "yday" in Win32 SYSTEMTIME |
297
ee394e997c77
nginx-0.0.3-2004-03-29-21:43:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
407 * |
ee394e997c77
nginx-0.0.3-2004-03-29-21:43:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
408 * yday -= 306; |
ee394e997c77
nginx-0.0.3-2004-03-29-21:43:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
409 */ |
ee394e997c77
nginx-0.0.3-2004-03-29-21:43:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
410 |
1970
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
411 } else { |
182
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
412 |
1970
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
413 mon += 2; |
182
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
414 |
1970
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
415 /* |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
416 * there is no "yday" in Win32 SYSTEMTIME |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
417 * |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
418 * yday += 31 + 28 + leap; |
5bb2c374cab2
use more straightforward ngx_gmtime() implementation
Igor Sysoev <igor@sysoev.ru>
parents:
1874
diff
changeset
|
419 */ |
182
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
420 } |
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
421 |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
271
diff
changeset
|
422 tp->ngx_tm_sec = (ngx_tm_sec_t) sec; |
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
271
diff
changeset
|
423 tp->ngx_tm_min = (ngx_tm_min_t) min; |
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
271
diff
changeset
|
424 tp->ngx_tm_hour = (ngx_tm_hour_t) hour; |
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
271
diff
changeset
|
425 tp->ngx_tm_mday = (ngx_tm_mday_t) mday; |
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
271
diff
changeset
|
426 tp->ngx_tm_mon = (ngx_tm_mon_t) mon; |
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
271
diff
changeset
|
427 tp->ngx_tm_year = (ngx_tm_year_t) year; |
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
271
diff
changeset
|
428 tp->ngx_tm_wday = (ngx_tm_wday_t) wday; |
182
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
181
diff
changeset
|
429 } |
2162 | 430 |
431 | |
432 time_t | |
433 ngx_next_time(time_t when) | |
434 { | |
435 time_t now, next; | |
436 struct tm tm; | |
437 | |
438 now = ngx_time(); | |
439 | |
440 ngx_libc_localtime(now, &tm); | |
441 | |
442 tm.tm_hour = (int) (when / 3600); | |
443 when %= 3600; | |
444 tm.tm_min = (int) (when / 60); | |
445 tm.tm_sec = (int) (when % 60); | |
446 | |
447 next = mktime(&tm); | |
448 | |
449 if (next == -1) { | |
450 return -1; | |
451 } | |
452 | |
453 if (next - now > 0) { | |
454 return next; | |
455 } | |
456 | |
457 tm.tm_mday++; | |
458 | |
459 /* mktime() should normalize a date (Jan 32, etc) */ | |
460 | |
461 next = mktime(&tm); | |
462 | |
463 if (next != -1) { | |
464 return next; | |
465 } | |
466 | |
467 return -1; | |
468 } |