Mercurial > hg > nginx
comparison src/http/ngx_http_cache.c @ 203:c9da5900c79e
nginx-0.0.1-2003-12-02-08:47:29 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 02 Dec 2003 05:47:29 +0000 |
parents | 74994aeef848 |
children | e91499541410 |
comparison
equal
deleted
inserted
replaced
202:74994aeef848 | 203:c9da5900c79e |
---|---|
45 for (i = 0; i < hash->nelts; i++) { | 45 for (i = 0; i < hash->nelts; i++) { |
46 if (c[i].crc == *crc | 46 if (c[i].crc == *crc |
47 && c[i].key.len == key->len | 47 && c[i].key.len == key->len |
48 && ngx_rstrncmp(c[i].key.data, key->data, key->len) == 0) | 48 && ngx_rstrncmp(c[i].key.data, key->data, key->len) == 0) |
49 { | 49 { |
50 #if 0 | |
51 if (c[i].expired) { | |
52 ngx_mutex_unlock(&hash->mutex); | |
53 return (void *) NGX_AGAIN; | |
54 } | |
55 #endif | |
56 | |
50 c[i].refs++; | 57 c[i].refs++; |
51 ngx_mutex_unlock(&hash->mutex); | |
52 | 58 |
53 if ((!(c[i].notify && (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT))) | 59 if ((!(c[i].notify && (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT))) |
54 && (ngx_cached_time - c[i].updated >= hash->update)) | 60 && (ngx_cached_time - c[i].updated >= hash->update)) |
55 { | 61 { |
56 c[i].expired = 1; | 62 c[i].expired = 1; |
57 } | 63 } |
64 | |
65 ngx_mutex_unlock(&hash->mutex); | |
58 | 66 |
59 if (cleanup) { | 67 if (cleanup) { |
60 cleanup->data.cache.hash = hash; | 68 cleanup->data.cache.hash = hash; |
61 cleanup->data.cache.cache = &c[i]; | 69 cleanup->data.cache.cache = &c[i]; |
62 cleanup->valid = 1; | 70 cleanup->valid = 1; |
215 | 223 |
216 cache->refs = 0; | 224 cache->refs = 0; |
217 } | 225 } |
218 | 226 |
219 | 227 |
228 void ngx_http_cache_lock(ngx_http_cache_hash_t *hash, ngx_http_cache_t *cache) | |
229 { | |
230 ngx_mutex_lock(&hash->mutex); | |
231 } | |
232 | |
233 | |
220 void ngx_http_cache_unlock(ngx_http_cache_hash_t *hash, | 234 void ngx_http_cache_unlock(ngx_http_cache_hash_t *hash, |
221 ngx_http_cache_t *cache, ngx_log_t *log) | 235 ngx_http_cache_t *cache, ngx_log_t *log) |
222 { | 236 { |
223 ngx_mutex_lock(&hash->mutex); | 237 ngx_mutex_lock(&hash->mutex); |
224 | 238 |
232 } | 246 } |
233 | 247 |
234 | 248 |
235 #if 0 | 249 #if 0 |
236 | 250 |
237 ngx_add_file_event(ngx_fd_t, ngx_event_handler_pt *handler, void *data) | 251 ngx_http_cache_add_file_event(ngx_http_cache_hash_t *hash, |
238 { | 252 ngx_http_cache_t *cache) |
239 ngx_event_t *ev; | 253 { |
254 ngx_event_t *ev; | |
255 ngx_http_cache_event_ctx_t *ctx; | |
240 | 256 |
241 ev = &ngx_cycle->read_events[fd]; | 257 ev = &ngx_cycle->read_events[fd]; |
242 ngx_memzero(ev, sizeof(ngx_event_t); | 258 ngx_memzero(ev, sizeof(ngx_event_t); |
243 | 259 |
244 ev->data = data; | 260 ev->data = data; |
248 } | 264 } |
249 | 265 |
250 | 266 |
251 void ngx_http_cache_invalidate(ngx_event_t *ev) | 267 void ngx_http_cache_invalidate(ngx_event_t *ev) |
252 { | 268 { |
253 ngx_http_cache_ctx_t *ctx; | 269 ngx_http_cache_event_ctx_t *ctx; |
254 | 270 |
255 ctx = ev->data; | 271 ctx = ev->data; |
256 | 272 |
257 ngx_http_cache_lock(&ctx->hash->mutex); | 273 ngx_http_cache_lock(&ctx->hash->mutex); |
258 | 274 |