Mercurial > hg > nginx
comparison src/core/ngx_times.c @ 270:7bb9562216ce
nginx-0.0.2-2004-02-25-23:16:15 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 25 Feb 2004 20:16:15 +0000 |
parents | 5238e93961a1 |
children | e16dfb9b9afa |
comparison
equal
deleted
inserted
replaced
269:f082cb6bcdd7 | 270:7bb9562216ce |
---|---|
49 ngx_start_msec = tv.tv_sec * 1000 + tv.tv_usec / 1000; | 49 ngx_start_msec = tv.tv_sec * 1000 + tv.tv_usec / 1000; |
50 ngx_old_elapsed_msec = 0; | 50 ngx_old_elapsed_msec = 0; |
51 ngx_elapsed_msec = 0; | 51 ngx_elapsed_msec = 0; |
52 | 52 |
53 ngx_time_update(tv.tv_sec); | 53 ngx_time_update(tv.tv_sec); |
54 | 54 } |
55 #if (NGX_THREADS0) | 55 |
56 if (!(ngx_time_mutex = ngx_mutex_init(log, NGX_MUTEX_LIGHT); | 56 |
57 return 0; | 57 #if (NGX_THREADS) |
58 } | 58 |
59 #endif | 59 ngx_int_t ngx_time_mutex_init(ngx_log_t *log) |
60 | 60 { |
61 } | 61 if (!(ngx_time_mutex = ngx_mutex_init(log, NGX_MUTEX_LIGHT))) { |
62 return NGX_ERROR; | |
63 } | |
64 | |
65 return NGX_OK; | |
66 } | |
67 | |
68 #endif | |
62 | 69 |
63 | 70 |
64 void ngx_time_update(time_t s) | 71 void ngx_time_update(time_t s) |
65 { | 72 { |
66 ngx_tm_t tm; | 73 ngx_tm_t tm; |
67 | 74 |
68 if (ngx_cached_time == s) { | 75 if (ngx_cached_time == s) { |
69 return; | 76 return; |
70 } | 77 } |
71 | 78 |
72 #if (NGX_THREADS0) | 79 #if (NGX_THREADS) |
73 if (ngx_mutex_trylock(ngx_time_mutex) != NGX_OK) { | 80 if (ngx_time_mutex) { |
74 return; | 81 if (ngx_mutex_trylock(ngx_time_mutex) != NGX_OK) { |
82 return; | |
83 } | |
75 } | 84 } |
76 #endif | 85 #endif |
77 | 86 |
78 ngx_cached_time = s; | 87 ngx_cached_time = s; |
79 | 88 |
107 tm.ngx_tm_year, | 116 tm.ngx_tm_year, |
108 tm.ngx_tm_hour, | 117 tm.ngx_tm_hour, |
109 tm.ngx_tm_min, | 118 tm.ngx_tm_min, |
110 tm.ngx_tm_sec); | 119 tm.ngx_tm_sec); |
111 | 120 |
112 #if (NGX_THREADS0) | 121 #if (NGX_THREADS) |
113 ngx_mutex_unlock(ngx_time_mutex); | 122 if (ngx_time_mutex) { |
123 ngx_mutex_unlock(ngx_time_mutex); | |
124 } | |
114 #endif | 125 #endif |
115 | 126 |
116 } | 127 } |
117 | 128 |
118 | 129 |