aboutsummaryrefslogtreecommitdiff
path: root/src/os/unix/ngx_time.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2002-08-15 17:20:26 +0000
committerIgor Sysoev <igor@sysoev.ru>2002-08-15 17:20:26 +0000
commit0c331d9f666b4f9be91009b7caea457e58a80779 (patch)
treed48221581b361ee5b0ccad46e4df49caa41b1bba /src/os/unix/ngx_time.c
parent6de5c2cb63f8aee4bcbec3c363a72fd8e4a4e64d (diff)
downloadnginx-0c331d9f666b4f9be91009b7caea457e58a80779.tar.gz
nginx-0c331d9f666b4f9be91009b7caea457e58a80779.zip
nginx-0.0.1-2002-08-15-21:20:26 import
Diffstat (limited to 'src/os/unix/ngx_time.c')
-rw-r--r--src/os/unix/ngx_time.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/os/unix/ngx_time.c b/src/os/unix/ngx_time.c
index d4be966dd..5dfcb63f2 100644
--- a/src/os/unix/ngx_time.c
+++ b/src/os/unix/ngx_time.c
@@ -17,3 +17,70 @@ u_int ngx_msec(void)
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
}
+
+#if 0
+
+typedef struct {
+ int busy;
+ u_int_64 msec;
+ time_t sec;
+ tm;
+ http_time_len;
+ http_time[n];
+};
+
+volatile *ngx_time_p;
+
+ngx_time()
+{
+ p = ngx_time_p;
+}
+
+ngx_update_time()
+{
+ u_int64 msec;
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+
+ msec = (unsigned long) tv.tv_sec * 1000 + tv.tv_usec / 1000;
+ p = ngx_time_p;
+
+ /* minimum can be for example 0, 10, 50 or 100 ms */
+ if (tv_sec > p->sec || msec - p->msec >= minimum) {
+ old_p = p;
+ /* max_tries < max_slots - 10,
+ max_slots should be more than max of threads */
+ for (/* void */; i < max_tries; i++) {
+ if (++p >= last_slot)
+ p = first_slot;
+
+ if (!test_and_set(p->busy)
+ break;
+ }
+
+ if (i == max_tries) {
+ ngx_log_error();
+ return;
+ }
+
+ if (tv_sec > p->sec) {
+ p->sec = tv.tv.sec;
+ p->msec = msec;
+ localtime_r(&tv.tv_sec, tm);
+ make http stirng;
+
+ } else {
+ ngx_memcpy(p->sec, old_p->sec, sizeof() - offset_of(, sec));
+ p->msec = msec;
+ }
+
+ /* here can be too seldom and non-critical race condition */
+ if (ngx_time_p == old_p)
+ ngx_time_p = p;
+
+ unlock(p->busy);
+ }
+}
+
+#endif