diff options
Diffstat (limited to 'src/core/ngx_times.c')
-rw-r--r-- | src/core/ngx_times.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/core/ngx_times.c b/src/core/ngx_times.c index 43c8c204a..235e7032d 100644 --- a/src/core/ngx_times.c +++ b/src/core/ngx_times.c @@ -51,15 +51,22 @@ void ngx_time_init() ngx_elapsed_msec = 0; ngx_time_update(tv.tv_sec); +} + + +#if (NGX_THREADS) -#if (NGX_THREADS0) - if (!(ngx_time_mutex = ngx_mutex_init(log, NGX_MUTEX_LIGHT); - return 0; +ngx_int_t ngx_time_mutex_init(ngx_log_t *log) +{ + if (!(ngx_time_mutex = ngx_mutex_init(log, NGX_MUTEX_LIGHT))) { + return NGX_ERROR; } -#endif + return NGX_OK; } +#endif + void ngx_time_update(time_t s) { @@ -69,9 +76,11 @@ void ngx_time_update(time_t s) return; } -#if (NGX_THREADS0) - if (ngx_mutex_trylock(ngx_time_mutex) != NGX_OK) { - return; +#if (NGX_THREADS) + if (ngx_time_mutex) { + if (ngx_mutex_trylock(ngx_time_mutex) != NGX_OK) { + return; + } } #endif @@ -109,8 +118,10 @@ void ngx_time_update(time_t s) tm.ngx_tm_min, tm.ngx_tm_sec); -#if (NGX_THREADS0) - ngx_mutex_unlock(ngx_time_mutex); +#if (NGX_THREADS) + if (ngx_time_mutex) { + ngx_mutex_unlock(ngx_time_mutex); + } #endif } |