diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/nginx.c | 8 | ||||
-rw-r--r-- | src/core/ngx_times.c | 29 | ||||
-rw-r--r-- | src/core/ngx_times.h | 3 |
3 files changed, 30 insertions, 10 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c index 592711522..21363d268 100644 --- a/src/core/nginx.c +++ b/src/core/nginx.c @@ -147,6 +147,12 @@ int main(int argc, char *const *argv, char **envp) ctx.argc = argc; ctx.argv = argv; +#if (NGX_THREADS) + if (ngx_time_mutex_init(log) == NGX_ERROR) { + return 1; + } +#endif + if (ngx_getopt(&ctx, &init_cycle) == NGX_ERROR) { return 1; } @@ -649,7 +655,7 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data) #if (NGX_THREADS) - if (ngx_init_threads(5, 128 * 1024 * 1024, cycle->log) == NGX_ERROR) { + if (ngx_init_threads(5, 128 * 1024 * 1024, cycle) == NGX_ERROR) { /* fatal */ exit(1); } 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 } diff --git a/src/core/ngx_times.h b/src/core/ngx_times.h index 7823af0b8..50910b1b4 100644 --- a/src/core/ngx_times.h +++ b/src/core/ngx_times.h @@ -7,6 +7,9 @@ void ngx_time_init(); +#if (NGX_THREADS) +ngx_int_t ngx_time_mutex_init(ngx_log_t *log); +#endif void ngx_time_update(time_t s); size_t ngx_http_time(char *buf, time_t t); void ngx_gmtime(time_t t, ngx_tm_t *tp); |