Mercurial > hg > nginx-vendor-0-5
comparison src/event/ngx_event_busy_lock.c @ 112:408f195b3482 NGINX_0_3_3
nginx 0.3.3
*) Change: the "bl" and "af" parameters of the "listen" directive was
renamed to the "backlog" and "accept_filter".
*) Feature: the "rcvbuf" and "sndbuf" parameters of the "listen"
directive.
*) Change: the "$msec" log parameter does not require now the
additional the gettimeofday() system call.
*) Feature: the -t switch now tests the "listen" directives.
*) Bugfix: if the invalid address was specified in the "listen"
directive, then after the -HUP signal nginx left an open socket in
the CLOSED state.
*) Bugfix: the mime type may be incorrectly set to default value for
index file with variable in the name; bug appeared in 0.3.0.
*) Feature: the "timer_resolution" directive.
*) Feature: the millisecond "$upstream_response_time" log parameter.
*) Bugfix: a temporary file with client request body now is removed
just after the response header was transferred to a client.
*) Bugfix: OpenSSL 0.9.6 compatibility.
*) Bugfix: the SSL certificate and key file paths could not be relative.
*) Bugfix: the "ssl_prefer_server_ciphers" directive did not work in
the ngx_imap_ssl_module.
*) Bugfix: the "ssl_protocols" directive allowed to specify the single
protocol only.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Wed, 19 Oct 2005 00:00:00 +0400 |
parents | b55cbf18157e |
children | bb61aa162c6b |
comparison
equal
deleted
inserted
replaced
111:a175b609c76d | 112:408f195b3482 |
---|---|
8 #include <ngx_core.h> | 8 #include <ngx_core.h> |
9 #include <ngx_event.h> | 9 #include <ngx_event.h> |
10 | 10 |
11 | 11 |
12 static int ngx_event_busy_lock_look_cachable(ngx_event_busy_lock_t *bl, | 12 static int ngx_event_busy_lock_look_cachable(ngx_event_busy_lock_t *bl, |
13 ngx_event_busy_lock_ctx_t *ctx); | 13 ngx_event_busy_lock_ctx_t *ctx); |
14 static void ngx_event_busy_lock_handler(ngx_event_t *ev); | 14 static void ngx_event_busy_lock_handler(ngx_event_t *ev); |
15 static void ngx_event_busy_lock_posted_handler(ngx_event_t *ev); | 15 static void ngx_event_busy_lock_posted_handler(ngx_event_t *ev); |
16 | 16 |
17 | 17 |
18 /* | 18 /* |
21 * NGX_BUSY: ctx->timer == 0: there are many the busy locks | 21 * NGX_BUSY: ctx->timer == 0: there are many the busy locks |
22 * ctx->timer != 0: there are many the waiting locks | 22 * ctx->timer != 0: there are many the waiting locks |
23 * NGX_ERROR: an error occured while the mutex locking | 23 * NGX_ERROR: an error occured while the mutex locking |
24 */ | 24 */ |
25 | 25 |
26 ngx_int_t ngx_event_busy_lock(ngx_event_busy_lock_t *bl, | 26 ngx_int_t |
27 ngx_event_busy_lock_ctx_t *ctx) | 27 ngx_event_busy_lock(ngx_event_busy_lock_t *bl, ngx_event_busy_lock_ctx_t *ctx) |
28 { | 28 { |
29 ngx_int_t rc; | 29 ngx_int_t rc; |
30 | 30 |
31 if (ngx_mutex_lock(bl->mutex) == NGX_ERROR) { | 31 ngx_mutex_lock(bl->mutex); |
32 return NGX_ERROR; | |
33 } | |
34 | 32 |
35 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ctx->event->log, 0, | 33 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ctx->event->log, 0, |
36 "event busy lock: b:%d mb:%d", | 34 "event busy lock: b:%d mb:%d", |
37 bl->busy, bl->max_busy); | 35 bl->busy, bl->max_busy); |
38 | 36 |
64 | 62 |
65 return rc; | 63 return rc; |
66 } | 64 } |
67 | 65 |
68 | 66 |
69 ngx_int_t ngx_event_busy_lock_cachable(ngx_event_busy_lock_t *bl, | 67 ngx_int_t |
70 ngx_event_busy_lock_ctx_t *ctx) | 68 ngx_event_busy_lock_cachable(ngx_event_busy_lock_t *bl, |
69 ngx_event_busy_lock_ctx_t *ctx) | |
71 { | 70 { |
72 ngx_int_t rc; | 71 ngx_int_t rc; |
73 | 72 |
74 if (ngx_mutex_lock(bl->mutex) == NGX_ERROR) { | 73 ngx_mutex_lock(bl->mutex); |
75 return NGX_ERROR; | |
76 } | |
77 | 74 |
78 rc = ngx_event_busy_lock_look_cachable(bl, ctx); | 75 rc = ngx_event_busy_lock_look_cachable(bl, ctx); |
79 | 76 |
80 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, ctx->event->log, 0, | 77 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, ctx->event->log, 0, |
81 "event busy lock: %d w:%d mw:%d", | 78 "event busy lock: %d w:%d mw:%d", |
110 | 107 |
111 return rc; | 108 return rc; |
112 } | 109 } |
113 | 110 |
114 | 111 |
115 ngx_int_t ngx_event_busy_unlock(ngx_event_busy_lock_t *bl, | 112 void |
116 ngx_event_busy_lock_ctx_t *ctx) | 113 ngx_event_busy_unlock(ngx_event_busy_lock_t *bl, |
114 ngx_event_busy_lock_ctx_t *ctx) | |
117 { | 115 { |
118 ngx_event_t *ev; | 116 ngx_event_t *ev; |
119 ngx_event_busy_lock_ctx_t *wakeup; | 117 ngx_event_busy_lock_ctx_t *wakeup; |
120 | 118 |
121 if (ngx_mutex_lock(bl->mutex) == NGX_ERROR) { | 119 ngx_mutex_lock(bl->mutex); |
122 return NGX_ERROR; | |
123 } | |
124 | 120 |
125 if (bl->events) { | 121 if (bl->events) { |
126 wakeup = bl->events; | 122 wakeup = bl->events; |
127 bl->events = bl->events->next; | 123 bl->events = bl->events->next; |
128 | 124 |
136 * each ctx has pid to wake up | 132 * each ctx has pid to wake up |
137 */ | 133 */ |
138 | 134 |
139 if (wakeup == NULL) { | 135 if (wakeup == NULL) { |
140 ngx_mutex_unlock(bl->mutex); | 136 ngx_mutex_unlock(bl->mutex); |
141 return NGX_OK; | 137 return; |
142 } | 138 } |
143 | 139 |
144 if (ctx->md5) { | 140 if (ctx->md5) { |
145 for (wakeup = bl->events; wakeup; wakeup = wakeup->next) { | 141 for (wakeup = bl->events; wakeup; wakeup = wakeup->next) { |
146 if (wakeup->md5 == NULL || wakeup->slot != ctx->slot) { | 142 if (wakeup->md5 == NULL || wakeup->slot != ctx->slot) { |
150 wakeup->handler = ngx_event_busy_lock_posted_handler; | 146 wakeup->handler = ngx_event_busy_lock_posted_handler; |
151 wakeup->cache_updated = 1; | 147 wakeup->cache_updated = 1; |
152 | 148 |
153 ev = wakeup->event; | 149 ev = wakeup->event; |
154 | 150 |
155 if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) { | 151 ngx_post_event(ev, &ngx_posted_events); |
156 return NGX_ERROR; | |
157 } | |
158 | |
159 ngx_post_event(ev); | |
160 | |
161 ngx_mutex_unlock(ngx_posted_events_mutex); | |
162 } | 152 } |
163 | 153 |
164 ngx_mutex_unlock(bl->mutex); | 154 ngx_mutex_unlock(bl->mutex); |
165 | 155 |
166 } else { | 156 } else { |
175 | 165 |
176 if (ev->timer_set) { | 166 if (ev->timer_set) { |
177 ngx_del_timer(ev); | 167 ngx_del_timer(ev); |
178 } | 168 } |
179 | 169 |
180 if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) { | 170 ngx_post_event(ev, &ngx_posted_events); |
181 return NGX_ERROR; | 171 } |
182 } | 172 } |
183 | 173 |
184 ngx_post_event(ev); | 174 |
185 | 175 void |
186 ngx_mutex_unlock(ngx_posted_events_mutex); | 176 ngx_event_busy_lock_cancel(ngx_event_busy_lock_t *bl, |
187 } | 177 ngx_event_busy_lock_ctx_t *ctx) |
188 | |
189 return NGX_OK; | |
190 } | |
191 | |
192 | |
193 ngx_int_t ngx_event_busy_lock_cancel(ngx_event_busy_lock_t *bl, | |
194 ngx_event_busy_lock_ctx_t *ctx) | |
195 { | 178 { |
196 ngx_event_busy_lock_ctx_t *c, *p; | 179 ngx_event_busy_lock_ctx_t *c, *p; |
197 | 180 |
198 if (ngx_mutex_lock(bl->mutex) == NGX_ERROR) { | 181 ngx_mutex_lock(bl->mutex); |
199 return NGX_ERROR; | |
200 } | |
201 | 182 |
202 bl->waiting--; | 183 bl->waiting--; |
203 | 184 |
204 if (ctx == bl->events) { | 185 if (ctx == bl->events) { |
205 bl->events = ctx->next; | 186 bl->events = ctx->next; |
214 p = c; | 195 p = c; |
215 } | 196 } |
216 } | 197 } |
217 | 198 |
218 ngx_mutex_unlock(bl->mutex); | 199 ngx_mutex_unlock(bl->mutex); |
219 | 200 } |
220 return NGX_OK; | 201 |
221 } | 202 |
222 | 203 static ngx_int_t |
223 | 204 ngx_event_busy_lock_look_cachable(ngx_event_busy_lock_t *bl, |
224 static int ngx_event_busy_lock_look_cachable(ngx_event_busy_lock_t *bl, | 205 ngx_event_busy_lock_ctx_t *ctx) |
225 ngx_event_busy_lock_ctx_t *ctx) | |
226 { | 206 { |
227 ngx_int_t free; | 207 ngx_int_t free; |
228 ngx_uint_t i, bit, cachable, mask; | 208 ngx_uint_t i, bit, cachable, mask; |
229 | 209 |
230 bit = 0; | 210 bit = 0; |
284 | 264 |
285 return NGX_OK; | 265 return NGX_OK; |
286 } | 266 } |
287 | 267 |
288 | 268 |
289 static void ngx_event_busy_lock_handler(ngx_event_t *ev) | 269 static void |
290 { | 270 ngx_event_busy_lock_handler(ngx_event_t *ev) |
291 if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) { | 271 { |
292 return; | |
293 } | |
294 | |
295 ngx_post_event(ev); | |
296 | |
297 ngx_mutex_unlock(ngx_posted_events_mutex); | |
298 | |
299 ev->handler = ngx_event_busy_lock_posted_handler; | 272 ev->handler = ngx_event_busy_lock_posted_handler; |
300 } | 273 |
301 | 274 ngx_post_event(ev, &ngx_posted_events); |
302 | 275 } |
303 static void ngx_event_busy_lock_posted_handler(ngx_event_t *ev) | 276 |
277 | |
278 static void | |
279 ngx_event_busy_lock_posted_handler(ngx_event_t *ev) | |
304 { | 280 { |
305 ngx_event_busy_lock_ctx_t *ctx; | 281 ngx_event_busy_lock_ctx_t *ctx; |
306 | 282 |
307 ctx = ev->data; | 283 ctx = ev->data; |
308 ctx->handler(ev); | 284 ctx->handler(ev); |