comparison src/http/ngx_http_file_cache.c @ 4039:ee270f311dea stable-1.0

Merge of r3972, r3973, r3974: Cache fixes: *) do not close connection if cache file is too small: replace it with valid one *) rename ngx_http_file_cache_manager_sleep() to ngx_http_file_cache_loader_sleep() and do not use it all in cache manager: this is a vestige of the times when cache manager loaded cache *) set correct configuration file values while adding path
author Igor Sysoev <igor@sysoev.ru>
date Mon, 29 Aug 2011 10:07:58 +0000
parents 30519bb5621d
children 2fad4d19ea4b
comparison
equal deleted inserted replaced
4038:30519bb5621d 4039:ee270f311dea
29 static time_t ngx_http_file_cache_forced_expire(ngx_http_file_cache_t *cache); 29 static time_t ngx_http_file_cache_forced_expire(ngx_http_file_cache_t *cache);
30 static time_t ngx_http_file_cache_expire(ngx_http_file_cache_t *cache); 30 static time_t ngx_http_file_cache_expire(ngx_http_file_cache_t *cache);
31 static void ngx_http_file_cache_delete(ngx_http_file_cache_t *cache, 31 static void ngx_http_file_cache_delete(ngx_http_file_cache_t *cache,
32 ngx_queue_t *q, u_char *name); 32 ngx_queue_t *q, u_char *name);
33 static ngx_int_t 33 static ngx_int_t
34 ngx_http_file_cache_manager_sleep(ngx_http_file_cache_t *cache); 34 ngx_http_file_cache_loader_sleep(ngx_http_file_cache_t *cache);
35 static ngx_int_t ngx_http_file_cache_noop(ngx_tree_ctx_t *ctx, 35 static ngx_int_t ngx_http_file_cache_noop(ngx_tree_ctx_t *ctx,
36 ngx_str_t *path); 36 ngx_str_t *path);
37 static ngx_int_t ngx_http_file_cache_manage_file(ngx_tree_ctx_t *ctx, 37 static ngx_int_t ngx_http_file_cache_manage_file(ngx_tree_ctx_t *ctx,
38 ngx_str_t *path); 38 ngx_str_t *path);
39 static ngx_int_t ngx_http_file_cache_add_file(ngx_tree_ctx_t *ctx, 39 static ngx_int_t ngx_http_file_cache_add_file(ngx_tree_ctx_t *ctx,
374 } 374 }
375 375
376 if ((size_t) n < c->header_start) { 376 if ((size_t) n < c->header_start) {
377 ngx_log_error(NGX_LOG_CRIT, r->connection->log, 0, 377 ngx_log_error(NGX_LOG_CRIT, r->connection->log, 0,
378 "cache file \"%s\" is too small", c->file.name.data); 378 "cache file \"%s\" is too small", c->file.name.data);
379 return NGX_ERROR; 379 return NGX_DECLINED;
380 } 380 }
381 381
382 h = (ngx_http_file_cache_header_t *) c->buf->pos; 382 h = (ngx_http_file_cache_header_t *) c->buf->pos;
383 383
384 if (h->crc32 != c->crc32) { 384 if (h->crc32 != c->crc32) {
1206 1206
1207 if (wait > 0) { 1207 if (wait > 0) {
1208 return wait; 1208 return wait;
1209 } 1209 }
1210 1210
1211 if (ngx_http_file_cache_manager_sleep(cache) != NGX_OK) { 1211 if (ngx_quit || ngx_terminate) {
1212 return next; 1212 return next;
1213 } 1213 }
1214 } 1214 }
1215 } 1215 }
1216 1216
1260 cache->bsize); 1260 cache->bsize);
1261 } 1261 }
1262 1262
1263 1263
1264 static ngx_int_t 1264 static ngx_int_t
1265 ngx_http_file_cache_manager_sleep(ngx_http_file_cache_t *cache) 1265 ngx_http_file_cache_loader_sleep(ngx_http_file_cache_t *cache)
1266 { 1266 {
1267 ngx_msec_t elapsed; 1267 ngx_msec_t elapsed;
1268 1268
1269 if (cache->files++ > 100) { 1269 if (cache->files++ > 100) {
1270 1270
1312 1312
1313 if (ngx_http_file_cache_add_file(ctx, path) != NGX_OK) { 1313 if (ngx_http_file_cache_add_file(ctx, path) != NGX_OK) {
1314 (void) ngx_http_file_cache_delete_file(ctx, path); 1314 (void) ngx_http_file_cache_delete_file(ctx, path);
1315 } 1315 }
1316 1316
1317 return ngx_http_file_cache_manager_sleep(cache); 1317 return ngx_http_file_cache_loader_sleep(cache);
1318 } 1318 }
1319 1319
1320 1320
1321 static ngx_int_t 1321 static ngx_int_t
1322 ngx_http_file_cache_add_file(ngx_tree_ctx_t *ctx, ngx_str_t *name) 1322 ngx_http_file_cache_add_file(ngx_tree_ctx_t *ctx, ngx_str_t *name)
1603 } 1603 }
1604 1604
1605 cache->path->manager = ngx_http_file_cache_manager; 1605 cache->path->manager = ngx_http_file_cache_manager;
1606 cache->path->loader = ngx_http_file_cache_loader; 1606 cache->path->loader = ngx_http_file_cache_loader;
1607 cache->path->data = cache; 1607 cache->path->data = cache;
1608 cache->path->conf_file = cf->conf_file->file.name.data;
1609 cache->path->line = cf->conf_file->line;
1608 1610
1609 if (ngx_add_path(cf, &cache->path) != NGX_OK) { 1611 if (ngx_add_path(cf, &cache->path) != NGX_OK) {
1610 return NGX_CONF_ERROR; 1612 return NGX_CONF_ERROR;
1611 } 1613 }
1612 1614