aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2004-04-21 20:13:48 +0000
committerIgor Sysoev <igor@sysoev.ru>2004-04-21 20:13:48 +0000
commite772e8fef51291f8386cf3d85e4da56928c9a86b (patch)
tree983d06e674f981851f47cce5dc965992c7040cf1 /src
parent732a27196381164c799d345ec0d010b416408555 (diff)
downloadnginx-e772e8fef51291f8386cf3d85e4da56928c9a86b.tar.gz
nginx-e772e8fef51291f8386cf3d85e4da56928c9a86b.zip
nginx-0.0.3-2004-04-22-00:13:48 import
Diffstat (limited to 'src')
-rw-r--r--src/core/ngx_times.c39
-rw-r--r--src/os/unix/ngx_time.h12
-rw-r--r--src/os/win32/ngx_process_cycle.c2
-rw-r--r--src/os/win32/ngx_time.c12
-rw-r--r--src/os/win32/ngx_time.h2
5 files changed, 37 insertions, 30 deletions
diff --git a/src/core/ngx_times.c b/src/core/ngx_times.c
index bb1c49cb3..097186a25 100644
--- a/src/core/ngx_times.c
+++ b/src/core/ngx_times.c
@@ -86,11 +86,8 @@ ngx_int_t ngx_time_mutex_init(ngx_log_t *log)
void ngx_time_update(time_t s)
{
- char *p;
- ngx_tm_t tm;
-#if (WIN32)
- TIME_ZONE_INFORMATION tz;
-#endif
+ u_char *p;
+ ngx_tm_t tm;
if (ngx_cached_time == s) {
return;
@@ -113,7 +110,7 @@ void ngx_time_update(time_t s)
p = cached_http_time0;
}
- ngx_snprintf(p, sizeof("Mon, 28 Sep 1970 06:00:00 GMT"),
+ ngx_snprintf((char *) p, sizeof("Mon, 28 Sep 1970 06:00:00 GMT"),
"%s, %02d %s %4d %02d:%02d:%02d GMT",
week[ngx_cached_gmtime.ngx_tm_wday],
ngx_cached_gmtime.ngx_tm_mday,
@@ -126,27 +123,9 @@ void ngx_time_update(time_t s)
ngx_cached_http_time.data = p;
-#if (WIN32)
-
- /*
- * we do not use GetLocalTime() because it does not return GMT offset,
- * and our ngx_gmtime() is fast enough
- */
-
- if (GetTimeZoneInformation(&tz) != TIME_ZONE_ID_INVALID) {
- ngx_gmtoff = - tz.Bias;
- }
-
- ngx_gmtime(ngx_cached_time + ngx_gmtoff * 60, &tm);
-
-#elif (SOLARIS)
-
- ngx_gmtoff = (daylight) ? - altzone / 60: - timezone / 60;
- ngx_gmtime(ngx_cached_time + ngx_gmtoff * 60, &tm);
-
-#elif defined __linux__
+#if (HAVE_TIMEZONE)
- ngx_gmtoff = - timezone / 60 + daylight * 60;
+ ngx_gmtoff = ngx_timezone();
ngx_gmtime(ngx_cached_time + ngx_gmtoff * 60, &tm);
#else
@@ -163,7 +142,7 @@ void ngx_time_update(time_t s)
p = cached_err_log_time0;
}
- ngx_snprintf(p, sizeof("1970/09/28 12:00:00"),
+ ngx_snprintf((char *) p, sizeof("1970/09/28 12:00:00"),
"%4d/%02d/%02d %02d:%02d:%02d",
tm.ngx_tm_year, tm.ngx_tm_mon,
tm.ngx_tm_mday, tm.ngx_tm_hour,
@@ -178,7 +157,7 @@ void ngx_time_update(time_t s)
p = cached_http_log_time0;
}
- ngx_snprintf(p, sizeof("28/Sep/1970:12:00:00 +0600"),
+ ngx_snprintf((char *) p, sizeof("28/Sep/1970:12:00:00 +0600"),
"%02d/%s/%d:%02d:%02d:%02d %c%02d%02d",
tm.ngx_tm_mday, months[tm.ngx_tm_mon - 1],
tm.ngx_tm_year, tm.ngx_tm_hour,
@@ -243,7 +222,7 @@ void ngx_gmtime(time_t t, ngx_tm_t *tp)
if (yday >= 306) {
/*
- * yday is not used in Win32 SYSTEMTIME
+ * there is no "yday" in Win32 SYSTEMTIME
*
* yday -= 306;
*/
@@ -271,7 +250,7 @@ void ngx_gmtime(time_t t, ngx_tm_t *tp)
}
/*
- * yday is not used in Win32 SYSTEMTIME
+ * there is no "yday" in Win32 SYSTEMTIME
*
* } else {
* yday += 31 + 28;
diff --git a/src/os/unix/ngx_time.h b/src/os/unix/ngx_time.h
index bb03e994b..0b44c5ad4 100644
--- a/src/os/unix/ngx_time.h
+++ b/src/os/unix/ngx_time.h
@@ -35,6 +35,18 @@ typedef struct tm ngx_tm_t;
#define ngx_tm_wday_t int
+#if (SOLARIS)
+#define HAVE_TIMEZONE 1
+
+#define ngx_timezone() (-((daylight) ? altzone : timezone) / 60)
+
+#elif defined __linux__
+#define HAVE_TIMEZONE 1
+
+#define ngx_timezone() (- timezone / 60 + daylight * 60)
+
+#endif
+
void ngx_localtime(ngx_tm_t *tm);
diff --git a/src/os/win32/ngx_process_cycle.c b/src/os/win32/ngx_process_cycle.c
index ad5024b23..fa90494c5 100644
--- a/src/os/win32/ngx_process_cycle.c
+++ b/src/os/win32/ngx_process_cycle.c
@@ -34,6 +34,8 @@ sig_atomic_t ngx_change_binary;
void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
{
+ ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, "master mode is not supported");
+
exit(2);
}
diff --git a/src/os/win32/ngx_time.c b/src/os/win32/ngx_time.c
index 43d2c41cb..cef335707 100644
--- a/src/os/win32/ngx_time.c
+++ b/src/os/win32/ngx_time.c
@@ -29,3 +29,15 @@ void ngx_gettimeofday(struct timeval *tp)
tp->tv_sec = (long) (intervals / 10000000);
tp->tv_usec = (long) ((intervals % 10000000) / 10);
}
+
+
+ngx_int_t ngx_timezone(void)
+{
+ TIME_ZONE_INFORMATION tz;
+
+ if (GetTimeZoneInformation(&tz) != TIME_ZONE_ID_INVALID) {
+ return -tz.Bias;
+ }
+
+ return 0;
+}
diff --git a/src/os/win32/ngx_time.h b/src/os/win32/ngx_time.h
index 4bf377da3..9ed94baeb 100644
--- a/src/os/win32/ngx_time.h
+++ b/src/os/win32/ngx_time.h
@@ -34,7 +34,9 @@ typedef FILETIME ngx_mtime_t;
#define ngx_msleep Sleep
+#define HAVE_TIMEZONE 1
+ngx_int_t ngx_timezone(void);
void ngx_gettimeofday(struct timeval *tp);