Mercurial > hg > nginx-quic
comparison src/http/ngx_http_cache.c @ 277:e91499541410
nginx-0.0.2-2004-03-03-19:14:15 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 03 Mar 2004 16:14:15 +0000 |
parents | c9da5900c79e |
children | da8c5707af39 |
comparison
equal
deleted
inserted
replaced
276:a2d1ccc96111 | 277:e91499541410 |
---|---|
38 | 38 |
39 *crc = ngx_crc(key->data, key->len); | 39 *crc = ngx_crc(key->data, key->len); |
40 | 40 |
41 c = hash->elts + *crc % hash->hash * hash->nelts; | 41 c = hash->elts + *crc % hash->hash * hash->nelts; |
42 | 42 |
43 ngx_mutex_lock(&hash->mutex); | 43 if (ngx_mutex_lock(&hash->mutex) == NGX_ERROR) { |
44 return (void *) NGX_ERROR; | |
45 } | |
44 | 46 |
45 for (i = 0; i < hash->nelts; i++) { | 47 for (i = 0; i < hash->nelts; i++) { |
46 if (c[i].crc == *crc | 48 if (c[i].crc == *crc |
47 && c[i].key.len == key->len | 49 && c[i].key.len == key->len |
48 && ngx_rstrncmp(c[i].key.data, key->data, key->len) == 0) | 50 && ngx_rstrncmp(c[i].key.data, key->data, key->len) == 0) |
93 | 95 |
94 old = ngx_cached_time + 1; | 96 old = ngx_cached_time + 1; |
95 | 97 |
96 c = hash->elts + crc % hash->hash * hash->nelts; | 98 c = hash->elts + crc % hash->hash * hash->nelts; |
97 | 99 |
98 ngx_mutex_lock(&hash->mutex); | 100 if (ngx_mutex_lock(&hash->mutex) == NGX_ERROR) { |
101 return (void *) NGX_ERROR; | |
102 } | |
99 | 103 |
100 if (cache == NULL) { | 104 if (cache == NULL) { |
101 | 105 |
102 /* allocate a new entry */ | 106 /* allocate a new entry */ |
103 | 107 |
225 } | 229 } |
226 | 230 |
227 | 231 |
228 void ngx_http_cache_lock(ngx_http_cache_hash_t *hash, ngx_http_cache_t *cache) | 232 void ngx_http_cache_lock(ngx_http_cache_hash_t *hash, ngx_http_cache_t *cache) |
229 { | 233 { |
230 ngx_mutex_lock(&hash->mutex); | 234 if (ngx_mutex_lock(&hash->mutex) == NGX_ERROR) { |
235 return; | |
236 } | |
231 } | 237 } |
232 | 238 |
233 | 239 |
234 void ngx_http_cache_unlock(ngx_http_cache_hash_t *hash, | 240 void ngx_http_cache_unlock(ngx_http_cache_hash_t *hash, |
235 ngx_http_cache_t *cache, ngx_log_t *log) | 241 ngx_http_cache_t *cache, ngx_log_t *log) |
236 { | 242 { |
237 ngx_mutex_lock(&hash->mutex); | 243 if (ngx_mutex_lock(&hash->mutex) == NGX_ERROR) { |
244 return; | |
245 } | |
238 | 246 |
239 cache->refs--; | 247 cache->refs--; |
240 | 248 |
241 if (cache->refs == 0 && cache->deleted) { | 249 if (cache->refs == 0 && cache->deleted) { |
242 ngx_http_cache_free(cache, NULL, NULL, log); | 250 ngx_http_cache_free(cache, NULL, NULL, log); |