comparison src/http/ngx_http_core_module.c @ 4241:6afb20bf2ad5 stable-1.0

Merging r4009, r4133, r4184, r4201, r4202, r4203, r4204, r4205: Miscellaneous fixes: *) Fix of names of the referer hash size directives introduced in r3940. *) Cosmetics: replaced NGX_CONF_TAKE1 to NGX_CONF_FLAG for "sendfile" and "chunked_transfer_encoding" directives, to be in line with all directives taking a boolean argument. Both flags will ensure that a directive takes one argument. *) Improved ngx_parse_time() code readability. *) Preallocating exact number of default MIME types entries. *) Stylistic change in checking the boolean expression. *) Replaced magic constants representing default values of some directives with appropriate #define's. *) Fixed grammar in a comment. *) Fixed two minor bugs in "types" parsing code.
author Igor Sysoev <igor@sysoev.ru>
date Tue, 01 Nov 2011 11:19:58 +0000
parents fb1375e8b68c
children d3568507db51
comparison
equal deleted inserted replaced
4240:17ab1927f80f 4241:6afb20bf2ad5
400 offsetof(ngx_http_core_loc_conf_t, client_body_in_single_buffer), 400 offsetof(ngx_http_core_loc_conf_t, client_body_in_single_buffer),
401 NULL }, 401 NULL },
402 402
403 { ngx_string("sendfile"), 403 { ngx_string("sendfile"),
404 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF 404 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
405 |NGX_CONF_TAKE1, 405 |NGX_CONF_FLAG,
406 ngx_conf_set_flag_slot, 406 ngx_conf_set_flag_slot,
407 NGX_HTTP_LOC_CONF_OFFSET, 407 NGX_HTTP_LOC_CONF_OFFSET,
408 offsetof(ngx_http_core_loc_conf_t, sendfile), 408 offsetof(ngx_http_core_loc_conf_t, sendfile),
409 NULL }, 409 NULL },
410 410
637 NGX_HTTP_LOC_CONF_OFFSET, 637 NGX_HTTP_LOC_CONF_OFFSET,
638 offsetof(ngx_http_core_loc_conf_t, max_ranges), 638 offsetof(ngx_http_core_loc_conf_t, max_ranges),
639 NULL }, 639 NULL },
640 640
641 { ngx_string("chunked_transfer_encoding"), 641 { ngx_string("chunked_transfer_encoding"),
642 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, 642 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
643 ngx_conf_set_flag_slot, 643 ngx_conf_set_flag_slot,
644 NGX_HTTP_LOC_CONF_OFFSET, 644 NGX_HTTP_LOC_CONF_OFFSET,
645 offsetof(ngx_http_core_loc_conf_t, chunked_transfer_encoding), 645 offsetof(ngx_http_core_loc_conf_t, chunked_transfer_encoding),
646 NULL }, 646 NULL },
647 647
2993 ngx_hash_key_t *type; 2993 ngx_hash_key_t *type;
2994 2994
2995 value = cf->args->elts; 2995 value = cf->args->elts;
2996 2996
2997 if (ngx_strcmp(value[0].data, "include") == 0) { 2997 if (ngx_strcmp(value[0].data, "include") == 0) {
2998 if (cf->args->nelts != 2) {
2999 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
3000 "invalid number of arguments"
3001 " in \"include\" directive");
3002 return NGX_CONF_ERROR;
3003 }
2998 file = value[1]; 3004 file = value[1];
2999 3005
3000 if (ngx_conf_full_name(cf->cycle, &file, 1) != NGX_OK) { 3006 if (ngx_conf_full_name(cf->cycle, &file, 1) != NGX_OK) {
3001 return NGX_CONF_ERROR; 3007 return NGX_CONF_ERROR;
3002 } 3008 }
3026 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, 3032 ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
3027 "duplicate extention \"%V\", " 3033 "duplicate extention \"%V\", "
3028 "content type: \"%V\", " 3034 "content type: \"%V\", "
3029 "old content type: \"%V\"", 3035 "old content type: \"%V\"",
3030 &value[i], content_type, old); 3036 &value[i], content_type, old);
3031 continue; 3037 goto next;
3032 } 3038 }
3033 } 3039 }
3034 3040
3035 3041
3036 type = ngx_array_push(clcf->types); 3042 type = ngx_array_push(clcf->types);
3039 } 3045 }
3040 3046
3041 type->key = value[i]; 3047 type->key = value[i];
3042 type->key_hash = hash; 3048 type->key_hash = hash;
3043 type->value = content_type; 3049 type->value = content_type;
3050
3051 next:
3052 continue;
3044 } 3053 }
3045 3054
3046 return NGX_CONF_OK; 3055 return NGX_CONF_OK;
3047 } 3056 }
3048 3057
3372 3381
3373 conf->types_hash_bucket_size = ngx_align(conf->types_hash_bucket_size, 3382 conf->types_hash_bucket_size = ngx_align(conf->types_hash_bucket_size,
3374 ngx_cacheline_size); 3383 ngx_cacheline_size);
3375 3384
3376 /* 3385 /*
3377 * the special handling the "types" directive in the "http" section 3386 * the special handling of the "types" directive in the "http" section
3378 * to inherit the http's conf->types_hash to all servers 3387 * to inherit the http's conf->types_hash to all servers
3379 */ 3388 */
3380 3389
3381 if (prev->types && prev->types_hash.buckets == NULL) { 3390 if (prev->types && prev->types_hash.buckets == NULL) {
3382 3391
3399 conf->types = prev->types; 3408 conf->types = prev->types;
3400 conf->types_hash = prev->types_hash; 3409 conf->types_hash = prev->types_hash;
3401 } 3410 }
3402 3411
3403 if (conf->types == NULL) { 3412 if (conf->types == NULL) {
3404 conf->types = ngx_array_create(cf->pool, 4, sizeof(ngx_hash_key_t)); 3413 conf->types = ngx_array_create(cf->pool, 3, sizeof(ngx_hash_key_t));
3405 if (conf->types == NULL) { 3414 if (conf->types == NULL) {
3406 return NGX_CONF_ERROR; 3415 return NGX_CONF_ERROR;
3407 } 3416 }
3408 3417
3409 for (i = 0; ngx_http_core_default_types[i].key.len; i++) { 3418 for (i = 0; ngx_http_core_default_types[i].key.len; i++) {
3466 ngx_conf_merge_uint_value(conf->satisfy, prev->satisfy, 3475 ngx_conf_merge_uint_value(conf->satisfy, prev->satisfy,
3467 NGX_HTTP_SATISFY_ALL); 3476 NGX_HTTP_SATISFY_ALL);
3468 ngx_conf_merge_uint_value(conf->if_modified_since, prev->if_modified_since, 3477 ngx_conf_merge_uint_value(conf->if_modified_since, prev->if_modified_since,
3469 NGX_HTTP_IMS_EXACT); 3478 NGX_HTTP_IMS_EXACT);
3470 ngx_conf_merge_uint_value(conf->max_ranges, prev->max_ranges, 3479 ngx_conf_merge_uint_value(conf->max_ranges, prev->max_ranges,
3471 0x7fffffff); 3480 NGX_MAX_INT32_VALUE);
3472 ngx_conf_merge_uint_value(conf->client_body_in_file_only, 3481 ngx_conf_merge_uint_value(conf->client_body_in_file_only,
3473 prev->client_body_in_file_only, 0); 3482 prev->client_body_in_file_only,
3483 NGX_HTTP_REQUEST_BODY_FILE_OFF);
3474 ngx_conf_merge_value(conf->client_body_in_single_buffer, 3484 ngx_conf_merge_value(conf->client_body_in_single_buffer,
3475 prev->client_body_in_single_buffer, 0); 3485 prev->client_body_in_single_buffer, 0);
3476 ngx_conf_merge_value(conf->internal, prev->internal, 0); 3486 ngx_conf_merge_value(conf->internal, prev->internal, 0);
3477 ngx_conf_merge_value(conf->sendfile, prev->sendfile, 0); 3487 ngx_conf_merge_value(conf->sendfile, prev->sendfile, 0);
3478 ngx_conf_merge_size_value(conf->sendfile_max_chunk, 3488 ngx_conf_merge_size_value(conf->sendfile_max_chunk,
3479 prev->sendfile_max_chunk, 0); 3489 prev->sendfile_max_chunk, 0);
3480 #if (NGX_HAVE_FILE_AIO) 3490 #if (NGX_HAVE_FILE_AIO)
3481 ngx_conf_merge_value(conf->aio, prev->aio, 0); 3491 ngx_conf_merge_value(conf->aio, prev->aio, NGX_HTTP_AIO_OFF);
3482 #endif 3492 #endif
3483 ngx_conf_merge_size_value(conf->read_ahead, prev->read_ahead, 0); 3493 ngx_conf_merge_size_value(conf->read_ahead, prev->read_ahead, 0);
3484 ngx_conf_merge_off_value(conf->directio, prev->directio, 3494 ngx_conf_merge_off_value(conf->directio, prev->directio,
3485 NGX_MAX_OFF_T_VALUE); 3495 NGX_OPEN_FILE_DIRECTIO_OFF);
3486 ngx_conf_merge_off_value(conf->directio_alignment, prev->directio_alignment, 3496 ngx_conf_merge_off_value(conf->directio_alignment, prev->directio_alignment,
3487 512); 3497 512);
3488 ngx_conf_merge_value(conf->tcp_nopush, prev->tcp_nopush, 0); 3498 ngx_conf_merge_value(conf->tcp_nopush, prev->tcp_nopush, 0);
3489 ngx_conf_merge_value(conf->tcp_nodelay, prev->tcp_nodelay, 1); 3499 ngx_conf_merge_value(conf->tcp_nodelay, prev->tcp_nodelay, 1);
3490 3500