comparison src/http/ngx_http_core_module.c @ 332:3a91bfeffaba NGINX_0_6_10

nginx 0.6.10 *) Feature: the "open_file_cache", "open_file_cache_retest", and "open_file_cache_errors" directives. *) Bugfix: socket leak; bug appeared in 0.6.7. *) Bugfix: a charset set by the "charset" directive was not appended to the "Content-Type" header set by $r->send_http_header(). *) Bugfix: a segmentation fault might occur in worker process if /dev/poll method was used.
author Igor Sysoev <http://sysoev.ru>
date Mon, 03 Sep 2007 00:00:00 +0400
parents 390b8f8309d6
children 1c519aff5c0c
comparison
equal deleted inserted replaced
331:b69d5e83bf82 332:3a91bfeffaba
59 static char *ngx_http_core_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); 59 static char *ngx_http_core_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
60 static char *ngx_http_core_limit_except(ngx_conf_t *cf, ngx_command_t *cmd, 60 static char *ngx_http_core_limit_except(ngx_conf_t *cf, ngx_command_t *cmd,
61 void *conf); 61 void *conf);
62 static char *ngx_http_core_error_page(ngx_conf_t *cf, ngx_command_t *cmd, 62 static char *ngx_http_core_error_page(ngx_conf_t *cf, ngx_command_t *cmd,
63 void *conf); 63 void *conf);
64 static char *ngx_http_core_open_file_cache(ngx_conf_t *cf, ngx_command_t *cmd,
65 void *conf);
64 static char *ngx_http_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd, 66 static char *ngx_http_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd,
65 void *conf); 67 void *conf);
66 static char *ngx_http_core_keepalive(ngx_conf_t *cf, ngx_command_t *cmd, 68 static char *ngx_http_core_keepalive(ngx_conf_t *cf, ngx_command_t *cmd,
67 void *conf); 69 void *conf);
68 static char *ngx_http_core_internal(ngx_conf_t *cf, ngx_command_t *cmd, 70 static char *ngx_http_core_internal(ngx_conf_t *cf, ngx_command_t *cmd,
446 ngx_http_core_error_log, 448 ngx_http_core_error_log,
447 NGX_HTTP_LOC_CONF_OFFSET, 449 NGX_HTTP_LOC_CONF_OFFSET,
448 0, 450 0,
449 NULL }, 451 NULL },
450 452
451 #if (NGX_HTTP_CACHE)
452
453 { ngx_string("open_file_cache"), 453 { ngx_string("open_file_cache"),
454 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE4, 454 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE12,
455 ngx_http_set_cache_slot, 455 ngx_http_core_open_file_cache,
456 NGX_HTTP_LOC_CONF_OFFSET, 456 NGX_HTTP_LOC_CONF_OFFSET,
457 offsetof(ngx_http_core_loc_conf_t, open_files), 457 offsetof(ngx_http_core_loc_conf_t, open_file_cache),
458 NULL }, 458 NULL },
459 459
460 #endif 460 { ngx_string("open_file_cache_retest"),
461 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
462 ngx_conf_set_sec_slot,
463 NGX_HTTP_LOC_CONF_OFFSET,
464 offsetof(ngx_http_core_loc_conf_t, open_file_cache_retest),
465 NULL },
466
467 { ngx_string("open_file_cache_errors"),
468 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
469 ngx_conf_set_flag_slot,
470 NGX_HTTP_LOC_CONF_OFFSET,
471 offsetof(ngx_http_core_loc_conf_t, open_file_cache_errors),
472 NULL },
473
474 { ngx_string("open_file_cache_events"),
475 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
476 ngx_conf_set_flag_slot,
477 NGX_HTTP_LOC_CONF_OFFSET,
478 offsetof(ngx_http_core_loc_conf_t, open_file_cache_events),
479 NULL },
461 480
462 ngx_null_command 481 ngx_null_command
463 }; 482 };
464 483
465 484
2358 lcf->msie_refresh = NGX_CONF_UNSET; 2377 lcf->msie_refresh = NGX_CONF_UNSET;
2359 lcf->log_not_found = NGX_CONF_UNSET; 2378 lcf->log_not_found = NGX_CONF_UNSET;
2360 lcf->recursive_error_pages = NGX_CONF_UNSET; 2379 lcf->recursive_error_pages = NGX_CONF_UNSET;
2361 lcf->types_hash_max_size = NGX_CONF_UNSET_UINT; 2380 lcf->types_hash_max_size = NGX_CONF_UNSET_UINT;
2362 lcf->types_hash_bucket_size = NGX_CONF_UNSET_UINT; 2381 lcf->types_hash_bucket_size = NGX_CONF_UNSET_UINT;
2382 lcf->open_file_cache = NGX_CONF_UNSET_PTR;
2383 lcf->open_file_cache_retest = NGX_CONF_UNSET;
2384 lcf->open_file_cache_errors = NGX_CONF_UNSET;
2385 lcf->open_file_cache_events = NGX_CONF_UNSET;
2363 2386
2364 return lcf; 2387 return lcf;
2365 } 2388 }
2366 2389
2367 2390
2541 ngx_conf_merge_value(conf->msie_refresh, prev->msie_refresh, 0); 2564 ngx_conf_merge_value(conf->msie_refresh, prev->msie_refresh, 0);
2542 ngx_conf_merge_value(conf->log_not_found, prev->log_not_found, 1); 2565 ngx_conf_merge_value(conf->log_not_found, prev->log_not_found, 1);
2543 ngx_conf_merge_value(conf->recursive_error_pages, 2566 ngx_conf_merge_value(conf->recursive_error_pages,
2544 prev->recursive_error_pages, 0); 2567 prev->recursive_error_pages, 0);
2545 2568
2546 if (conf->open_files == NULL) { 2569 ngx_conf_merge_ptr_value(conf->open_file_cache,
2547 conf->open_files = prev->open_files; 2570 prev->open_file_cache, NULL);
2548 } 2571
2572 ngx_conf_merge_sec_value(conf->open_file_cache_retest,
2573 prev->open_file_cache_retest, 60);
2574
2575 ngx_conf_merge_sec_value(conf->open_file_cache_errors,
2576 prev->open_file_cache_errors, 0);
2577
2578 ngx_conf_merge_sec_value(conf->open_file_cache_events,
2579 prev->open_file_cache_events, 0);
2549 2580
2550 return NGX_CONF_OK; 2581 return NGX_CONF_OK;
2551 } 2582 }
2552 2583
2553 2584
3160 return NGX_CONF_OK; 3191 return NGX_CONF_OK;
3161 } 3192 }
3162 3193
3163 3194
3164 static char * 3195 static char *
3196 ngx_http_core_open_file_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
3197 {
3198 ngx_http_core_loc_conf_t *lcf = conf;
3199
3200 time_t inactive;
3201 ngx_str_t *value, s;
3202 ngx_int_t max;
3203 ngx_uint_t i;
3204
3205 if (lcf->open_file_cache != NGX_CONF_UNSET_PTR) {
3206 return "is duplicate";
3207 }
3208
3209 value = cf->args->elts;
3210
3211 max = 0;
3212 inactive = 60;
3213
3214 for (i = 1; i < cf->args->nelts; i++) {
3215
3216 if (ngx_strncmp(value[i].data, "max=", 4) == 0) {
3217
3218 max = ngx_atoi(value[i].data + 4, value[i].len - 4);
3219 if (max == NGX_ERROR) {
3220 return NGX_CONF_ERROR;
3221 }
3222
3223 continue;
3224 }
3225
3226 if (ngx_strncmp(value[i].data, "inactive=", 9) == 0) {
3227
3228 s.len = value[i].len - 9;
3229 s.data = value[i].data + 9;
3230
3231 inactive = ngx_parse_time(&s, 1);
3232 if (inactive < 0) {
3233 return NGX_CONF_ERROR;
3234 }
3235
3236 continue;
3237 }
3238
3239 if (ngx_strcmp(value[i].data, "off") == 0) {
3240
3241 lcf->open_file_cache = NULL;
3242
3243 continue;
3244 }
3245
3246 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
3247 "invalid \"open_file_cache\" parameter \"%V\"",
3248 &value[i]);
3249 return NGX_CONF_ERROR;
3250 }
3251
3252 if (lcf->open_file_cache == NULL) {
3253 return NGX_CONF_OK;
3254 }
3255
3256 if (max == 0) {
3257 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
3258 "\"open_file_cache\" must have \"max\" parameter");
3259 return NGX_CONF_ERROR;
3260 }
3261
3262 lcf->open_file_cache = ngx_open_file_cache_init(cf->pool, max, inactive);
3263 if (lcf->open_file_cache) {
3264 return NGX_CONF_OK;
3265 }
3266
3267 return NGX_CONF_ERROR;
3268 }
3269
3270
3271 static char *
3165 ngx_http_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) 3272 ngx_http_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
3166 { 3273 {
3167 ngx_http_core_loc_conf_t *lcf = conf; 3274 ngx_http_core_loc_conf_t *lcf = conf;
3168 3275
3169 lcf->err_log = ngx_log_create_errlog(cf->cycle, cf->args); 3276 lcf->err_log = ngx_log_create_errlog(cf->cycle, cf->args);