Mercurial > hg > nginx
comparison src/http/ngx_http_core_module.c @ 176:c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 09 Nov 2003 20:03:38 +0000 |
parents | c42be4185301 |
children | 4db54fdbcbe7 |
comparison
equal
deleted
inserted
replaced
175:e92c2c647c57 | 176:c0552e5ab567 |
---|---|
29 static char *ngx_types_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | 29 static char *ngx_types_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
30 static char *ngx_set_type(ngx_conf_t *cf, ngx_command_t *dummy, void *conf); | 30 static char *ngx_set_type(ngx_conf_t *cf, ngx_command_t *dummy, void *conf); |
31 static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | 31 static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
32 static char *ngx_set_server_name(ngx_conf_t *cf, ngx_command_t *cmd, | 32 static char *ngx_set_server_name(ngx_conf_t *cf, ngx_command_t *cmd, |
33 void *conf); | 33 void *conf); |
34 static char *ngx_set_error_page(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | |
34 static char *ngx_set_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | 35 static char *ngx_set_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
35 | 36 |
36 static char *ngx_http_lowat_check(ngx_conf_t *cf, void *post, void *data); | 37 static char *ngx_http_lowat_check(ngx_conf_t *cf, void *post, void *data); |
37 | 38 |
38 static ngx_conf_post_t ngx_http_lowat_post = { ngx_http_lowat_check } ; | 39 static ngx_conf_post_t ngx_http_lowat_post = { ngx_http_lowat_check } ; |
190 ngx_conf_set_flag_slot, | 191 ngx_conf_set_flag_slot, |
191 NGX_HTTP_LOC_CONF_OFFSET, | 192 NGX_HTTP_LOC_CONF_OFFSET, |
192 offsetof(ngx_http_core_loc_conf_t, msie_padding), | 193 offsetof(ngx_http_core_loc_conf_t, msie_padding), |
193 NULL}, | 194 NULL}, |
194 | 195 |
196 {ngx_string("error_page"), | |
197 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_2MORE, | |
198 ngx_set_error_page, | |
199 NGX_HTTP_LOC_CONF_OFFSET, | |
200 0, | |
201 NULL}, | |
202 | |
195 {ngx_string("error_log"), | 203 {ngx_string("error_log"), |
196 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | 204 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
197 ngx_set_error_log, | 205 ngx_set_error_log, |
198 NGX_HTTP_LOC_CONF_OFFSET, | 206 NGX_HTTP_LOC_CONF_OFFSET, |
199 0, | 207 0, |
629 { | 637 { |
630 int m; | 638 int m; |
631 char *rv; | 639 char *rv; |
632 ngx_str_t *location; | 640 ngx_str_t *location; |
633 ngx_http_module_t *module; | 641 ngx_http_module_t *module; |
634 ngx_conf_t pcf; | 642 ngx_conf_t pvcf; |
635 ngx_http_conf_ctx_t *ctx, *pctx; | 643 ngx_http_conf_ctx_t *ctx, *pvctx; |
636 ngx_http_core_srv_conf_t *cscf; | 644 ngx_http_core_srv_conf_t *cscf; |
637 ngx_http_core_loc_conf_t *clcf, **clcfp; | 645 ngx_http_core_loc_conf_t *clcf, **clcfp; |
638 | 646 |
639 ngx_test_null(ctx, | 647 ngx_test_null(ctx, |
640 ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)), | 648 ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)), |
641 NGX_CONF_ERROR); | 649 NGX_CONF_ERROR); |
642 | 650 |
643 pctx = (ngx_http_conf_ctx_t *) cf->ctx; | 651 pvctx = (ngx_http_conf_ctx_t *) cf->ctx; |
644 ctx->main_conf = pctx->main_conf; | 652 ctx->main_conf = pvctx->main_conf; |
645 ctx->srv_conf = pctx->srv_conf; | 653 ctx->srv_conf = pvctx->srv_conf; |
646 | 654 |
647 ngx_test_null(ctx->loc_conf, | 655 ngx_test_null(ctx->loc_conf, |
648 ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module), | 656 ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module), |
649 NGX_CONF_ERROR); | 657 NGX_CONF_ERROR); |
650 | 658 |
670 | 678 |
671 cscf = ctx->srv_conf[ngx_http_core_module.ctx_index]; | 679 cscf = ctx->srv_conf[ngx_http_core_module.ctx_index]; |
672 ngx_test_null(clcfp, ngx_push_array(&cscf->locations), NGX_CONF_ERROR); | 680 ngx_test_null(clcfp, ngx_push_array(&cscf->locations), NGX_CONF_ERROR); |
673 *clcfp = clcf; | 681 *clcfp = clcf; |
674 | 682 |
675 pcf = *cf; | 683 pvcf = *cf; |
676 cf->ctx = ctx; | 684 cf->ctx = ctx; |
677 cf->cmd_type = NGX_HTTP_LOC_CONF; | 685 cf->cmd_type = NGX_HTTP_LOC_CONF; |
678 rv = ngx_conf_parse(cf, NULL); | 686 rv = ngx_conf_parse(cf, NULL); |
679 *cf = pcf; | 687 *cf = pvcf; |
680 | 688 |
681 return rv; | 689 return rv; |
682 } | 690 } |
683 | 691 |
684 | 692 |
854 lcf->doc_root.data = NULL; | 862 lcf->doc_root.data = NULL; |
855 lcf->types = NULL; | 863 lcf->types = NULL; |
856 lcf->default_type.len = 0; | 864 lcf->default_type.len = 0; |
857 lcf->default_type.data = NULL; | 865 lcf->default_type.data = NULL; |
858 lcf->err_log = NULL; | 866 lcf->err_log = NULL; |
867 lcf->error_pages = NULL; | |
859 | 868 |
860 */ | 869 */ |
861 | 870 |
862 lcf->client_body_timeout = NGX_CONF_UNSET; | 871 lcf->client_body_timeout = NGX_CONF_UNSET; |
863 lcf->sendfile = NGX_CONF_UNSET; | 872 lcf->sendfile = NGX_CONF_UNSET; |
925 if (prev->err_log) { | 934 if (prev->err_log) { |
926 conf->err_log = prev->err_log; | 935 conf->err_log = prev->err_log; |
927 } else { | 936 } else { |
928 conf->err_log = cf->cycle->log; | 937 conf->err_log = cf->cycle->log; |
929 } | 938 } |
939 } | |
940 | |
941 if (conf->error_pages == NULL && prev->error_pages) { | |
942 conf->error_pages = prev->error_pages; | |
930 } | 943 } |
931 | 944 |
932 ngx_conf_merge_str_value(conf->default_type, | 945 ngx_conf_merge_str_value(conf->default_type, |
933 prev->default_type, "text/plain"); | 946 prev->default_type, "text/plain"); |
934 | 947 |
1059 | 1072 |
1060 return NGX_CONF_OK; | 1073 return NGX_CONF_OK; |
1061 } | 1074 } |
1062 | 1075 |
1063 | 1076 |
1077 static char *ngx_set_error_page(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
1078 { | |
1079 ngx_http_core_loc_conf_t *lcf = conf; | |
1080 | |
1081 int i; | |
1082 ngx_str_t *value; | |
1083 ngx_http_err_page_t *err; | |
1084 | |
1085 if (lcf->error_pages == NULL) { | |
1086 lcf->error_pages = ngx_create_array(cf->pool, 5, | |
1087 sizeof(ngx_http_err_page_t)); | |
1088 if (lcf->error_pages == NULL) { | |
1089 return NGX_CONF_ERROR; | |
1090 } | |
1091 } | |
1092 | |
1093 value = cf->args->elts; | |
1094 | |
1095 for (i = 1; i < cf->args->nelts - 1; i++) { | |
1096 ngx_test_null(err, ngx_push_array(lcf->error_pages), NGX_CONF_ERROR); | |
1097 err->code = ngx_atoi(value[i].data, value[i].len); | |
1098 if (err->code == NGX_ERROR) { | |
1099 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1100 "invalid value \"%s\"", value[i].data); | |
1101 return NGX_CONF_ERROR; | |
1102 } | |
1103 | |
1104 if (err->code < 400 || err->code > 599) { | |
1105 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1106 "value \"%s\" must be between 400 and 599", | |
1107 value[i].data); | |
1108 return NGX_CONF_ERROR; | |
1109 } | |
1110 | |
1111 err->uri = value[cf->args->nelts - 1]; | |
1112 } | |
1113 | |
1114 return NGX_CONF_OK; | |
1115 } | |
1116 | |
1117 | |
1064 static char *ngx_set_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | 1118 static char *ngx_set_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
1065 { | 1119 { |
1066 ngx_http_core_loc_conf_t *lcf = conf; | 1120 ngx_http_core_loc_conf_t *lcf = conf; |
1067 | 1121 |
1068 ngx_str_t *value; | 1122 ngx_str_t *value; |
1077 } | 1131 } |
1078 | 1132 |
1079 | 1133 |
1080 static char *ngx_http_lowat_check(ngx_conf_t *cf, void *post, void *data) | 1134 static char *ngx_http_lowat_check(ngx_conf_t *cf, void *post, void *data) |
1081 { | 1135 { |
1136 #if (HAVE_LOWAT_EVENT) | |
1137 | |
1082 int *np = data; | 1138 int *np = data; |
1083 | |
1084 #if (HAVE_LOWAT_EVENT) | |
1085 | 1139 |
1086 if (*np >= ngx_freebsd_net_inet_tcp_sendspace) { | 1140 if (*np >= ngx_freebsd_net_inet_tcp_sendspace) { |
1087 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 1141 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
1088 "\"send_lowat\" must be less than %d " | 1142 "\"send_lowat\" must be less than %d " |
1089 "(sysctl net.inet.tcp.sendspace)", | 1143 "(sysctl net.inet.tcp.sendspace)", |