Mercurial > hg > nginx-ranges
comparison src/http/ngx_http_core_module.c @ 539:5f4de8cf0d9d
Merge with current.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 15 Sep 2009 03:43:40 +0400 |
parents | 0161f3197817 |
children | 4c5d2c627a6c |
comparison
equal
deleted
inserted
replaced
522:40fd8d7b82f9 | 539:5f4de8cf0d9d |
---|---|
102 { ngx_string("clean"), NGX_HTTP_REQUEST_BODY_FILE_CLEAN }, | 102 { ngx_string("clean"), NGX_HTTP_REQUEST_BODY_FILE_CLEAN }, |
103 { ngx_null_string, 0 } | 103 { ngx_null_string, 0 } |
104 }; | 104 }; |
105 | 105 |
106 | 106 |
107 #if (NGX_HAVE_FILE_AIO) | |
108 | |
109 static ngx_conf_enum_t ngx_http_core_aio[] = { | |
110 { ngx_string("off"), NGX_HTTP_AIO_OFF }, | |
111 { ngx_string("on"), NGX_HTTP_AIO_ON }, | |
112 #if (NGX_HAVE_AIO_SENDFILE) | |
113 { ngx_string("sendfile"), NGX_HTTP_AIO_SENDFILE }, | |
114 #endif | |
115 { ngx_null_string, 0 } | |
116 }; | |
117 | |
118 #endif | |
119 | |
120 | |
107 static ngx_conf_enum_t ngx_http_core_satisfy[] = { | 121 static ngx_conf_enum_t ngx_http_core_satisfy[] = { |
108 { ngx_string("all"), NGX_HTTP_SATISFY_ALL }, | 122 { ngx_string("all"), NGX_HTTP_SATISFY_ALL }, |
109 { ngx_string("any"), NGX_HTTP_SATISFY_ANY }, | 123 { ngx_string("any"), NGX_HTTP_SATISFY_ANY }, |
110 { ngx_null_string, 0 } | 124 { ngx_null_string, 0 } |
111 }; | 125 }; |
381 ngx_conf_set_size_slot, | 395 ngx_conf_set_size_slot, |
382 NGX_HTTP_LOC_CONF_OFFSET, | 396 NGX_HTTP_LOC_CONF_OFFSET, |
383 offsetof(ngx_http_core_loc_conf_t, sendfile_max_chunk), | 397 offsetof(ngx_http_core_loc_conf_t, sendfile_max_chunk), |
384 NULL }, | 398 NULL }, |
385 | 399 |
400 #if (NGX_HAVE_FILE_AIO) | |
401 | |
402 { ngx_string("aio"), | |
403 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
404 ngx_conf_set_enum_slot, | |
405 NGX_HTTP_LOC_CONF_OFFSET, | |
406 offsetof(ngx_http_core_loc_conf_t, aio), | |
407 &ngx_http_core_aio }, | |
408 | |
409 #endif | |
410 | |
386 { ngx_string("directio"), | 411 { ngx_string("directio"), |
387 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | 412 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
388 ngx_http_core_directio, | 413 ngx_http_core_directio, |
389 NGX_HTTP_LOC_CONF_OFFSET, | 414 NGX_HTTP_LOC_CONF_OFFSET, |
390 0, | 415 0, |
416 NULL }, | |
417 | |
418 { ngx_string("directio_alignment"), | |
419 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
420 ngx_conf_set_off_slot, | |
421 NGX_HTTP_LOC_CONF_OFFSET, | |
422 offsetof(ngx_http_core_loc_conf_t, directio_alignment), | |
391 NULL }, | 423 NULL }, |
392 | 424 |
393 { ngx_string("tcp_nopush"), | 425 { ngx_string("tcp_nopush"), |
394 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | 426 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, |
395 ngx_conf_set_flag_slot, | 427 ngx_conf_set_flag_slot, |
883 { | 915 { |
884 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | 916 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
885 "client intended to send too large body: %O bytes", | 917 "client intended to send too large body: %O bytes", |
886 r->headers_in.content_length_n); | 918 r->headers_in.content_length_n); |
887 | 919 |
920 (void) ngx_http_discard_request_body(r); | |
888 ngx_http_finalize_request(r, NGX_HTTP_REQUEST_ENTITY_TOO_LARGE); | 921 ngx_http_finalize_request(r, NGX_HTTP_REQUEST_ENTITY_TOO_LARGE); |
889 return NGX_OK; | 922 return NGX_OK; |
890 } | 923 } |
891 | 924 |
892 if (rc == NGX_DONE) { | 925 if (rc == NGX_DONE) { |
959 if (r->uri_changes == 0) { | 992 if (r->uri_changes == 0) { |
960 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | 993 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
961 "rewrite or internal redirection cycle " | 994 "rewrite or internal redirection cycle " |
962 "while processing \"%V\"", &r->uri); | 995 "while processing \"%V\"", &r->uri); |
963 | 996 |
997 r->main->count++; | |
964 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | 998 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
965 return NGX_OK; | 999 return NGX_OK; |
966 } | 1000 } |
967 | 1001 |
968 r->phase_handler = ph->next; | 1002 r->phase_handler = ph->next; |
1181 ngx_http_split_args(r, &path, &args); | 1215 ngx_http_split_args(r, &path, &args); |
1182 | 1216 |
1183 (void) ngx_http_internal_redirect(r, &path, &args); | 1217 (void) ngx_http_internal_redirect(r, &path, &args); |
1184 } | 1218 } |
1185 | 1219 |
1220 ngx_http_finalize_request(r, NGX_DONE); | |
1186 return NGX_OK; | 1221 return NGX_OK; |
1187 } | 1222 } |
1188 | 1223 |
1189 ngx_memzero(&of, sizeof(ngx_open_file_info_t)); | 1224 ngx_memzero(&of, sizeof(ngx_open_file_info_t)); |
1190 | 1225 |
1258 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 1293 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1259 "content phase: %ui", r->phase_handler); | 1294 "content phase: %ui", r->phase_handler); |
1260 | 1295 |
1261 rc = ph->handler(r); | 1296 rc = ph->handler(r); |
1262 | 1297 |
1263 if (rc == NGX_DONE) { | |
1264 return NGX_OK; | |
1265 } | |
1266 | |
1267 if (rc != NGX_DECLINED) { | 1298 if (rc != NGX_DECLINED) { |
1268 ngx_http_finalize_request(r, rc); | 1299 ngx_http_finalize_request(r, rc); |
1269 return NGX_OK; | 1300 return NGX_OK; |
1270 } | 1301 } |
1271 | 1302 |
1687 "http output filter \"%V?%V\"", &r->uri, &r->args); | 1718 "http output filter \"%V?%V\"", &r->uri, &r->args); |
1688 | 1719 |
1689 rc = ngx_http_top_body_filter(r, in); | 1720 rc = ngx_http_top_body_filter(r, in); |
1690 | 1721 |
1691 if (rc == NGX_ERROR) { | 1722 if (rc == NGX_ERROR) { |
1692 | |
1693 if (c->destroyed) { | |
1694 return NGX_DONE; | |
1695 } | |
1696 | |
1697 /* NGX_ERROR may be returned by any filter */ | 1723 /* NGX_ERROR may be returned by any filter */ |
1698 c->error = 1; | 1724 c->error = 1; |
1699 } | 1725 } |
1700 | 1726 |
1701 return rc; | 1727 return rc; |
2124 sr->main_filter_need_in_memory = r->main_filter_need_in_memory; | 2150 sr->main_filter_need_in_memory = r->main_filter_need_in_memory; |
2125 | 2151 |
2126 sr->uri_changes = NGX_HTTP_MAX_URI_CHANGES + 1; | 2152 sr->uri_changes = NGX_HTTP_MAX_URI_CHANGES + 1; |
2127 | 2153 |
2128 r->main->subrequests++; | 2154 r->main->subrequests++; |
2155 r->main->count++; | |
2129 | 2156 |
2130 *psr = sr; | 2157 *psr = sr; |
2131 | 2158 |
2132 return ngx_http_post_request(sr); | 2159 return ngx_http_post_request(sr, NULL); |
2133 } | 2160 } |
2134 | 2161 |
2135 | 2162 |
2136 ngx_int_t | 2163 ngx_int_t |
2137 ngx_http_internal_redirect(ngx_http_request_t *r, | 2164 ngx_http_internal_redirect(ngx_http_request_t *r, |
2144 if (r->uri_changes == 0) { | 2171 if (r->uri_changes == 0) { |
2145 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | 2172 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
2146 "rewrite or internal redirection cycle " | 2173 "rewrite or internal redirection cycle " |
2147 "while internal redirect to \"%V\"", uri); | 2174 "while internal redirect to \"%V\"", uri); |
2148 | 2175 |
2176 r->main->count++; | |
2149 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | 2177 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
2150 return NGX_DONE; | 2178 return NGX_DONE; |
2151 } | 2179 } |
2152 | 2180 |
2153 r->uri = *uri; | 2181 r->uri = *uri; |
2176 #if (NGX_HTTP_CACHE) | 2204 #if (NGX_HTTP_CACHE) |
2177 r->cache = NULL; | 2205 r->cache = NULL; |
2178 #endif | 2206 #endif |
2179 | 2207 |
2180 r->internal = 1; | 2208 r->internal = 1; |
2209 r->main->count++; | |
2181 | 2210 |
2182 ngx_http_handler(r); | 2211 ngx_http_handler(r); |
2183 | 2212 |
2184 return NGX_DONE; | 2213 return NGX_DONE; |
2185 } | 2214 } |
2189 ngx_http_named_location(ngx_http_request_t *r, ngx_str_t *name) | 2218 ngx_http_named_location(ngx_http_request_t *r, ngx_str_t *name) |
2190 { | 2219 { |
2191 ngx_http_core_srv_conf_t *cscf; | 2220 ngx_http_core_srv_conf_t *cscf; |
2192 ngx_http_core_loc_conf_t **clcfp; | 2221 ngx_http_core_loc_conf_t **clcfp; |
2193 ngx_http_core_main_conf_t *cmcf; | 2222 ngx_http_core_main_conf_t *cmcf; |
2223 | |
2224 r->main->count++; | |
2194 | 2225 |
2195 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); | 2226 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
2196 | 2227 |
2197 if (cscf->named_locations) { | 2228 if (cscf->named_locations) { |
2198 | 2229 |
2919 lcf->client_body_in_file_only = NGX_CONF_UNSET_UINT; | 2950 lcf->client_body_in_file_only = NGX_CONF_UNSET_UINT; |
2920 lcf->client_body_in_single_buffer = NGX_CONF_UNSET; | 2951 lcf->client_body_in_single_buffer = NGX_CONF_UNSET; |
2921 lcf->internal = NGX_CONF_UNSET; | 2952 lcf->internal = NGX_CONF_UNSET; |
2922 lcf->sendfile = NGX_CONF_UNSET; | 2953 lcf->sendfile = NGX_CONF_UNSET; |
2923 lcf->sendfile_max_chunk = NGX_CONF_UNSET_SIZE; | 2954 lcf->sendfile_max_chunk = NGX_CONF_UNSET_SIZE; |
2955 #if (NGX_HAVE_FILE_AIO) | |
2956 lcf->aio = NGX_CONF_UNSET; | |
2957 #endif | |
2924 lcf->directio = NGX_CONF_UNSET; | 2958 lcf->directio = NGX_CONF_UNSET; |
2959 lcf->directio_alignment = NGX_CONF_UNSET; | |
2925 lcf->tcp_nopush = NGX_CONF_UNSET; | 2960 lcf->tcp_nopush = NGX_CONF_UNSET; |
2926 lcf->tcp_nodelay = NGX_CONF_UNSET; | 2961 lcf->tcp_nodelay = NGX_CONF_UNSET; |
2927 lcf->send_timeout = NGX_CONF_UNSET_MSEC; | 2962 lcf->send_timeout = NGX_CONF_UNSET_MSEC; |
2928 lcf->send_lowat = NGX_CONF_UNSET_SIZE; | 2963 lcf->send_lowat = NGX_CONF_UNSET_SIZE; |
2929 lcf->postpone_output = NGX_CONF_UNSET_SIZE; | 2964 lcf->postpone_output = NGX_CONF_UNSET_SIZE; |
3116 prev->client_body_in_single_buffer, 0); | 3151 prev->client_body_in_single_buffer, 0); |
3117 ngx_conf_merge_value(conf->internal, prev->internal, 0); | 3152 ngx_conf_merge_value(conf->internal, prev->internal, 0); |
3118 ngx_conf_merge_value(conf->sendfile, prev->sendfile, 0); | 3153 ngx_conf_merge_value(conf->sendfile, prev->sendfile, 0); |
3119 ngx_conf_merge_size_value(conf->sendfile_max_chunk, | 3154 ngx_conf_merge_size_value(conf->sendfile_max_chunk, |
3120 prev->sendfile_max_chunk, 0); | 3155 prev->sendfile_max_chunk, 0); |
3156 #if (NGX_HAVE_FILE_AIO) | |
3157 ngx_conf_merge_value(conf->aio, prev->aio, 0); | |
3158 #endif | |
3121 ngx_conf_merge_off_value(conf->directio, prev->directio, | 3159 ngx_conf_merge_off_value(conf->directio, prev->directio, |
3122 NGX_MAX_OFF_T_VALUE); | 3160 NGX_MAX_OFF_T_VALUE); |
3161 ngx_conf_merge_off_value(conf->directio_alignment, prev->directio_alignment, | |
3162 512); | |
3123 ngx_conf_merge_value(conf->tcp_nopush, prev->tcp_nopush, 0); | 3163 ngx_conf_merge_value(conf->tcp_nopush, prev->tcp_nopush, 0); |
3124 ngx_conf_merge_value(conf->tcp_nodelay, prev->tcp_nodelay, 1); | 3164 ngx_conf_merge_value(conf->tcp_nodelay, prev->tcp_nodelay, 1); |
3125 | 3165 |
3126 ngx_conf_merge_msec_value(conf->send_timeout, prev->send_timeout, 60000); | 3166 ngx_conf_merge_msec_value(conf->send_timeout, prev->send_timeout, 60000); |
3127 ngx_conf_merge_size_value(conf->send_lowat, prev->send_lowat, 0); | 3167 ngx_conf_merge_size_value(conf->send_lowat, prev->send_lowat, 0); |
3509 #if (NGX_PCRE) | 3549 #if (NGX_PCRE) |
3510 { | 3550 { |
3511 ngx_str_t err; | 3551 ngx_str_t err; |
3512 u_char errstr[NGX_MAX_CONF_ERRSTR]; | 3552 u_char errstr[NGX_MAX_CONF_ERRSTR]; |
3513 | 3553 |
3554 if (value[i].len == 1) { | |
3555 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
3556 "empty regex in server name \"%V\"", &value[i]); | |
3557 return NGX_CONF_ERROR; | |
3558 } | |
3559 | |
3514 err.len = NGX_MAX_CONF_ERRSTR; | 3560 err.len = NGX_MAX_CONF_ERRSTR; |
3515 err.data = errstr; | 3561 err.data = errstr; |
3516 | 3562 |
3517 value[i].len--; | 3563 value[i].len--; |
3518 value[i].data++; | 3564 value[i].data++; |