comparison src/os/unix/ngx_time.c @ 305:4b1a3a4acc60

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