comparison src/http/ngx_http_file_cache.c @ 634:23ef0645ea57 NGINX_1_1_1

nginx 1.1.1 *) Change: now cache loader processes either as many files as specified by "loader_files" parameter or works no more than time specified by "loader_threshold" parameter during each iteration. *) Change: now SIGWINCH signal works only in deamon mode. *) Feature: now shared zones and caches use POSIX semaphores on Solaris. Thanks to Den Ivanov. *) Feature: accept filters are now supported on NetBSD. *) Bugfix: nginx could not be build on Linux 3.0. *) Bugfix: nginx did not use gzipping in some cases; the bug had appeared in 1.1.0. *) Bugfix: request body might be incorrectly processed if client used pipelining. *) Bugfix: in the "request_body_in_single_buf" directive. *) Bugfix: in "proxy_set_body" and "proxy_pass_request_body" directives if SSL connection to backend was used. *) Bugfix: nginx hogged CPU if all servers in an upstream were marked as "down". *) Bugfix: a segmentation fault might occur during reconfiguration if ssl_session_cache was defined but not used in a previous configuration. *) Bugfix: a segmentation fault might occur in a worker process if many backup servers were used in an upstream. *) Bugfix: a segmentation fault might occur in a worker process if "fastcgi/scgi/uwsgi_param" directives were used with values starting with "HTTP_"; the bug had appeared in 0.8.40.
author Igor Sysoev <http://sysoev.ru>
date Mon, 22 Aug 2011 00:00:00 +0400
parents 5b73504dd4ba
children 943566b4d82e
comparison
equal deleted inserted replaced
633:561a37709f6d 634:23ef0645ea57
28 static void ngx_http_file_cache_cleanup(void *data); 28 static void ngx_http_file_cache_cleanup(void *data);
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 void ngx_http_file_cache_loader_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, 34 static ngx_int_t ngx_http_file_cache_noop(ngx_tree_ctx_t *ctx,
36 ngx_str_t *path); 35 ngx_str_t *path);
37 static ngx_int_t ngx_http_file_cache_manage_file(ngx_tree_ctx_t *ctx, 36 static ngx_int_t ngx_http_file_cache_manage_file(ngx_tree_ctx_t *ctx,
38 ngx_str_t *path); 37 ngx_str_t *path);
39 static ngx_int_t ngx_http_file_cache_add_file(ngx_tree_ctx_t *ctx, 38 static ngx_int_t ngx_http_file_cache_add_file(ngx_tree_ctx_t *ctx,
1259 cache->bsize); 1258 cache->bsize);
1260 } 1259 }
1261 1260
1262 1261
1263 static ngx_int_t 1262 static ngx_int_t
1264 ngx_http_file_cache_loader_sleep(ngx_http_file_cache_t *cache) 1263 ngx_http_file_cache_noop(ngx_tree_ctx_t *ctx, ngx_str_t *path)
1265 { 1264 {
1266 ngx_msec_t elapsed; 1265 return NGX_OK;
1266 }
1267
1268
1269 static ngx_int_t
1270 ngx_http_file_cache_manage_file(ngx_tree_ctx_t *ctx, ngx_str_t *path)
1271 {
1272 ngx_msec_t elapsed;
1273 ngx_http_file_cache_t *cache;
1274
1275 cache = ctx->data;
1276
1277 if (ngx_http_file_cache_add_file(ctx, path) != NGX_OK) {
1278 (void) ngx_http_file_cache_delete_file(ctx, path);
1279 }
1267 1280
1268 if (++cache->files >= cache->loader_files) { 1281 if (++cache->files >= cache->loader_files) {
1269 1282 ngx_http_file_cache_loader_sleep(cache);
1283
1284 } else {
1270 ngx_time_update(); 1285 ngx_time_update();
1271 1286
1272 elapsed = ngx_abs((ngx_msec_int_t) (ngx_current_msec - cache->last)); 1287 elapsed = ngx_abs((ngx_msec_int_t) (ngx_current_msec - cache->last));
1273 1288
1274 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0, 1289 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,
1275 "http file cache loader time elapsed: %M", elapsed); 1290 "http file cache loader time elapsed: %M", elapsed);
1276 1291
1277 if (elapsed >= cache->loader_threshold) { 1292 if (elapsed >= cache->loader_threshold) {
1278 1293 ngx_http_file_cache_loader_sleep(cache);
1279 if (cache->loader_files > 1) { 1294 }
1280 cache->loader_files /= 2;
1281 ngx_log_error(NGX_LOG_NOTICE, ngx_cycle->log, 0,
1282 "cache %V loader_files decreased to %ui",
1283 &cache->path->name, cache->loader_files);
1284
1285 } else {
1286 cache->loader_sleep *= 2;
1287 ngx_log_error(NGX_LOG_NOTICE, ngx_cycle->log, 0,
1288 "cache %V loader_sleep increased to %Mms",
1289 &cache->path->name, cache->loader_sleep);
1290 }
1291 }
1292
1293 ngx_msleep(cache->loader_sleep);
1294
1295 ngx_time_update();
1296
1297 cache->last = ngx_current_msec;
1298 cache->files = 0;
1299 } 1295 }
1300 1296
1301 return (ngx_quit || ngx_terminate) ? NGX_ABORT : NGX_OK; 1297 return (ngx_quit || ngx_terminate) ? NGX_ABORT : NGX_OK;
1302 } 1298 }
1303 1299
1304 1300
1305 static ngx_int_t 1301 static void
1306 ngx_http_file_cache_noop(ngx_tree_ctx_t *ctx, ngx_str_t *path) 1302 ngx_http_file_cache_loader_sleep(ngx_http_file_cache_t *cache)
1307 { 1303 {
1308 return NGX_OK; 1304 ngx_msleep(cache->loader_sleep);
1309 } 1305
1310 1306 ngx_time_update();
1311 1307
1312 static ngx_int_t 1308 cache->last = ngx_current_msec;
1313 ngx_http_file_cache_manage_file(ngx_tree_ctx_t *ctx, ngx_str_t *path) 1309 cache->files = 0;
1314 {
1315 ngx_http_file_cache_t *cache;
1316
1317 cache = ctx->data;
1318
1319 if (ngx_http_file_cache_add_file(ctx, path) != NGX_OK) {
1320 (void) ngx_http_file_cache_delete_file(ctx, path);
1321 }
1322
1323 return ngx_http_file_cache_loader_sleep(cache);
1324 } 1310 }
1325 1311
1326 1312
1327 static ngx_int_t 1313 static ngx_int_t
1328 ngx_http_file_cache_add_file(ngx_tree_ctx_t *ctx, ngx_str_t *name) 1314 ngx_http_file_cache_add_file(ngx_tree_ctx_t *ctx, ngx_str_t *name)