Mercurial > hg > nginx-mail
comparison src/http/ngx_http_core_module.c @ 645:c5122335e41d NGINX_0_8_53
nginx 0.8.53
*) Feature: now the "error_page" directive allows to change a status
code in a redirect.
*) Feature: the "gzip_disable" directive supports special "degradation"
mask.
*) Bugfix: a socket leak might occurred if file AIO was used.
Thanks to Maxim Dounin.
*) Bugfix: if the first server had no "listen" directive and there was
no explicit default server, then a next server with a "listen"
directive became the default server; the bug had appeared in 0.8.21.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 18 Oct 2010 00:00:00 +0400 |
parents | be70f83b184f |
children | 428c6e58046a |
comparison
equal
deleted
inserted
replaced
644:b2afd36d87f4 | 645:c5122335e41d |
---|---|
2425 char *rv; | 2425 char *rv; |
2426 void *mconf; | 2426 void *mconf; |
2427 ngx_uint_t i; | 2427 ngx_uint_t i; |
2428 ngx_conf_t pcf; | 2428 ngx_conf_t pcf; |
2429 ngx_http_module_t *module; | 2429 ngx_http_module_t *module; |
2430 struct sockaddr_in *sin; | |
2430 ngx_http_conf_ctx_t *ctx, *http_ctx; | 2431 ngx_http_conf_ctx_t *ctx, *http_ctx; |
2432 ngx_http_listen_opt_t lsopt; | |
2431 ngx_http_core_srv_conf_t *cscf, **cscfp; | 2433 ngx_http_core_srv_conf_t *cscf, **cscfp; |
2432 ngx_http_core_main_conf_t *cmcf; | 2434 ngx_http_core_main_conf_t *cmcf; |
2433 | 2435 |
2434 ctx = ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)); | 2436 ctx = ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)); |
2435 if (ctx == NULL) { | 2437 if (ctx == NULL) { |
2503 cf->cmd_type = NGX_HTTP_SRV_CONF; | 2505 cf->cmd_type = NGX_HTTP_SRV_CONF; |
2504 | 2506 |
2505 rv = ngx_conf_parse(cf, NULL); | 2507 rv = ngx_conf_parse(cf, NULL); |
2506 | 2508 |
2507 *cf = pcf; | 2509 *cf = pcf; |
2510 | |
2511 if (rv == NGX_CONF_OK && !cscf->listen) { | |
2512 ngx_memzero(&lsopt, sizeof(ngx_http_listen_opt_t)); | |
2513 | |
2514 sin = &lsopt.u.sockaddr_in; | |
2515 | |
2516 sin->sin_family = AF_INET; | |
2517 #if (NGX_WIN32) | |
2518 sin->sin_port = htons(80); | |
2519 #else | |
2520 sin->sin_port = htons((getuid() == 0) ? 80 : 8000); | |
2521 #endif | |
2522 sin->sin_addr.s_addr = INADDR_ANY; | |
2523 | |
2524 lsopt.socklen = sizeof(struct sockaddr_in); | |
2525 | |
2526 lsopt.backlog = NGX_LISTEN_BACKLOG; | |
2527 lsopt.rcvbuf = -1; | |
2528 lsopt.sndbuf = -1; | |
2529 #if (NGX_HAVE_SETFIB) | |
2530 lsopt.setfib = -1; | |
2531 #endif | |
2532 lsopt.wildcard = 1; | |
2533 | |
2534 (void) ngx_sock_ntop(&lsopt.u.sockaddr, lsopt.addr, | |
2535 NGX_SOCKADDR_STRLEN, 1); | |
2536 | |
2537 if (ngx_http_add_listen(cf, cscf, &lsopt) != NGX_OK) { | |
2538 return NGX_CONF_ERROR; | |
2539 } | |
2540 } | |
2508 | 2541 |
2509 return rv; | 2542 return rv; |
2510 } | 2543 } |
2511 | 2544 |
2512 | 2545 |
2944 ngx_http_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) | 2977 ngx_http_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) |
2945 { | 2978 { |
2946 ngx_http_core_srv_conf_t *prev = parent; | 2979 ngx_http_core_srv_conf_t *prev = parent; |
2947 ngx_http_core_srv_conf_t *conf = child; | 2980 ngx_http_core_srv_conf_t *conf = child; |
2948 | 2981 |
2949 struct sockaddr_in *sin; | |
2950 ngx_http_listen_opt_t lsopt; | |
2951 ngx_http_server_name_t *sn; | 2982 ngx_http_server_name_t *sn; |
2952 | 2983 |
2953 /* TODO: it does not merge, it inits only */ | 2984 /* TODO: it does not merge, it inits only */ |
2954 | 2985 |
2955 ngx_conf_merge_size_value(conf->connection_pool_size, | 2986 ngx_conf_merge_size_value(conf->connection_pool_size, |
2976 | 3007 |
2977 ngx_conf_merge_value(conf->merge_slashes, prev->merge_slashes, 1); | 3008 ngx_conf_merge_value(conf->merge_slashes, prev->merge_slashes, 1); |
2978 | 3009 |
2979 ngx_conf_merge_value(conf->underscores_in_headers, | 3010 ngx_conf_merge_value(conf->underscores_in_headers, |
2980 prev->underscores_in_headers, 0); | 3011 prev->underscores_in_headers, 0); |
2981 | |
2982 if (!conf->listen) { | |
2983 ngx_memzero(&lsopt, sizeof(ngx_http_listen_opt_t)); | |
2984 | |
2985 sin = &lsopt.u.sockaddr_in; | |
2986 | |
2987 sin->sin_family = AF_INET; | |
2988 #if (NGX_WIN32) | |
2989 sin->sin_port = htons(80); | |
2990 #else | |
2991 sin->sin_port = htons((getuid() == 0) ? 80 : 8000); | |
2992 #endif | |
2993 sin->sin_addr.s_addr = INADDR_ANY; | |
2994 | |
2995 lsopt.socklen = sizeof(struct sockaddr_in); | |
2996 | |
2997 lsopt.backlog = NGX_LISTEN_BACKLOG; | |
2998 lsopt.rcvbuf = -1; | |
2999 lsopt.sndbuf = -1; | |
3000 #if (NGX_HAVE_SETFIB) | |
3001 lsopt.setfib = -1; | |
3002 #endif | |
3003 lsopt.wildcard = 1; | |
3004 | |
3005 (void) ngx_sock_ntop(&lsopt.u.sockaddr, lsopt.addr, | |
3006 NGX_SOCKADDR_STRLEN, 1); | |
3007 | |
3008 if (ngx_http_add_listen(cf, conf, &lsopt) == NGX_OK) { | |
3009 return NGX_CONF_OK; | |
3010 } | |
3011 } | |
3012 | 3012 |
3013 if (conf->server_name.data == NULL) { | 3013 if (conf->server_name.data == NULL) { |
3014 ngx_str_set(&conf->server_name, ""); | 3014 ngx_str_set(&conf->server_name, ""); |
3015 | 3015 |
3016 sn = ngx_array_push(&conf->server_names); | 3016 sn = ngx_array_push(&conf->server_names); |
3111 clcf->gzip_http_version = NGX_CONF_UNSET_UINT; | 3111 clcf->gzip_http_version = NGX_CONF_UNSET_UINT; |
3112 #if (NGX_PCRE) | 3112 #if (NGX_PCRE) |
3113 clcf->gzip_disable = NGX_CONF_UNSET_PTR; | 3113 clcf->gzip_disable = NGX_CONF_UNSET_PTR; |
3114 #endif | 3114 #endif |
3115 clcf->gzip_disable_msie6 = 3; | 3115 clcf->gzip_disable_msie6 = 3; |
3116 #if (NGX_HTTP_DEGRADATION) | |
3117 clcf->gzip_disable_degradation = 3; | |
3118 #endif | |
3116 #endif | 3119 #endif |
3117 | 3120 |
3118 return clcf; | 3121 return clcf; |
3119 } | 3122 } |
3120 | 3123 |
3371 if (conf->gzip_disable_msie6 == 3) { | 3374 if (conf->gzip_disable_msie6 == 3) { |
3372 conf->gzip_disable_msie6 = | 3375 conf->gzip_disable_msie6 = |
3373 (prev->gzip_disable_msie6 == 3) ? 0 : prev->gzip_disable_msie6; | 3376 (prev->gzip_disable_msie6 == 3) ? 0 : prev->gzip_disable_msie6; |
3374 } | 3377 } |
3375 | 3378 |
3379 #if (NGX_HTTP_DEGRADATION) | |
3380 | |
3381 if (conf->gzip_disable_degradation == 3) { | |
3382 conf->gzip_disable_degradation = | |
3383 (prev->gzip_disable_degradation == 3) ? | |
3384 0 : prev->gzip_disable_degradation; | |
3385 } | |
3386 | |
3387 #endif | |
3376 #endif | 3388 #endif |
3377 | 3389 |
3378 return NGX_CONF_OK; | 3390 return NGX_CONF_OK; |
3379 } | 3391 } |
3380 | 3392 |
4055 "value \"%V\" must be between 300 and 599", | 4067 "value \"%V\" must be between 300 and 599", |
4056 &value[i]); | 4068 &value[i]); |
4057 return NGX_CONF_ERROR; | 4069 return NGX_CONF_ERROR; |
4058 } | 4070 } |
4059 | 4071 |
4060 if (overwrite >= 0) { | 4072 err->overwrite = overwrite; |
4061 err->overwrite = overwrite; | 4073 |
4062 | 4074 if (overwrite == -1) { |
4063 } else { | |
4064 switch (err->status) { | 4075 switch (err->status) { |
4065 case NGX_HTTP_TO_HTTPS: | 4076 case NGX_HTTP_TO_HTTPS: |
4066 case NGX_HTTPS_CERT_ERROR: | 4077 case NGX_HTTPS_CERT_ERROR: |
4067 case NGX_HTTPS_NO_CERT: | 4078 case NGX_HTTPS_NO_CERT: |
4068 err->overwrite = NGX_HTTP_BAD_REQUEST; | 4079 err->overwrite = NGX_HTTP_BAD_REQUEST; |
4069 break; | |
4070 | |
4071 default: | 4080 default: |
4072 err->overwrite = err->status; | |
4073 break; | 4081 break; |
4074 } | 4082 } |
4075 } | 4083 } |
4076 | 4084 |
4077 err->value = cv; | 4085 err->value = cv; |
4392 if (ngx_strcmp(value[i].data, "msie6") == 0) { | 4400 if (ngx_strcmp(value[i].data, "msie6") == 0) { |
4393 clcf->gzip_disable_msie6 = 1; | 4401 clcf->gzip_disable_msie6 = 1; |
4394 continue; | 4402 continue; |
4395 } | 4403 } |
4396 | 4404 |
4405 #if (NGX_HTTP_DEGRADATION) | |
4406 | |
4407 if (ngx_strcmp(value[i].data, "degradation") == 0) { | |
4408 clcf->gzip_disable_degradation = 1; | |
4409 continue; | |
4410 } | |
4411 | |
4412 #endif | |
4413 | |
4397 re = ngx_array_push(clcf->gzip_disable); | 4414 re = ngx_array_push(clcf->gzip_disable); |
4398 if (re == NULL) { | 4415 if (re == NULL) { |
4399 return NGX_CONF_ERROR; | 4416 return NGX_CONF_ERROR; |
4400 } | 4417 } |
4401 | 4418 |
4412 } | 4429 } |
4413 | 4430 |
4414 return NGX_CONF_OK; | 4431 return NGX_CONF_OK; |
4415 | 4432 |
4416 #else | 4433 #else |
4417 ngx_str_t *value; | 4434 ngx_str_t *value; |
4435 ngx_uint_t i; | |
4418 | 4436 |
4419 value = cf->args->elts; | 4437 value = cf->args->elts; |
4420 | 4438 |
4421 if (cf->args->nelts == 2 && ngx_strcmp(value[1].data, "msie6") == 0) { | 4439 for (i = 1; i < cf->args->nelts; i++) { |
4422 clcf->gzip_disable_msie6 = 1; | 4440 if (ngx_strcmp(value[i].data, "msie6") == 0) { |
4423 return NGX_CONF_OK; | 4441 clcf->gzip_disable_msie6 = 1; |
4424 } | 4442 continue; |
4425 | 4443 } |
4426 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 4444 |
4427 "without PCRE library \"gzip_disable\" supports " | 4445 #if (NGX_HTTP_DEGRADATION) |
4428 "builtin \"msie6\" mask only"); | 4446 |
4429 | 4447 if (ngx_strcmp(value[i].data, "degradation") == 0) { |
4430 return NGX_CONF_ERROR; | 4448 clcf->gzip_disable_degradation = 1; |
4449 continue; | |
4450 } | |
4451 | |
4452 #endif | |
4453 | |
4454 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
4455 "without PCRE library \"gzip_disable\" supports " | |
4456 "builtin \"msie6\" and \"degradation\" mask only"); | |
4457 | |
4458 return NGX_CONF_ERROR; | |
4459 } | |
4460 | |
4461 return NGX_CONF_OK; | |
4462 | |
4431 #endif | 4463 #endif |
4432 } | 4464 } |
4433 | 4465 |
4434 #endif | 4466 #endif |
4435 | 4467 |