Mercurial > hg > nginx
comparison src/os/unix/ngx_time.c @ 1:d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 15 Aug 2002 17:20:26 +0000 |
parents | 4eff17414a43 |
children | a117a7fdf042 |
comparison
equal
deleted
inserted
replaced
0:4eff17414a43 | 1:d220029ac7f3 |
---|---|
15 gettimeofday(&tv, NULL); | 15 gettimeofday(&tv, NULL); |
16 | 16 |
17 return tv.tv_sec * 1000 + tv.tv_usec / 1000; | 17 return tv.tv_sec * 1000 + tv.tv_usec / 1000; |
18 } | 18 } |
19 | 19 |
20 | |
21 #if 0 | |
22 | |
23 typedef struct { | |
24 int busy; | |
25 u_int_64 msec; | |
26 time_t sec; | |
27 tm; | |
28 http_time_len; | |
29 http_time[n]; | |
30 }; | |
31 | |
32 volatile *ngx_time_p; | |
33 | |
34 ngx_time() | |
35 { | |
36 p = ngx_time_p; | |
37 } | |
38 | |
39 ngx_update_time() | |
40 { | |
41 u_int64 msec; | |
42 struct timeval tv; | |
43 | |
44 gettimeofday(&tv, NULL); | |
45 | |
46 msec = (unsigned long) tv.tv_sec * 1000 + tv.tv_usec / 1000; | |
47 p = ngx_time_p; | |
48 | |
49 /* minimum can be for example 0, 10, 50 or 100 ms */ | |
50 if (tv_sec > p->sec || msec - p->msec >= minimum) { | |
51 old_p = p; | |
52 /* max_tries < max_slots - 10, | |
53 max_slots should be more than max of threads */ | |
54 for (/* void */; i < max_tries; i++) { | |
55 if (++p >= last_slot) | |
56 p = first_slot; | |
57 | |
58 if (!test_and_set(p->busy) | |
59 break; | |
60 } | |
61 | |
62 if (i == max_tries) { | |
63 ngx_log_error(); | |
64 return; | |
65 } | |
66 | |
67 if (tv_sec > p->sec) { | |
68 p->sec = tv.tv.sec; | |
69 p->msec = msec; | |
70 localtime_r(&tv.tv_sec, tm); | |
71 make http stirng; | |
72 | |
73 } else { | |
74 ngx_memcpy(p->sec, old_p->sec, sizeof() - offset_of(, sec)); | |
75 p->msec = msec; | |
76 } | |
77 | |
78 /* here can be too seldom and non-critical race condition */ | |
79 if (ngx_time_p == old_p) | |
80 ngx_time_p = p; | |
81 | |
82 unlock(p->busy); | |
83 } | |
84 } | |
85 | |
86 #endif |