Mercurial > hg > nginx
comparison src/event/ngx_event_timer.c @ 306:6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 04 Apr 2004 20:32:09 +0000 |
parents | b836469c37c3 |
children | 39b6f2df45c0 |
comparison
equal
deleted
inserted
replaced
305:4b1a3a4acc60 | 306:6b91bfbc4123 |
---|---|
40 | 40 |
41 if (ngx_event_timer_rbtree == &ngx_event_timer_sentinel) { | 41 if (ngx_event_timer_rbtree == &ngx_event_timer_sentinel) { |
42 return 0; | 42 return 0; |
43 } | 43 } |
44 | 44 |
45 #if (NGX_THREADS) | |
46 if (ngx_mutex_lock(ngx_event_timer_mutex) == NGX_ERROR) { | 45 if (ngx_mutex_lock(ngx_event_timer_mutex) == NGX_ERROR) { |
47 return NGX_TIMER_ERROR; | 46 return NGX_TIMER_ERROR; |
48 } | 47 } |
49 #endif | |
50 | 48 |
51 node = ngx_rbtree_min((ngx_rbtree_t *) ngx_event_timer_rbtree, | 49 node = ngx_rbtree_min((ngx_rbtree_t *) ngx_event_timer_rbtree, |
52 &ngx_event_timer_sentinel); | 50 &ngx_event_timer_sentinel); |
53 | 51 |
54 #if (NGX_THREADS) | |
55 ngx_mutex_unlock(ngx_event_timer_mutex); | 52 ngx_mutex_unlock(ngx_event_timer_mutex); |
56 #endif | |
57 | 53 |
58 return (ngx_msec_t) | 54 return (ngx_msec_t) |
59 (node->key * NGX_TIMER_RESOLUTION - | 55 (node->key * NGX_TIMER_RESOLUTION - |
60 ngx_elapsed_msec / NGX_TIMER_RESOLUTION * NGX_TIMER_RESOLUTION); | 56 ngx_elapsed_msec / NGX_TIMER_RESOLUTION * NGX_TIMER_RESOLUTION); |
61 #if 0 | 57 #if 0 |
73 | 69 |
74 if (ngx_event_timer_rbtree == &ngx_event_timer_sentinel) { | 70 if (ngx_event_timer_rbtree == &ngx_event_timer_sentinel) { |
75 break; | 71 break; |
76 } | 72 } |
77 | 73 |
78 #if (NGX_THREADS) | |
79 if (ngx_mutex_lock(ngx_event_timer_mutex) == NGX_ERROR) { | 74 if (ngx_mutex_lock(ngx_event_timer_mutex) == NGX_ERROR) { |
80 return; | 75 return; |
81 } | 76 } |
82 #endif | |
83 | 77 |
84 node = ngx_rbtree_min((ngx_rbtree_t *) ngx_event_timer_rbtree, | 78 node = ngx_rbtree_min((ngx_rbtree_t *) ngx_event_timer_rbtree, |
85 &ngx_event_timer_sentinel); | 79 &ngx_event_timer_sentinel); |
86 | 80 |
87 #if (NGX_THREADS) | |
88 ngx_mutex_unlock(ngx_event_timer_mutex); | 81 ngx_mutex_unlock(ngx_event_timer_mutex); |
89 #endif | |
90 | 82 |
91 if ((ngx_msec_t) node->key <= (ngx_msec_t) | 83 if ((ngx_msec_t) node->key <= (ngx_msec_t) |
92 (ngx_old_elapsed_msec + timer) / NGX_TIMER_RESOLUTION) | 84 (ngx_old_elapsed_msec + timer) / NGX_TIMER_RESOLUTION) |
93 { | 85 { |
94 ev = (ngx_event_t *) | 86 ev = (ngx_event_t *) |
104 | 96 |
105 } else { | 97 } else { |
106 ev->timedout = 1; | 98 ev->timedout = 1; |
107 } | 99 } |
108 | 100 |
109 #if (NGX_THREADS) | 101 if (ngx_threaded) { |
110 /* STUB: post event */ | 102 if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) { |
111 #endif | 103 return; |
104 } | |
105 | |
106 ngx_post_event(ev); | |
107 | |
108 ngx_mutex_unlock(ngx_posted_events_mutex); | |
109 continue; | |
110 } | |
112 | 111 |
113 ev->event_handler(ev); | 112 ev->event_handler(ev); |
114 continue; | 113 continue; |
115 } | 114 } |
116 | 115 |