Mercurial > hg > nginx-mail
comparison src/http/ngx_http_core_module.c @ 36:a39d1b793287 NGINX_0_1_18
nginx 0.1.18
*) Workaround: the default values of the devpoll_events and the
devpoll_changes directives changed from 512 to 32 to be compatible
with Solaris 10.
*) Bugfix: the proxy_set_x_var and fastcgi_set_var directives were not
inherited.
*) Bugfix: in the redirect rewrite directive the arguments were
concatenated with URI by the "&" rather than the "?".
*) Bugfix: the lines without trailing ";" in the file being included by
the ngx_http_geo_module were silently ignored.
*) Feature: the ngx_http_stub_status_module.
*) Bugfix: the unknown log format in the access_log directive caused
the segmentation fault.
*) Feature: the new "document_root" parameter of the fastcgi_params
directive.
*) Feature: the fastcgi_redirect_errors directive.
*) Feature: the new "break" modifier of the "rewrite" directive allows
to stop the rewrite/location cycle and sets the current
configuration to the request.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Wed, 09 Feb 2005 00:00:00 +0300 |
parents | aab2ea7c0458 |
children | 2879cd3a40cb |
comparison
equal
deleted
inserted
replaced
35:ef53675fe4a6 | 36:a39d1b793287 |
---|---|
18 | 18 |
19 | 19 |
20 static void ngx_http_core_phase_event_handler(ngx_event_t *rev); | 20 static void ngx_http_core_phase_event_handler(ngx_event_t *rev); |
21 static void ngx_http_core_run_phases(ngx_http_request_t *r); | 21 static void ngx_http_core_run_phases(ngx_http_request_t *r); |
22 static ngx_int_t ngx_http_core_find_location(ngx_http_request_t *r, | 22 static ngx_int_t ngx_http_core_find_location(ngx_http_request_t *r, |
23 ngx_array_t *locations, size_t len); | 23 ngx_array_t *locations, size_t len); |
24 | 24 |
25 static void *ngx_http_core_create_main_conf(ngx_conf_t *cf); | 25 static void *ngx_http_core_create_main_conf(ngx_conf_t *cf); |
26 static char *ngx_http_core_init_main_conf(ngx_conf_t *cf, void *conf); | 26 static char *ngx_http_core_init_main_conf(ngx_conf_t *cf, void *conf); |
27 static void *ngx_http_core_create_srv_conf(ngx_conf_t *cf); | 27 static void *ngx_http_core_create_srv_conf(ngx_conf_t *cf); |
28 static char *ngx_http_core_merge_srv_conf(ngx_conf_t *cf, | 28 static char *ngx_http_core_merge_srv_conf(ngx_conf_t *cf, |
29 void *parent, void *child); | 29 void *parent, void *child); |
30 static void *ngx_http_core_create_loc_conf(ngx_conf_t *cf); | 30 static void *ngx_http_core_create_loc_conf(ngx_conf_t *cf); |
31 static char *ngx_http_core_merge_loc_conf(ngx_conf_t *cf, | 31 static char *ngx_http_core_merge_loc_conf(ngx_conf_t *cf, |
32 void *parent, void *child); | 32 void *parent, void *child); |
33 | 33 |
34 static char *ngx_http_core_server(ngx_conf_t *cf, ngx_command_t *cmd, | 34 static char *ngx_http_core_server(ngx_conf_t *cf, ngx_command_t *cmd, |
35 void *dummy); | 35 void *dummy); |
36 static char *ngx_http_core_location(ngx_conf_t *cf, ngx_command_t *cmd, | 36 static char *ngx_http_core_location(ngx_conf_t *cf, ngx_command_t *cmd, |
37 void *dummy); | 37 void *dummy); |
38 static int ngx_http_core_cmp_locations(const void *first, const void *second); | 38 static int ngx_http_core_cmp_locations(const void *first, const void *second); |
39 | 39 |
40 static char *ngx_http_core_types(ngx_conf_t *cf, ngx_command_t *cmd, | 40 static char *ngx_http_core_types(ngx_conf_t *cf, ngx_command_t *cmd, |
41 void *conf); | 41 void *conf); |
42 static char *ngx_http_core_type(ngx_conf_t *cf, ngx_command_t *dummy, | 42 static char *ngx_http_core_type(ngx_conf_t *cf, ngx_command_t *dummy, |
43 void *conf); | 43 void *conf); |
44 | 44 |
45 static char *ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, | 45 static char *ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, |
46 void *conf); | 46 void *conf); |
47 static char *ngx_http_core_server_name(ngx_conf_t *cf, ngx_command_t *cmd, | 47 static char *ngx_http_core_server_name(ngx_conf_t *cf, ngx_command_t *cmd, |
48 void *conf); | 48 void *conf); |
49 static char *ngx_http_core_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | 49 static char *ngx_http_core_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
50 static char *ngx_http_core_error_page(ngx_conf_t *cf, ngx_command_t *cmd, | 50 static char *ngx_http_core_error_page(ngx_conf_t *cf, ngx_command_t *cmd, |
51 void *conf); | 51 void *conf); |
52 static char *ngx_http_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd, | 52 static char *ngx_http_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd, |
53 void *conf); | 53 void *conf); |
54 static char *ngx_http_core_keepalive(ngx_conf_t *cf, ngx_command_t *cmd, | 54 static char *ngx_http_core_keepalive(ngx_conf_t *cf, ngx_command_t *cmd, |
55 void *conf); | 55 void *conf); |
56 | 56 |
57 static char *ngx_http_core_lowat_check(ngx_conf_t *cf, void *post, void *data); | 57 static char *ngx_http_core_lowat_check(ngx_conf_t *cf, void *post, void *data); |
58 | 58 |
59 static ngx_conf_post_t ngx_http_core_lowat_post = | 59 static ngx_conf_post_t ngx_http_core_lowat_post = |
60 { ngx_http_core_lowat_check }; | 60 { ngx_http_core_lowat_check }; |
358 NULL, /* init module */ | 358 NULL, /* init module */ |
359 NULL /* init process */ | 359 NULL /* init process */ |
360 }; | 360 }; |
361 | 361 |
362 | 362 |
363 void ngx_http_handler(ngx_http_request_t *r) | 363 void |
364 ngx_http_handler(ngx_http_request_t *r) | |
364 { | 365 { |
365 r->connection->log->action = NULL; | 366 r->connection->log->action = NULL; |
366 | 367 |
367 r->connection->unexpected_eof = 0; | 368 r->connection->unexpected_eof = 0; |
368 | 369 |
414 | 415 |
415 r->uri_changed = 1; | 416 r->uri_changed = 1; |
416 r->uri_changes = 11; | 417 r->uri_changes = 11; |
417 | 418 |
418 ngx_http_core_run_phases(r); | 419 ngx_http_core_run_phases(r); |
419 | 420 } |
420 return; | 421 |
421 } | 422 |
422 | 423 static void |
423 | 424 ngx_http_core_phase_event_handler(ngx_event_t *ev) |
424 static void ngx_http_core_phase_event_handler(ngx_event_t *ev) | |
425 { | 425 { |
426 ngx_connection_t *c; | 426 ngx_connection_t *c; |
427 ngx_http_request_t *r; | 427 ngx_http_request_t *r; |
428 | 428 |
429 c = ev->data; | 429 c = ev->data; |
430 r = c->data; | 430 r = c->data; |
431 | 431 |
432 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0, "phase event handler"); | 432 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0, "phase event handler"); |
433 | 433 |
434 ngx_http_core_run_phases(r); | 434 ngx_http_core_run_phases(r); |
435 | 435 } |
436 return; | 436 |
437 } | 437 |
438 | 438 static void |
439 | 439 ngx_http_core_run_phases(ngx_http_request_t *r) |
440 static void ngx_http_core_run_phases(ngx_http_request_t *r) | |
441 { | 440 { |
442 ngx_int_t rc; | 441 ngx_int_t rc; |
443 ngx_http_handler_pt *h; | 442 ngx_http_handler_pt *h; |
444 ngx_http_core_loc_conf_t *clcf; | 443 ngx_http_core_loc_conf_t *clcf; |
445 ngx_http_core_main_conf_t *cmcf; | 444 ngx_http_core_main_conf_t *cmcf; |
539 } | 538 } |
540 | 539 |
541 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "no handler found"); | 540 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "no handler found"); |
542 | 541 |
543 ngx_http_finalize_request(r, NGX_HTTP_NOT_FOUND); | 542 ngx_http_finalize_request(r, NGX_HTTP_NOT_FOUND); |
544 return; | 543 } |
545 } | 544 |
546 | 545 |
547 | 546 ngx_int_t |
548 ngx_int_t ngx_http_find_location_config(ngx_http_request_t *r) | 547 ngx_http_find_location_config(ngx_http_request_t *r) |
549 { | 548 { |
550 ngx_int_t rc; | 549 ngx_int_t rc; |
551 ngx_http_core_loc_conf_t *clcf; | 550 ngx_http_core_loc_conf_t *clcf; |
552 ngx_http_core_srv_conf_t *cscf; | 551 ngx_http_core_srv_conf_t *cscf; |
553 | 552 |
616 | 615 |
617 return NGX_OK; | 616 return NGX_OK; |
618 } | 617 } |
619 | 618 |
620 | 619 |
621 static ngx_int_t ngx_http_core_find_location(ngx_http_request_t *r, | 620 static ngx_int_t |
622 ngx_array_t *locations, size_t len) | 621 ngx_http_core_find_location(ngx_http_request_t *r, |
622 ngx_array_t *locations, size_t len) | |
623 { | 623 { |
624 ngx_int_t n, rc; | 624 ngx_int_t n, rc; |
625 ngx_uint_t i, found, noregex; | 625 ngx_uint_t i, found, noregex; |
626 ngx_http_core_loc_conf_t *clcf, **clcfp; | 626 ngx_http_core_loc_conf_t *clcf, **clcfp; |
627 | 627 |
750 | 750 |
751 return NGX_OK; | 751 return NGX_OK; |
752 } | 752 } |
753 | 753 |
754 | 754 |
755 ngx_int_t ngx_http_set_content_type(ngx_http_request_t *r) | 755 ngx_int_t |
756 ngx_http_set_content_type(ngx_http_request_t *r) | |
756 { | 757 { |
757 u_char c, *p, *exten; | 758 u_char c, *p, *exten; |
758 uint32_t key; | 759 uint32_t key; |
759 ngx_uint_t i; | 760 ngx_uint_t i; |
760 ngx_http_type_t *type; | 761 ngx_http_type_t *type; |
830 | 831 |
831 return NGX_OK; | 832 return NGX_OK; |
832 } | 833 } |
833 | 834 |
834 | 835 |
835 ngx_int_t ngx_http_send_header(ngx_http_request_t *r) | 836 ngx_int_t |
837 ngx_http_send_header(ngx_http_request_t *r) | |
836 { | 838 { |
837 if (r->main) { | 839 if (r->main) { |
838 return NGX_OK; | 840 return NGX_OK; |
839 } | 841 } |
840 | 842 |
841 if (r->err_ctx) { | 843 if (r->err_ctx) { |
842 r->headers_out.status = r->err_status; | 844 r->headers_out.status = r->err_status; |
843 r->headers_out.status_line.len = 0; | 845 r->headers_out.status_line.len = 0; |
844 } | 846 } |
845 | 847 |
846 return (*ngx_http_top_header_filter)(r); | 848 return ngx_http_top_header_filter(r); |
847 } | 849 } |
848 | 850 |
849 | 851 |
850 ngx_int_t ngx_http_output_filter(ngx_http_request_t *r, ngx_chain_t *in) | 852 ngx_int_t |
853 ngx_http_output_filter(ngx_http_request_t *r, ngx_chain_t *in) | |
851 { | 854 { |
852 ngx_int_t rc; | 855 ngx_int_t rc; |
853 | 856 |
854 if (r->connection->write->error) { | 857 if (r->connection->write->error) { |
855 return NGX_ERROR; | 858 return NGX_ERROR; |
857 | 860 |
858 rc = ngx_http_top_body_filter(r, in); | 861 rc = ngx_http_top_body_filter(r, in); |
859 | 862 |
860 if (rc == NGX_ERROR) { | 863 if (rc == NGX_ERROR) { |
861 | 864 |
862 /* NGX_ERROR could be returned by any filter */ | 865 /* NGX_ERROR may be returned by any filter */ |
863 | 866 |
864 r->connection->write->error = 1; | 867 r->connection->write->error = 1; |
865 } | 868 } |
866 | 869 |
867 return rc; | 870 return rc; |
868 } | 871 } |
869 | 872 |
870 | 873 |
871 int ngx_http_redirect(ngx_http_request_t *r, int redirect) | 874 ngx_int_t |
875 ngx_http_redirect(ngx_http_request_t *r, int redirect) | |
872 { | 876 { |
873 /* STUB */ | 877 /* STUB */ |
874 | 878 |
875 /* log request */ | 879 /* log request */ |
876 | 880 |
877 ngx_http_close_request(r, 0); | 881 ngx_http_close_request(r, 0); |
878 return NGX_OK; | 882 return NGX_OK; |
879 } | 883 } |
880 | 884 |
881 | 885 |
882 ngx_int_t ngx_http_set_exten(ngx_http_request_t *r) | 886 ngx_int_t |
887 ngx_http_set_exten(ngx_http_request_t *r) | |
883 { | 888 { |
884 ngx_int_t i; | 889 ngx_int_t i; |
885 | 890 |
886 r->exten.len = 0; | 891 r->exten.len = 0; |
887 r->exten.data = NULL; | 892 r->exten.data = NULL; |
910 | 915 |
911 return NGX_OK; | 916 return NGX_OK; |
912 } | 917 } |
913 | 918 |
914 | 919 |
915 ngx_int_t ngx_http_internal_redirect(ngx_http_request_t *r, | 920 ngx_int_t |
916 ngx_str_t *uri, ngx_str_t *args) | 921 ngx_http_internal_redirect(ngx_http_request_t *r, |
917 { | 922 ngx_str_t *uri, ngx_str_t *args) |
923 { | |
924 ngx_http_core_srv_conf_t *cscf; | |
925 | |
918 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 926 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
919 "internal redirect: \"%V\"", uri); | 927 "internal redirect: \"%V\"", uri); |
920 | 928 |
921 r->uri = *uri; | 929 r->uri = *uri; |
922 | 930 |
928 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 936 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
929 } | 937 } |
930 | 938 |
931 if (r->err_ctx) { | 939 if (r->err_ctx) { |
932 | 940 |
933 /* allocate the new modules contexts */ | 941 /* allocate the new module's contexts */ |
934 | 942 |
935 r->ctx = ngx_pcalloc(r->pool, sizeof(void *) * ngx_http_max_module); | 943 r->ctx = ngx_pcalloc(r->pool, sizeof(void *) * ngx_http_max_module); |
936 if (r->ctx == NULL) { | 944 if (r->ctx == NULL) { |
937 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 945 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
938 } | 946 } |
942 /* clear the modules contexts */ | 950 /* clear the modules contexts */ |
943 | 951 |
944 ngx_memzero(r->ctx, sizeof(void *) * ngx_http_max_module); | 952 ngx_memzero(r->ctx, sizeof(void *) * ngx_http_max_module); |
945 } | 953 } |
946 | 954 |
955 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); | |
956 r->loc_conf = cscf->ctx->loc_conf; | |
957 | |
947 r->phase = 0; | 958 r->phase = 0; |
948 r->phase_handler = 0; | 959 r->phase_handler = 0; |
949 r->content_handler = NULL; | 960 r->content_handler = NULL; |
950 | 961 |
951 ngx_http_handler(r); | 962 ngx_http_handler(r); |
954 } | 965 } |
955 | 966 |
956 | 967 |
957 #if 0 /* STUB: test the delay http handler */ | 968 #if 0 /* STUB: test the delay http handler */ |
958 | 969 |
959 int ngx_http_delay_handler(ngx_http_request_t *r) | 970 ngx_int_t |
971 ngx_http_delay_handler(ngx_http_request_t *r) | |
960 { | 972 { |
961 static int on; | 973 static int on; |
962 | 974 |
963 if (on++ == 0) { | 975 if (on++ == 0) { |
964 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 976 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
974 } | 986 } |
975 | 987 |
976 #endif | 988 #endif |
977 | 989 |
978 | 990 |
979 ngx_http_variable_t *ngx_http_add_variable(ngx_conf_t *cf) | 991 ngx_http_variable_t * |
992 ngx_http_add_variable(ngx_conf_t *cf) | |
980 { | 993 { |
981 ngx_http_variable_t *var; | 994 ngx_http_variable_t *var; |
982 ngx_http_core_main_conf_t *cmcf; | 995 ngx_http_core_main_conf_t *cmcf; |
983 | 996 |
984 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); | 997 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); |
999 | 1012 |
1000 return var; | 1013 return var; |
1001 } | 1014 } |
1002 | 1015 |
1003 | 1016 |
1004 ngx_http_variable_value_t *ngx_http_get_variable(ngx_http_request_t *r, | 1017 ngx_http_variable_value_t * |
1005 ngx_uint_t index) | 1018 ngx_http_get_variable(ngx_http_request_t *r, ngx_uint_t index) |
1006 { | 1019 { |
1007 ngx_http_variable_t *v; | 1020 ngx_http_variable_t *v; |
1008 ngx_http_core_main_conf_t *cmcf; | 1021 ngx_http_core_main_conf_t *cmcf; |
1009 | 1022 |
1010 /* TODO: cached variables */ | 1023 /* TODO: cached variables */ |
1021 | 1034 |
1022 return v[index].handler(r, v[index].data); | 1035 return v[index].handler(r, v[index].data); |
1023 } | 1036 } |
1024 | 1037 |
1025 | 1038 |
1026 static char *ngx_http_core_server(ngx_conf_t *cf, ngx_command_t *cmd, | 1039 static char * |
1027 void *dummy) | 1040 ngx_http_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy) |
1028 { | 1041 { |
1029 int m; | 1042 int m; |
1030 char *rv; | 1043 char *rv; |
1031 ngx_http_module_t *module; | 1044 void *mconf; |
1032 ngx_conf_t save; | 1045 ngx_conf_t save; |
1033 ngx_http_conf_ctx_t *ctx, *http_ctx; | 1046 ngx_http_module_t *module; |
1034 ngx_http_core_main_conf_t *cmcf; | 1047 ngx_http_conf_ctx_t *ctx, *http_ctx; |
1035 ngx_http_core_srv_conf_t *cscf, **cscfp; | 1048 ngx_http_core_srv_conf_t *cscf, **cscfp; |
1036 | 1049 ngx_http_core_main_conf_t *cmcf; |
1037 ngx_test_null(ctx, | 1050 |
1038 ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)), | 1051 if (!(ctx = ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)))) { |
1039 NGX_CONF_ERROR); | 1052 return NGX_CONF_ERROR; |
1053 } | |
1040 | 1054 |
1041 http_ctx = cf->ctx; | 1055 http_ctx = cf->ctx; |
1042 ctx->main_conf = http_ctx->main_conf; | 1056 ctx->main_conf = http_ctx->main_conf; |
1043 | 1057 |
1044 /* the server{}'s srv_conf */ | 1058 /* the server{}'s srv_conf */ |
1045 | 1059 |
1046 ngx_test_null(ctx->srv_conf, | 1060 ctx->srv_conf = ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module); |
1047 ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module), | 1061 if (ctx->srv_conf == NULL) { |
1048 NGX_CONF_ERROR); | 1062 return NGX_CONF_ERROR; |
1063 } | |
1049 | 1064 |
1050 /* the server{}'s loc_conf */ | 1065 /* the server{}'s loc_conf */ |
1051 | 1066 |
1052 ngx_test_null(ctx->loc_conf, | 1067 ctx->loc_conf = ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module); |
1053 ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module), | 1068 if (ctx->loc_conf == NULL) { |
1054 NGX_CONF_ERROR); | 1069 return NGX_CONF_ERROR; |
1070 } | |
1055 | 1071 |
1056 for (m = 0; ngx_modules[m]; m++) { | 1072 for (m = 0; ngx_modules[m]; m++) { |
1057 if (ngx_modules[m]->type != NGX_HTTP_MODULE) { | 1073 if (ngx_modules[m]->type != NGX_HTTP_MODULE) { |
1058 continue; | 1074 continue; |
1059 } | 1075 } |
1060 | 1076 |
1061 module = ngx_modules[m]->ctx; | 1077 module = ngx_modules[m]->ctx; |
1062 | 1078 |
1063 if (module->create_srv_conf) { | 1079 if (module->create_srv_conf) { |
1064 ngx_test_null(ctx->srv_conf[ngx_modules[m]->ctx_index], | 1080 if (!(mconf = module->create_srv_conf(cf))) { |
1065 module->create_srv_conf(cf), | 1081 return NGX_CONF_ERROR; |
1066 NGX_CONF_ERROR); | 1082 } |
1083 | |
1084 ctx->srv_conf[ngx_modules[m]->ctx_index] = mconf; | |
1067 } | 1085 } |
1068 | 1086 |
1069 if (module->create_loc_conf) { | 1087 if (module->create_loc_conf) { |
1070 ngx_test_null(ctx->loc_conf[ngx_modules[m]->ctx_index], | 1088 if (!(mconf = module->create_loc_conf(cf))) { |
1071 module->create_loc_conf(cf), | 1089 return NGX_CONF_ERROR; |
1072 NGX_CONF_ERROR); | 1090 } |
1073 } | 1091 |
1074 } | 1092 ctx->loc_conf[ngx_modules[m]->ctx_index] = mconf; |
1075 | 1093 } |
1076 /* create links of the srv_conf's */ | 1094 } |
1095 | |
1096 | |
1097 /* the server configuration context */ | |
1077 | 1098 |
1078 cscf = ctx->srv_conf[ngx_http_core_module.ctx_index]; | 1099 cscf = ctx->srv_conf[ngx_http_core_module.ctx_index]; |
1079 cscf->ctx = ctx; | 1100 cscf->ctx = ctx; |
1080 | 1101 |
1102 | |
1081 cmcf = ctx->main_conf[ngx_http_core_module.ctx_index]; | 1103 cmcf = ctx->main_conf[ngx_http_core_module.ctx_index]; |
1082 ngx_test_null(cscfp, ngx_push_array(&cmcf->servers), NGX_CONF_ERROR); | 1104 |
1105 if (!(cscfp = ngx_array_push(&cmcf->servers))) { | |
1106 return NGX_CONF_ERROR; | |
1107 } | |
1108 | |
1083 *cscfp = cscf; | 1109 *cscfp = cscf; |
1110 | |
1084 | 1111 |
1085 /* parse inside server{} */ | 1112 /* parse inside server{} */ |
1086 | 1113 |
1087 save = *cf; | 1114 save = *cf; |
1088 cf->ctx = ctx; | 1115 cf->ctx = ctx; |
1101 | 1128 |
1102 return rv; | 1129 return rv; |
1103 } | 1130 } |
1104 | 1131 |
1105 | 1132 |
1106 static char *ngx_http_core_location(ngx_conf_t *cf, ngx_command_t *cmd, | 1133 static char * |
1107 void *dummy) | 1134 ngx_http_core_location(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy) |
1108 { | 1135 { |
1109 char *rv; | 1136 char *rv; |
1110 ngx_int_t m; | 1137 ngx_int_t m; |
1111 ngx_str_t *value; | 1138 ngx_str_t *value; |
1112 ngx_conf_t save; | 1139 ngx_conf_t save; |
1203 | 1230 |
1204 pclcf = pctx->loc_conf[ngx_http_core_module.ctx_index]; | 1231 pclcf = pctx->loc_conf[ngx_http_core_module.ctx_index]; |
1205 | 1232 |
1206 if (pclcf->name.len == 0) { | 1233 if (pclcf->name.len == 0) { |
1207 cscf = ctx->srv_conf[ngx_http_core_module.ctx_index]; | 1234 cscf = ctx->srv_conf[ngx_http_core_module.ctx_index]; |
1208 if (!(clcfp = ngx_push_array(&cscf->locations))) { | 1235 if (!(clcfp = ngx_array_push(&cscf->locations))) { |
1209 return NGX_CONF_ERROR; | 1236 return NGX_CONF_ERROR; |
1210 } | 1237 } |
1211 | 1238 |
1212 } else { | 1239 } else { |
1213 #if 0 | 1240 #if 0 |
1266 | 1293 |
1267 return rv; | 1294 return rv; |
1268 } | 1295 } |
1269 | 1296 |
1270 | 1297 |
1271 static int ngx_http_core_cmp_locations(const void *one, const void *two) | 1298 static int |
1299 ngx_http_core_cmp_locations(const void *one, const void *two) | |
1272 { | 1300 { |
1273 ngx_int_t rc; | 1301 ngx_int_t rc; |
1274 ngx_http_core_loc_conf_t *first, *second; | 1302 ngx_http_core_loc_conf_t *first, *second; |
1275 | 1303 |
1276 first = *(ngx_http_core_loc_conf_t **) one; | 1304 first = *(ngx_http_core_loc_conf_t **) one; |
1319 | 1347 |
1320 return (int) rc; | 1348 return (int) rc; |
1321 } | 1349 } |
1322 | 1350 |
1323 | 1351 |
1324 static char *ngx_http_core_types(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | 1352 static char * |
1353 ngx_http_core_types(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
1325 { | 1354 { |
1326 char *rv; | 1355 char *rv; |
1327 ngx_conf_t save; | 1356 ngx_conf_t save; |
1328 | 1357 |
1329 save = *cf; | 1358 save = *cf; |
1336 | 1365 |
1337 return rv; | 1366 return rv; |
1338 } | 1367 } |
1339 | 1368 |
1340 | 1369 |
1341 static char *ngx_http_core_type(ngx_conf_t *cf, ngx_command_t *dummy, | 1370 static char * |
1342 void *conf) | 1371 ngx_http_core_type(ngx_conf_t *cf, ngx_command_t *dummy, void *conf) |
1343 { | 1372 { |
1344 ngx_http_core_loc_conf_t *lcf = conf; | 1373 ngx_http_core_loc_conf_t *lcf = conf; |
1345 | 1374 |
1346 uint32_t key; | 1375 uint32_t key; |
1347 ngx_uint_t i; | 1376 ngx_uint_t i; |
1379 | 1408 |
1380 return NGX_CONF_OK; | 1409 return NGX_CONF_OK; |
1381 } | 1410 } |
1382 | 1411 |
1383 | 1412 |
1384 static void *ngx_http_core_create_main_conf(ngx_conf_t *cf) | 1413 static void * |
1414 ngx_http_core_create_main_conf(ngx_conf_t *cf) | |
1385 { | 1415 { |
1386 ngx_http_core_main_conf_t *cmcf; | 1416 ngx_http_core_main_conf_t *cmcf; |
1387 | 1417 |
1388 if (!(cmcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_core_main_conf_t)))) { | 1418 if (!(cmcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_core_main_conf_t)))) { |
1389 return NGX_CONF_ERROR; | 1419 return NGX_CONF_ERROR; |
1400 | 1430 |
1401 return cmcf; | 1431 return cmcf; |
1402 } | 1432 } |
1403 | 1433 |
1404 | 1434 |
1405 static char *ngx_http_core_init_main_conf(ngx_conf_t *cf, void *conf) | 1435 static char * |
1436 ngx_http_core_init_main_conf(ngx_conf_t *cf, void *conf) | |
1406 { | 1437 { |
1407 ngx_http_core_main_conf_t *cmcf = conf; | 1438 ngx_http_core_main_conf_t *cmcf = conf; |
1408 | 1439 |
1409 if (cmcf->server_names_hash == NGX_CONF_UNSET_UINT) { | 1440 if (cmcf->server_names_hash == NGX_CONF_UNSET_UINT) { |
1410 cmcf->server_names_hash = 1009; | 1441 cmcf->server_names_hash = 1009; |
1416 | 1447 |
1417 return NGX_CONF_OK; | 1448 return NGX_CONF_OK; |
1418 } | 1449 } |
1419 | 1450 |
1420 | 1451 |
1421 static void *ngx_http_core_create_srv_conf(ngx_conf_t *cf) | 1452 static void * |
1453 ngx_http_core_create_srv_conf(ngx_conf_t *cf) | |
1422 { | 1454 { |
1423 ngx_http_core_srv_conf_t *cscf; | 1455 ngx_http_core_srv_conf_t *cscf; |
1424 | 1456 |
1425 ngx_test_null(cscf, | 1457 if (!(cscf = ngx_pcalloc(cf->pool, sizeof(ngx_http_core_srv_conf_t)))) { |
1426 ngx_pcalloc(cf->pool, sizeof(ngx_http_core_srv_conf_t)), | 1458 return NGX_CONF_ERROR; |
1427 NGX_CONF_ERROR); | 1459 } |
1460 | |
1428 /* | 1461 /* |
1462 * set by ngx_pcalloc(): | |
1429 * | 1463 * |
1430 * set by ngx_pcalloc(): | |
1431 * conf->client_large_buffers.num = 0; | 1464 * conf->client_large_buffers.num = 0; |
1432 */ | 1465 */ |
1433 | 1466 |
1434 ngx_init_array(cscf->locations, cf->pool, | 1467 if (ngx_array_init(&cscf->locations, cf->pool, 5, sizeof(void *)) |
1435 5, sizeof(void *), NGX_CONF_ERROR); | 1468 == NGX_ERROR) |
1436 ngx_init_array(cscf->listen, cf->pool, 5, sizeof(ngx_http_listen_t), | 1469 { |
1437 NGX_CONF_ERROR); | 1470 return NGX_CONF_ERROR; |
1438 ngx_init_array(cscf->server_names, cf->pool, | 1471 } |
1439 5, sizeof(ngx_http_server_name_t), NGX_CONF_ERROR); | 1472 |
1473 if (ngx_array_init(&cscf->listen, cf->pool, 5, sizeof(ngx_http_listen_t)) | |
1474 == NGX_ERROR) | |
1475 { | |
1476 return NGX_CONF_ERROR; | |
1477 } | |
1478 | |
1479 if (ngx_array_init(&cscf->server_names, cf->pool, 5, | |
1480 sizeof(ngx_http_server_name_t)) == NGX_ERROR) | |
1481 { | |
1482 return NGX_CONF_ERROR; | |
1483 } | |
1440 | 1484 |
1441 cscf->connection_pool_size = NGX_CONF_UNSET_SIZE; | 1485 cscf->connection_pool_size = NGX_CONF_UNSET_SIZE; |
1442 cscf->post_accept_timeout = NGX_CONF_UNSET_MSEC; | 1486 cscf->post_accept_timeout = NGX_CONF_UNSET_MSEC; |
1443 cscf->request_pool_size = NGX_CONF_UNSET_SIZE; | 1487 cscf->request_pool_size = NGX_CONF_UNSET_SIZE; |
1444 cscf->client_header_timeout = NGX_CONF_UNSET_MSEC; | 1488 cscf->client_header_timeout = NGX_CONF_UNSET_MSEC; |
1447 | 1491 |
1448 return cscf; | 1492 return cscf; |
1449 } | 1493 } |
1450 | 1494 |
1451 | 1495 |
1452 static char *ngx_http_core_merge_srv_conf(ngx_conf_t *cf, | 1496 static char * |
1453 void *parent, void *child) | 1497 ngx_http_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) |
1454 { | 1498 { |
1455 ngx_http_core_srv_conf_t *prev = parent; | 1499 ngx_http_core_srv_conf_t *prev = parent; |
1456 ngx_http_core_srv_conf_t *conf = child; | 1500 ngx_http_core_srv_conf_t *conf = child; |
1457 | 1501 |
1458 ngx_http_listen_t *l; | 1502 ngx_http_listen_t *ls; |
1459 ngx_http_server_name_t *n; | 1503 ngx_http_server_name_t *sn; |
1460 ngx_http_core_main_conf_t *cmcf; | 1504 ngx_http_core_main_conf_t *cmcf; |
1461 | 1505 |
1462 /* TODO: it does not merge, it inits only */ | 1506 /* TODO: it does not merge, it inits only */ |
1463 | 1507 |
1464 if (conf->listen.nelts == 0) { | 1508 if (conf->listen.nelts == 0) { |
1465 ngx_test_null(l, ngx_push_array(&conf->listen), NGX_CONF_ERROR); | 1509 if (!(ls = ngx_array_push(&conf->listen))) { |
1466 l->addr = INADDR_ANY; | 1510 return NGX_CONF_ERROR; |
1511 } | |
1512 | |
1513 ls->addr = INADDR_ANY; | |
1467 #if (NGX_WIN32) | 1514 #if (NGX_WIN32) |
1468 l->port = 80; | 1515 ls->port = 80; |
1469 #else | 1516 #else |
1470 /* STUB: getuid() should be cached */ | 1517 /* STUB: getuid() should be cached */ |
1471 l->port = (getuid() == 0) ? 80 : 8000; | 1518 ls->port = (getuid() == 0) ? 80 : 8000; |
1472 #endif | 1519 #endif |
1473 l->family = AF_INET; | 1520 ls->family = AF_INET; |
1474 } | 1521 } |
1475 | 1522 |
1476 if (conf->server_names.nelts == 0) { | 1523 if (conf->server_names.nelts == 0) { |
1477 ngx_test_null(n, ngx_push_array(&conf->server_names), NGX_CONF_ERROR); | 1524 if (!(sn = ngx_array_push(&conf->server_names))) { |
1478 ngx_test_null(n->name.data, ngx_palloc(cf->pool, NGX_MAXHOSTNAMELEN), | 1525 return NGX_CONF_ERROR; |
1479 NGX_CONF_ERROR); | 1526 } |
1480 | 1527 |
1481 if (gethostname((char *) n->name.data, NGX_MAXHOSTNAMELEN) == -1) { | 1528 if (!(sn->name.data = ngx_palloc(cf->pool, NGX_MAXHOSTNAMELEN))) { |
1529 return NGX_CONF_ERROR; | |
1530 } | |
1531 | |
1532 if (gethostname((char *) sn->name.data, NGX_MAXHOSTNAMELEN) == -1) { | |
1482 ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno, | 1533 ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno, |
1483 "gethostname() failed"); | 1534 "gethostname() failed"); |
1484 return NGX_CONF_ERROR; | 1535 return NGX_CONF_ERROR; |
1485 } | 1536 } |
1486 | 1537 |
1487 n->name.len = ngx_strlen(n->name.data); | 1538 sn->name.len = ngx_strlen(sn->name.data); |
1488 n->core_srv_conf = conf; | 1539 sn->core_srv_conf = conf; |
1489 n->wildcard = 0; | 1540 sn->wildcard = 0; |
1490 | 1541 |
1491 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); | 1542 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); |
1492 | 1543 |
1493 if (cmcf->max_server_name_len < n->name.len) { | 1544 if (cmcf->max_server_name_len < sn->name.len) { |
1494 cmcf->max_server_name_len = n->name.len; | 1545 cmcf->max_server_name_len = sn->name.len; |
1495 } | 1546 } |
1496 } | 1547 } |
1497 | 1548 |
1498 ngx_conf_merge_size_value(conf->connection_pool_size, | 1549 ngx_conf_merge_size_value(conf->connection_pool_size, |
1499 prev->connection_pool_size, 256); | 1550 prev->connection_pool_size, 256); |
1515 "equal to or bigger than \"connection_pool_size\""); | 1566 "equal to or bigger than \"connection_pool_size\""); |
1516 return NGX_CONF_ERROR; | 1567 return NGX_CONF_ERROR; |
1517 } | 1568 } |
1518 | 1569 |
1519 ngx_conf_merge_unsigned_value(conf->restrict_host_names, | 1570 ngx_conf_merge_unsigned_value(conf->restrict_host_names, |
1520 prev->restrict_host_names, 0); | 1571 prev->restrict_host_names, 0); |
1521 | 1572 |
1522 return NGX_CONF_OK; | 1573 return NGX_CONF_OK; |
1523 } | 1574 } |
1524 | 1575 |
1525 | 1576 |
1526 static void *ngx_http_core_create_loc_conf(ngx_conf_t *cf) | 1577 static void * |
1578 ngx_http_core_create_loc_conf(ngx_conf_t *cf) | |
1527 { | 1579 { |
1528 ngx_http_core_loc_conf_t *lcf; | 1580 ngx_http_core_loc_conf_t *lcf; |
1529 | 1581 |
1530 ngx_test_null(lcf, | 1582 if (!(lcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_core_loc_conf_t)))) { |
1531 ngx_pcalloc(cf->pool, sizeof(ngx_http_core_loc_conf_t)), | 1583 return NGX_CONF_ERROR; |
1532 NGX_CONF_ERROR); | 1584 } |
1533 | 1585 |
1534 /* | 1586 /* |
1535 * set by ngx_pcalloc(): | 1587 * set by ngx_pcalloc(): |
1536 * | 1588 * |
1537 * lcf->root.len = 0; | 1589 * lcf->root.len = 0; |
1567 | 1619 |
1568 return lcf; | 1620 return lcf; |
1569 } | 1621 } |
1570 | 1622 |
1571 | 1623 |
1572 static ngx_http_type_t default_types[] = { | 1624 static ngx_http_type_t ngx_http_core_default_types[] = { |
1573 { ngx_string("html"), ngx_string("text/html") }, | 1625 { ngx_string("html"), ngx_string("text/html") }, |
1574 { ngx_string("gif"), ngx_string("image/gif") }, | 1626 { ngx_string("gif"), ngx_string("image/gif") }, |
1575 { ngx_string("jpg"), ngx_string("image/jpeg") }, | 1627 { ngx_string("jpg"), ngx_string("image/jpeg") }, |
1576 { ngx_null_string, ngx_null_string } | 1628 { ngx_null_string, ngx_null_string } |
1577 }; | 1629 }; |
1578 | 1630 |
1579 | 1631 |
1580 static char *ngx_http_core_merge_loc_conf(ngx_conf_t *cf, | 1632 static char * |
1633 ngx_http_core_merge_loc_conf(ngx_conf_t *cf, | |
1581 void *parent, void *child) | 1634 void *parent, void *child) |
1582 { | 1635 { |
1583 ngx_http_core_loc_conf_t *prev = parent; | 1636 ngx_http_core_loc_conf_t *prev = parent; |
1584 ngx_http_core_loc_conf_t *conf = child; | 1637 ngx_http_core_loc_conf_t *conf = child; |
1585 | 1638 |
1586 int i, key; | 1639 uint32_t key; |
1587 ngx_http_type_t *t; | 1640 ngx_uint_t i; |
1641 ngx_http_type_t *type; | |
1588 | 1642 |
1589 ngx_conf_merge_str_value(conf->root, prev->root, "html"); | 1643 ngx_conf_merge_str_value(conf->root, prev->root, "html"); |
1590 | 1644 |
1591 if (ngx_conf_full_name(cf->cycle, &conf->root) == NGX_ERROR) { | 1645 if (ngx_conf_full_name(cf->cycle, &conf->root) == NGX_ERROR) { |
1592 return NGX_CONF_ERROR; | 1646 return NGX_CONF_ERROR; |
1595 if (conf->types == NULL) { | 1649 if (conf->types == NULL) { |
1596 if (prev->types) { | 1650 if (prev->types) { |
1597 conf->types = prev->types; | 1651 conf->types = prev->types; |
1598 | 1652 |
1599 } else { | 1653 } else { |
1600 ngx_test_null(conf->types, | 1654 conf->types = ngx_palloc(cf->pool, NGX_HTTP_TYPES_HASH_PRIME |
1601 ngx_palloc(cf->pool, NGX_HTTP_TYPES_HASH_PRIME | 1655 * sizeof(ngx_array_t)); |
1602 * sizeof(ngx_array_t)), | 1656 if (conf->types == NULL) { |
1603 NGX_CONF_ERROR); | 1657 return NGX_CONF_ERROR; |
1658 } | |
1604 | 1659 |
1605 for (i = 0; i < NGX_HTTP_TYPES_HASH_PRIME; i++) { | 1660 for (i = 0; i < NGX_HTTP_TYPES_HASH_PRIME; i++) { |
1606 ngx_init_array(conf->types[i], cf->pool, | 1661 if (ngx_array_init(&conf->types[i], cf->pool, 5, |
1607 5, sizeof(ngx_http_type_t), NGX_CONF_ERROR); | 1662 sizeof(ngx_http_type_t)) == NGX_ERROR) |
1608 } | 1663 { |
1609 | 1664 return NGX_CONF_ERROR; |
1610 for (i = 0; default_types[i].exten.len; i++) { | 1665 } |
1611 ngx_http_types_hash_key(key, default_types[i].exten); | 1666 } |
1612 | 1667 |
1613 ngx_test_null(t, ngx_push_array(&conf->types[key]), | 1668 for (i = 0; ngx_http_core_default_types[i].exten.len; i++) { |
1614 NGX_CONF_ERROR); | 1669 ngx_http_types_hash_key(key, |
1615 t->exten.len = default_types[i].exten.len; | 1670 ngx_http_core_default_types[i].exten); |
1616 t->exten.data = default_types[i].exten.data; | 1671 |
1617 t->type.len = default_types[i].type.len; | 1672 if (!(type = ngx_array_push(&conf->types[key]))) { |
1618 t->type.data = default_types[i].type.data; | 1673 return NGX_CONF_ERROR; |
1674 } | |
1675 | |
1676 *type = ngx_http_core_default_types[i]; | |
1619 } | 1677 } |
1620 } | 1678 } |
1621 } | 1679 } |
1622 | 1680 |
1623 if (conf->err_log == NULL) { | 1681 if (conf->err_log == NULL) { |
1631 if (conf->error_pages == NULL && prev->error_pages) { | 1689 if (conf->error_pages == NULL && prev->error_pages) { |
1632 conf->error_pages = prev->error_pages; | 1690 conf->error_pages = prev->error_pages; |
1633 } | 1691 } |
1634 | 1692 |
1635 ngx_conf_merge_str_value(conf->default_type, | 1693 ngx_conf_merge_str_value(conf->default_type, |
1636 prev->default_type, "text/plain"); | 1694 prev->default_type, "text/plain"); |
1637 | 1695 |
1638 ngx_conf_merge_size_value(conf->client_max_body_size, | 1696 ngx_conf_merge_size_value(conf->client_max_body_size, |
1639 prev->client_max_body_size, 1 * 1024 * 1024); | 1697 prev->client_max_body_size, 1 * 1024 * 1024); |
1640 ngx_conf_merge_size_value(conf->client_body_buffer_size, | 1698 ngx_conf_merge_size_value(conf->client_body_buffer_size, |
1641 prev->client_body_buffer_size, | 1699 prev->client_body_buffer_size, |
1663 prev->client_body_temp_path, | 1721 prev->client_body_temp_path, |
1664 NGX_HTTP_CLIENT_TEMP_PATH, 0, 0, 0, | 1722 NGX_HTTP_CLIENT_TEMP_PATH, 0, 0, 0, |
1665 ngx_garbage_collector_temp_handler, cf); | 1723 ngx_garbage_collector_temp_handler, cf); |
1666 | 1724 |
1667 ngx_conf_merge_value(conf->reset_timedout_connection, | 1725 ngx_conf_merge_value(conf->reset_timedout_connection, |
1668 prev->reset_timedout_connection, 0); | 1726 prev->reset_timedout_connection, 0); |
1669 ngx_conf_merge_value(conf->msie_padding, prev->msie_padding, 1); | 1727 ngx_conf_merge_value(conf->msie_padding, prev->msie_padding, 1); |
1670 | 1728 |
1671 if (conf->open_files == NULL) { | 1729 if (conf->open_files == NULL) { |
1672 conf->open_files = prev->open_files; | 1730 conf->open_files = prev->open_files; |
1673 } | 1731 } |
1674 | 1732 |
1675 return NGX_CONF_OK; | 1733 return NGX_CONF_OK; |
1676 } | 1734 } |
1677 | 1735 |
1678 | 1736 |
1679 static char *ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, | 1737 static char * |
1680 void *conf) | 1738 ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
1681 { | 1739 { |
1682 ngx_http_core_srv_conf_t *scf = conf; | 1740 ngx_http_core_srv_conf_t *scf = conf; |
1683 | 1741 |
1684 u_char *addr; | 1742 u_char *addr; |
1685 ngx_int_t port; | 1743 ngx_int_t port; |
1744 } else { | 1802 } else { |
1745 ls->port = (in_port_t) port; | 1803 ls->port = (in_port_t) port; |
1746 } | 1804 } |
1747 | 1805 |
1748 ls->addr = inet_addr((const char *) addr); | 1806 ls->addr = inet_addr((const char *) addr); |
1807 | |
1749 if (ls->addr == INADDR_NONE) { | 1808 if (ls->addr == INADDR_NONE) { |
1750 h = gethostbyname((const char *) addr); | 1809 h = gethostbyname((const char *) addr); |
1751 | 1810 |
1752 if (h == NULL || h->h_addr_list[0] == NULL) { | 1811 if (h == NULL || h->h_addr_list[0] == NULL) { |
1753 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 1812 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
1761 | 1820 |
1762 return NGX_CONF_OK; | 1821 return NGX_CONF_OK; |
1763 } | 1822 } |
1764 | 1823 |
1765 | 1824 |
1766 static char *ngx_http_core_server_name(ngx_conf_t *cf, ngx_command_t *cmd, | 1825 static char * |
1767 void *conf) | 1826 ngx_http_core_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
1768 { | 1827 { |
1769 ngx_http_core_srv_conf_t *scf = conf; | 1828 ngx_http_core_srv_conf_t *scf = conf; |
1770 | 1829 |
1771 ngx_uint_t i; | 1830 ngx_uint_t i; |
1772 ngx_str_t *value; | 1831 ngx_str_t *value; |
1812 | 1871 |
1813 return NGX_CONF_OK; | 1872 return NGX_CONF_OK; |
1814 } | 1873 } |
1815 | 1874 |
1816 | 1875 |
1817 static char *ngx_http_core_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | 1876 static char * |
1877 ngx_http_core_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
1818 { | 1878 { |
1819 ngx_http_core_loc_conf_t *lcf = conf; | 1879 ngx_http_core_loc_conf_t *lcf = conf; |
1820 | 1880 |
1821 ngx_uint_t alias; | 1881 ngx_uint_t alias; |
1822 ngx_str_t *value; | 1882 ngx_str_t *value; |
1852 | 1912 |
1853 return NGX_CONF_OK; | 1913 return NGX_CONF_OK; |
1854 } | 1914 } |
1855 | 1915 |
1856 | 1916 |
1857 static char *ngx_http_core_error_page(ngx_conf_t *cf, ngx_command_t *cmd, | 1917 static char * |
1858 void *conf) | 1918 ngx_http_core_error_page(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
1859 { | 1919 { |
1860 ngx_http_core_loc_conf_t *lcf = conf; | 1920 ngx_http_core_loc_conf_t *lcf = conf; |
1861 | 1921 |
1862 int overwrite; | 1922 ngx_int_t overwrite; |
1863 ngx_uint_t i, n; | 1923 ngx_uint_t i, n; |
1864 ngx_str_t *value; | 1924 ngx_str_t *value; |
1865 ngx_http_err_page_t *err; | 1925 ngx_http_err_page_t *err; |
1866 | 1926 |
1867 if (lcf->error_pages == NULL) { | 1927 if (lcf->error_pages == NULL) { |
1868 lcf->error_pages = ngx_create_array(cf->pool, 5, | 1928 lcf->error_pages = ngx_array_create(cf->pool, 4, |
1869 sizeof(ngx_http_err_page_t)); | 1929 sizeof(ngx_http_err_page_t)); |
1870 if (lcf->error_pages == NULL) { | 1930 if (lcf->error_pages == NULL) { |
1871 return NGX_CONF_ERROR; | 1931 return NGX_CONF_ERROR; |
1872 } | 1932 } |
1873 } | 1933 } |
1897 overwrite = 0; | 1957 overwrite = 0; |
1898 n = 1; | 1958 n = 1; |
1899 } | 1959 } |
1900 | 1960 |
1901 for (i = 1; i < cf->args->nelts - n; i++) { | 1961 for (i = 1; i < cf->args->nelts - n; i++) { |
1902 if (!(err = ngx_push_array(lcf->error_pages))) { | 1962 if (!(err = ngx_array_push(lcf->error_pages))) { |
1903 return NGX_CONF_ERROR; | 1963 return NGX_CONF_ERROR; |
1904 } | 1964 } |
1905 | 1965 |
1906 err->status = ngx_atoi(value[i].data, value[i].len); | 1966 err->status = ngx_atoi(value[i].data, value[i].len); |
1967 | |
1907 if (err->status == NGX_ERROR) { | 1968 if (err->status == NGX_ERROR) { |
1908 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 1969 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
1909 "invalid value \"%V\"", &value[i]); | 1970 "invalid value \"%V\"", &value[i]); |
1910 return NGX_CONF_ERROR; | 1971 return NGX_CONF_ERROR; |
1911 } | 1972 } |
1923 | 1984 |
1924 return NGX_CONF_OK; | 1985 return NGX_CONF_OK; |
1925 } | 1986 } |
1926 | 1987 |
1927 | 1988 |
1928 static char *ngx_http_core_keepalive(ngx_conf_t *cf, ngx_command_t *cmd, | 1989 static char * |
1929 void *conf) | 1990 ngx_http_core_keepalive(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
1930 { | 1991 { |
1931 ngx_http_core_loc_conf_t *lcf = conf; | 1992 ngx_http_core_loc_conf_t *lcf = conf; |
1932 | 1993 |
1933 ngx_str_t *value; | 1994 ngx_str_t *value; |
1934 | 1995 |
1937 } | 1998 } |
1938 | 1999 |
1939 value = cf->args->elts; | 2000 value = cf->args->elts; |
1940 | 2001 |
1941 lcf->keepalive_timeout = ngx_parse_time(&value[1], 0); | 2002 lcf->keepalive_timeout = ngx_parse_time(&value[1], 0); |
2003 | |
1942 if (lcf->keepalive_timeout == (ngx_msec_t) NGX_ERROR) { | 2004 if (lcf->keepalive_timeout == (ngx_msec_t) NGX_ERROR) { |
1943 return "invalid value"; | 2005 return "invalid value"; |
1944 } | 2006 } |
1945 | 2007 |
1946 if (lcf->keepalive_timeout == (ngx_msec_t) NGX_PARSE_LARGE_TIME) { | 2008 if (lcf->keepalive_timeout == (ngx_msec_t) NGX_PARSE_LARGE_TIME) { |
1950 if (cf->args->nelts == 2) { | 2012 if (cf->args->nelts == 2) { |
1951 return NGX_CONF_OK; | 2013 return NGX_CONF_OK; |
1952 } | 2014 } |
1953 | 2015 |
1954 lcf->keepalive_header = ngx_parse_time(&value[2], 1); | 2016 lcf->keepalive_header = ngx_parse_time(&value[2], 1); |
2017 | |
1955 if (lcf->keepalive_header == NGX_ERROR) { | 2018 if (lcf->keepalive_header == NGX_ERROR) { |
1956 return "invalid value"; | 2019 return "invalid value"; |
1957 } | 2020 } |
1958 | 2021 |
1959 if (lcf->keepalive_header == NGX_PARSE_LARGE_TIME) { | 2022 if (lcf->keepalive_header == NGX_PARSE_LARGE_TIME) { |
1962 | 2025 |
1963 return NGX_CONF_OK; | 2026 return NGX_CONF_OK; |
1964 } | 2027 } |
1965 | 2028 |
1966 | 2029 |
1967 static char *ngx_http_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd, | 2030 static char * |
1968 void *conf) | 2031 ngx_http_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
1969 { | 2032 { |
1970 ngx_http_core_loc_conf_t *lcf = conf; | 2033 ngx_http_core_loc_conf_t *lcf = conf; |
1971 | 2034 |
1972 if (!(lcf->err_log = ngx_log_create_errlog(cf->cycle, cf->args))) { | 2035 if (!(lcf->err_log = ngx_log_create_errlog(cf->cycle, cf->args))) { |
1973 return NGX_CONF_ERROR; | 2036 return NGX_CONF_ERROR; |
1975 | 2038 |
1976 return ngx_set_error_log_levels(cf, lcf->err_log); | 2039 return ngx_set_error_log_levels(cf, lcf->err_log); |
1977 } | 2040 } |
1978 | 2041 |
1979 | 2042 |
1980 static char *ngx_http_core_lowat_check(ngx_conf_t *cf, void *post, void *data) | 2043 static char * |
2044 ngx_http_core_lowat_check(ngx_conf_t *cf, void *post, void *data) | |
1981 { | 2045 { |
1982 #if (NGX_FREEBSD) | 2046 #if (NGX_FREEBSD) |
1983 ssize_t *np = data; | 2047 ssize_t *np = data; |
1984 | 2048 |
1985 if (*np >= ngx_freebsd_net_inet_tcp_sendspace) { | 2049 if (*np >= ngx_freebsd_net_inet_tcp_sendspace) { |