Mercurial > hg > nginx
comparison src/event/ngx_event_busy_lock.c @ 1565:4c43e25d11ea
fix English grammar
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 14 Oct 2007 18:56:15 +0000 |
parents | f69d1aab6a0f |
children | d620f497c50f |
comparison
equal
deleted
inserted
replaced
1564:6725c3f56216 | 1565:4c43e25d11ea |
---|---|
7 #include <ngx_config.h> | 7 #include <ngx_config.h> |
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 ngx_int_t ngx_event_busy_lock_look_cachable(ngx_event_busy_lock_t *bl, | 12 static ngx_int_t ngx_event_busy_lock_look_cacheable(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 |
63 return rc; | 63 return rc; |
64 } | 64 } |
65 | 65 |
66 | 66 |
67 ngx_int_t | 67 ngx_int_t |
68 ngx_event_busy_lock_cachable(ngx_event_busy_lock_t *bl, | 68 ngx_event_busy_lock_cacheable(ngx_event_busy_lock_t *bl, |
69 ngx_event_busy_lock_ctx_t *ctx) | 69 ngx_event_busy_lock_ctx_t *ctx) |
70 { | 70 { |
71 ngx_int_t rc; | 71 ngx_int_t rc; |
72 | 72 |
73 ngx_mutex_lock(bl->mutex); | 73 ngx_mutex_lock(bl->mutex); |
74 | 74 |
75 rc = ngx_event_busy_lock_look_cachable(bl, ctx); | 75 rc = ngx_event_busy_lock_look_cacheable(bl, ctx); |
76 | 76 |
77 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, ctx->event->log, 0, | 77 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, ctx->event->log, 0, |
78 "event busy lock: %d w:%d mw:%d", | 78 "event busy lock: %d w:%d mw:%d", |
79 rc, bl->waiting, bl->max_waiting); | 79 rc, bl->waiting, bl->max_waiting); |
80 | 80 |
199 ngx_mutex_unlock(bl->mutex); | 199 ngx_mutex_unlock(bl->mutex); |
200 } | 200 } |
201 | 201 |
202 | 202 |
203 static ngx_int_t | 203 static ngx_int_t |
204 ngx_event_busy_lock_look_cachable(ngx_event_busy_lock_t *bl, | 204 ngx_event_busy_lock_look_cacheable(ngx_event_busy_lock_t *bl, |
205 ngx_event_busy_lock_ctx_t *ctx) | 205 ngx_event_busy_lock_ctx_t *ctx) |
206 { | 206 { |
207 ngx_int_t free; | 207 ngx_int_t free; |
208 ngx_uint_t i, bit, cachable, mask; | 208 ngx_uint_t i, bit, cacheable, mask; |
209 | 209 |
210 bit = 0; | 210 bit = 0; |
211 cachable = 0; | 211 cacheable = 0; |
212 free = -1; | 212 free = -1; |
213 | 213 |
214 #if (NGX_SUPPRESS_WARN) | 214 #if (NGX_SUPPRESS_WARN) |
215 mask = 0; | 215 mask = 0; |
216 #endif | 216 #endif |
225 if (ngx_memcmp(&bl->md5[i * 16], ctx->md5, 16) == 0) { | 225 if (ngx_memcmp(&bl->md5[i * 16], ctx->md5, 16) == 0) { |
226 ctx->waiting = 1; | 226 ctx->waiting = 1; |
227 ctx->slot = i; | 227 ctx->slot = i; |
228 return NGX_AGAIN; | 228 return NGX_AGAIN; |
229 } | 229 } |
230 cachable++; | 230 cacheable++; |
231 | 231 |
232 } else if (free == -1) { | 232 } else if (free == -1) { |
233 free = i; | 233 free = i; |
234 } | 234 } |
235 | 235 |
236 if (cachable == bl->cachable) { | 236 if (cacheable == bl->cacheable) { |
237 if (free == -1 && cachable < bl->max_busy) { | 237 if (free == -1 && cacheable < bl->max_busy) { |
238 free = i + 1; | 238 free = i + 1; |
239 } | 239 } |
240 | 240 |
241 break; | 241 break; |
242 } | 242 } |
257 | 257 |
258 ngx_memcpy(&bl->md5[free * 16], ctx->md5, 16); | 258 ngx_memcpy(&bl->md5[free * 16], ctx->md5, 16); |
259 bl->md5_mask[free / 8] |= 1 << (free & 7); | 259 bl->md5_mask[free / 8] |= 1 << (free & 7); |
260 ctx->slot = free; | 260 ctx->slot = free; |
261 | 261 |
262 bl->cachable++; | 262 bl->cacheable++; |
263 bl->busy++; | 263 bl->busy++; |
264 | 264 |
265 return NGX_OK; | 265 return NGX_OK; |
266 } | 266 } |
267 | 267 |