Mercurial > hg > nginx
diff src/core/ngx_times.c @ 266:5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 23 Feb 2004 20:57:12 +0000 |
parents | e6c005b66b3a |
children | 7bb9562216ce |
line wrap: on
line diff
--- a/src/core/ngx_times.c +++ b/src/core/ngx_times.c @@ -3,6 +3,11 @@ #include <ngx_core.h> +#if (NGX_THREADS) +static ngx_mutex_t *ngx_time_mutex; +#endif + + time_t ngx_cached_time; ngx_epoch_msec_t ngx_elapsed_msec; ngx_epoch_msec_t ngx_old_elapsed_msec; @@ -46,6 +51,13 @@ void ngx_time_init() ngx_elapsed_msec = 0; ngx_time_update(tv.tv_sec); + +#if (NGX_THREADS0) + if (!(ngx_time_mutex = ngx_mutex_init(log, NGX_MUTEX_LIGHT); + return 0; + } +#endif + } @@ -57,6 +69,12 @@ void ngx_time_update(time_t s) return; } +#if (NGX_THREADS0) + if (ngx_mutex_trylock(ngx_time_mutex) != NGX_OK) { + return; + } +#endif + ngx_cached_time = s; ngx_gmtime(ngx_cached_time, &ngx_cached_gmtime); @@ -90,6 +108,11 @@ void ngx_time_update(time_t s) tm.ngx_tm_hour, tm.ngx_tm_min, tm.ngx_tm_sec); + +#if (NGX_THREADS0) + ngx_mutex_unlock(ngx_time_mutex); +#endif + }