return NULL instead of NGX_CONF_ERROR on a create conf failure
Igor Sysoev
13 years ago
215 | 215 | |
216 | 216 | if (module->create_conf) { |
217 | 217 | rv = module->create_conf(cycle); |
218 | if (rv == NGX_CONF_ERROR) { | |
218 | if (rv == NULL) { | |
219 | 219 | ngx_destroy_pool(pool); |
220 | 220 | return NULL; |
221 | 221 | } |
549 | 549 | |
550 | 550 | dpcf = ngx_palloc(cycle->pool, sizeof(ngx_devpoll_conf_t)); |
551 | 551 | if (dpcf == NULL) { |
552 | return NGX_CONF_ERROR; | |
552 | return NULL; | |
553 | 553 | } |
554 | 554 | |
555 | 555 | dpcf->changes = NGX_CONF_UNSET; |
551 | 551 | |
552 | 552 | epcf = ngx_palloc(cycle->pool, sizeof(ngx_epoll_conf_t)); |
553 | 553 | if (epcf == NULL) { |
554 | return NGX_CONF_ERROR; | |
554 | return NULL; | |
555 | 555 | } |
556 | 556 | |
557 | 557 | epcf->events = NGX_CONF_UNSET; |
580 | 580 | |
581 | 581 | epcf = ngx_palloc(cycle->pool, sizeof(ngx_eventport_conf_t)); |
582 | 582 | if (epcf == NULL) { |
583 | return NGX_CONF_ERROR; | |
583 | return NULL; | |
584 | 584 | } |
585 | 585 | |
586 | 586 | epcf->events = NGX_CONF_UNSET; |
767 | 767 | |
768 | 768 | kcf = ngx_palloc(cycle->pool, sizeof(ngx_kqueue_conf_t)); |
769 | 769 | if (kcf == NULL) { |
770 | return NGX_CONF_ERROR; | |
770 | return NULL; | |
771 | 771 | } |
772 | 772 | |
773 | 773 | kcf->changes = NGX_CONF_UNSET; |
690 | 690 | |
691 | 691 | rtscf = ngx_palloc(cycle->pool, sizeof(ngx_rtsig_conf_t)); |
692 | 692 | if (rtscf == NULL) { |
693 | return NGX_CONF_ERROR; | |
693 | return NULL; | |
694 | 694 | } |
695 | 695 | |
696 | 696 | rtscf->signo = NGX_CONF_UNSET; |
1112 | 1112 | |
1113 | 1113 | ecf = ngx_palloc(cycle->pool, sizeof(ngx_event_conf_t)); |
1114 | 1114 | if (ecf == NULL) { |
1115 | return NGX_CONF_ERROR; | |
1115 | return NULL; | |
1116 | 1116 | } |
1117 | 1117 | |
1118 | 1118 | ecf->connections = NGX_CONF_UNSET_UINT; |
1127 | 1127 | if (ngx_array_init(&ecf->debug_connection, cycle->pool, 4, |
1128 | 1128 | sizeof(ngx_event_debug_t)) == NGX_ERROR) |
1129 | 1129 | { |
1130 | return NGX_CONF_ERROR; | |
1130 | return NULL; | |
1131 | 1131 | } |
1132 | 1132 | |
1133 | 1133 | #endif |
2114 | 2114 | |
2115 | 2115 | oscf = ngx_pcalloc(cycle->pool, sizeof(ngx_openssl_conf_t)); |
2116 | 2116 | if (oscf == NULL) { |
2117 | return NGX_CONF_ERROR; | |
2117 | return NULL; | |
2118 | 2118 | } |
2119 | 2119 | |
2120 | 2120 | /* |
200 | 200 | |
201 | 201 | conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_access_loc_conf_t)); |
202 | 202 | if (conf == NULL) { |
203 | return NGX_CONF_ERROR; | |
203 | return NULL; | |
204 | 204 | } |
205 | 205 | |
206 | 206 | return conf; |
211 | 211 | |
212 | 212 | conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_addition_conf_t)); |
213 | 213 | if (conf == NULL) { |
214 | return NGX_CONF_ERROR; | |
214 | return NULL; | |
215 | 215 | } |
216 | 216 | |
217 | 217 | /* |
371 | 371 | |
372 | 372 | conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_auth_basic_loc_conf_t)); |
373 | 373 | if (conf == NULL) { |
374 | return NGX_CONF_ERROR; | |
374 | return NULL; | |
375 | 375 | } |
376 | 376 | |
377 | 377 | return conf; |
631 | 631 | |
632 | 632 | conf = ngx_palloc(cf->pool, sizeof(ngx_http_autoindex_loc_conf_t)); |
633 | 633 | if (conf == NULL) { |
634 | return NGX_CONF_ERROR; | |
634 | return NULL; | |
635 | 635 | } |
636 | 636 | |
637 | 637 | conf->enable = NGX_CONF_UNSET; |
422 | 422 | |
423 | 423 | conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_browser_conf_t)); |
424 | 424 | if (conf == NULL) { |
425 | return NGX_CONF_ERROR; | |
425 | return NULL; | |
426 | 426 | } |
427 | 427 | |
428 | 428 | /* |
1487 | 1487 | |
1488 | 1488 | mcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_charset_main_conf_t)); |
1489 | 1489 | if (mcf == NULL) { |
1490 | return NGX_CONF_ERROR; | |
1490 | return NULL; | |
1491 | 1491 | } |
1492 | 1492 | |
1493 | 1493 | if (ngx_array_init(&mcf->charsets, cf->pool, 2, sizeof(ngx_http_charset_t)) |
1494 | 1494 | != NGX_OK) |
1495 | 1495 | { |
1496 | return NGX_CONF_ERROR; | |
1496 | return NULL; | |
1497 | 1497 | } |
1498 | 1498 | |
1499 | 1499 | if (ngx_array_init(&mcf->tables, cf->pool, 1, |
1500 | 1500 | sizeof(ngx_http_charset_tables_t)) |
1501 | 1501 | != NGX_OK) |
1502 | 1502 | { |
1503 | return NGX_CONF_ERROR; | |
1503 | return NULL; | |
1504 | 1504 | } |
1505 | 1505 | |
1506 | 1506 | if (ngx_array_init(&mcf->recodes, cf->pool, 2, |
1507 | 1507 | sizeof(ngx_http_charset_recode_t)) |
1508 | 1508 | != NGX_OK) |
1509 | 1509 | { |
1510 | return NGX_CONF_ERROR; | |
1510 | return NULL; | |
1511 | 1511 | } |
1512 | 1512 | |
1513 | 1513 | return mcf; |
1521 | 1521 | |
1522 | 1522 | lcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_charset_loc_conf_t)); |
1523 | 1523 | if (lcf == NULL) { |
1524 | return NGX_CONF_ERROR; | |
1524 | return NULL; | |
1525 | 1525 | } |
1526 | 1526 | |
1527 | 1527 | /* |
1153 | 1153 | |
1154 | 1154 | conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_dav_loc_conf_t)); |
1155 | 1155 | if (conf == NULL) { |
1156 | return NGX_CONF_ERROR; | |
1156 | return NULL; | |
1157 | 1157 | } |
1158 | 1158 | |
1159 | 1159 | /* |
1832 | 1832 | |
1833 | 1833 | conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_fastcgi_loc_conf_t)); |
1834 | 1834 | if (conf == NULL) { |
1835 | return NGX_CONF_ERROR; | |
1835 | return NULL; | |
1836 | 1836 | } |
1837 | 1837 | |
1838 | 1838 | /* |
1068 | 1068 | |
1069 | 1069 | conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_gzip_conf_t)); |
1070 | 1070 | if (conf == NULL) { |
1071 | return NGX_CONF_ERROR; | |
1071 | return NULL; | |
1072 | 1072 | } |
1073 | 1073 | |
1074 | 1074 | /* |
250 | 250 | |
251 | 251 | conf = ngx_palloc(cf->pool, sizeof(ngx_http_gzip_static_conf_t)); |
252 | 252 | if (conf == NULL) { |
253 | return NGX_CONF_ERROR; | |
253 | return NULL; | |
254 | 254 | } |
255 | 255 | |
256 | 256 | conf->enable = NGX_CONF_UNSET; |
420 | 420 | |
421 | 421 | conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_headers_conf_t)); |
422 | 422 | if (conf == NULL) { |
423 | return NGX_CONF_ERROR; | |
423 | return NULL; | |
424 | 424 | } |
425 | 425 | |
426 | 426 | /* |
946 | 946 | |
947 | 947 | conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_image_filter_conf_t)); |
948 | 948 | if (conf == NULL) { |
949 | return NGX_CONF_ERROR; | |
949 | return NULL; | |
950 | 950 | } |
951 | 951 | |
952 | 952 | conf->filter = NGX_CONF_UNSET_UINT; |
365 | 365 | |
366 | 366 | conf = ngx_palloc(cf->pool, sizeof(ngx_http_index_loc_conf_t)); |
367 | 367 | if (conf == NULL) { |
368 | return NGX_CONF_ERROR; | |
368 | return NULL; | |
369 | 369 | } |
370 | 370 | |
371 | 371 | conf->indices = NULL; |
521 | 521 | |
522 | 522 | conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_limit_req_conf_t)); |
523 | 523 | if (conf == NULL) { |
524 | return NGX_CONF_ERROR; | |
524 | return NULL; | |
525 | 525 | } |
526 | 526 | |
527 | 527 | /* |
380 | 380 | |
381 | 381 | conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_limit_zone_conf_t)); |
382 | 382 | if (conf == NULL) { |
383 | return NGX_CONF_ERROR; | |
383 | return NULL; | |
384 | 384 | } |
385 | 385 | |
386 | 386 | /* |
713 | 713 | |
714 | 714 | conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_main_conf_t)); |
715 | 715 | if (conf == NULL) { |
716 | return NGX_CONF_ERROR; | |
716 | return NULL; | |
717 | 717 | } |
718 | 718 | |
719 | 719 | if (ngx_array_init(&conf->formats, cf->pool, 4, sizeof(ngx_http_log_fmt_t)) |
720 | 720 | != NGX_OK) |
721 | 721 | { |
722 | return NGX_CONF_ERROR; | |
722 | return NULL; | |
723 | 723 | } |
724 | 724 | |
725 | 725 | fmt = ngx_array_push(&conf->formats); |
726 | 726 | if (fmt == NULL) { |
727 | return NGX_CONF_ERROR; | |
727 | return NULL; | |
728 | 728 | } |
729 | 729 | |
730 | 730 | fmt->name.len = sizeof("combined") - 1; |
734 | 734 | |
735 | 735 | fmt->ops = ngx_array_create(cf->pool, 16, sizeof(ngx_http_log_op_t)); |
736 | 736 | if (fmt->ops == NULL) { |
737 | return NGX_CONF_ERROR; | |
737 | return NULL; | |
738 | 738 | } |
739 | 739 | |
740 | 740 | return conf; |
748 | 748 | |
749 | 749 | conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_loc_conf_t)); |
750 | 750 | if (conf == NULL) { |
751 | return NGX_CONF_ERROR; | |
751 | return NULL; | |
752 | 752 | } |
753 | 753 | |
754 | 754 | conf->open_file_cache = NGX_CONF_UNSET_PTR; |
159 | 159 | |
160 | 160 | mcf = ngx_palloc(cf->pool, sizeof(ngx_http_map_conf_t)); |
161 | 161 | if (mcf == NULL) { |
162 | return NGX_CONF_ERROR; | |
162 | return NULL; | |
163 | 163 | } |
164 | 164 | |
165 | 165 | mcf->hash_max_size = NGX_CONF_UNSET_UINT; |
512 | 512 | |
513 | 513 | conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_memcached_loc_conf_t)); |
514 | 514 | if (conf == NULL) { |
515 | return NGX_CONF_ERROR; | |
515 | return NULL; | |
516 | 516 | } |
517 | 517 | |
518 | 518 | /* |
1882 | 1882 | |
1883 | 1883 | conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_proxy_loc_conf_t)); |
1884 | 1884 | if (conf == NULL) { |
1885 | return NGX_CONF_ERROR; | |
1885 | return NULL; | |
1886 | 1886 | } |
1887 | 1887 | |
1888 | 1888 | /* |
279 | 279 | |
280 | 280 | conf = ngx_palloc(cf->pool, sizeof(ngx_http_random_index_loc_conf_t)); |
281 | 281 | if (conf == NULL) { |
282 | return NGX_CONF_ERROR; | |
282 | return NULL; | |
283 | 283 | } |
284 | 284 | |
285 | 285 | conf->enable = NGX_CONF_UNSET; |
359 | 359 | |
360 | 360 | conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_realip_loc_conf_t)); |
361 | 361 | if (conf == NULL) { |
362 | return NGX_CONF_ERROR; | |
362 | return NULL; | |
363 | 363 | } |
364 | 364 | |
365 | 365 | /* |
220 | 220 | |
221 | 221 | conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_referer_conf_t)); |
222 | 222 | if (conf == NULL) { |
223 | return NGX_CONF_ERROR; | |
223 | return NULL; | |
224 | 224 | } |
225 | 225 | |
226 | 226 | #if (NGX_PCRE) |
219 | 219 | |
220 | 220 | conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_rewrite_loc_conf_t)); |
221 | 221 | if (conf == NULL) { |
222 | return NGX_CONF_ERROR; | |
222 | return NULL; | |
223 | 223 | } |
224 | 224 | |
225 | 225 | conf->stack_size = NGX_CONF_UNSET_UINT; |
151 | 151 | |
152 | 152 | conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_secure_link_conf_t)); |
153 | 153 | if (conf == NULL) { |
154 | return NGX_CONF_ERROR; | |
154 | return NULL; | |
155 | 155 | } |
156 | 156 | |
157 | 157 | /* |
2688 | 2688 | |
2689 | 2689 | smcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_ssi_main_conf_t)); |
2690 | 2690 | if (smcf == NULL) { |
2691 | return NGX_CONF_ERROR; | |
2691 | return NULL; | |
2692 | 2692 | } |
2693 | 2693 | |
2694 | 2694 | smcf->commands.pool = cf->pool; |
2695 | 2695 | smcf->commands.temp_pool = cf->temp_pool; |
2696 | 2696 | |
2697 | 2697 | if (ngx_hash_keys_array_init(&smcf->commands, NGX_HASH_SMALL) != NGX_OK) { |
2698 | return NGX_CONF_ERROR; | |
2698 | return NULL; | |
2699 | 2699 | } |
2700 | 2700 | |
2701 | 2701 | return smcf; |
2735 | 2735 | |
2736 | 2736 | slcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_ssi_loc_conf_t)); |
2737 | 2737 | if (slcf == NULL) { |
2738 | return NGX_CONF_ERROR; | |
2738 | return NULL; | |
2739 | 2739 | } |
2740 | 2740 | |
2741 | 2741 | /* |
301 | 301 | |
302 | 302 | sscf = ngx_pcalloc(cf->pool, sizeof(ngx_http_ssl_srv_conf_t)); |
303 | 303 | if (sscf == NULL) { |
304 | return NGX_CONF_ERROR; | |
304 | return NULL; | |
305 | 305 | } |
306 | 306 | |
307 | 307 | /* |
637 | 637 | |
638 | 638 | slcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_sub_loc_conf_t)); |
639 | 639 | if (slcf == NULL) { |
640 | return NGX_CONF_ERROR; | |
640 | return NULL; | |
641 | 641 | } |
642 | 642 | |
643 | 643 | /* |
569 | 569 | |
570 | 570 | conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_userid_conf_t)); |
571 | 571 | if (conf == NULL) { |
572 | return NGX_CONF_ERROR; | |
572 | return NULL; | |
573 | 573 | } |
574 | 574 | |
575 | 575 | /* |
1168 | 1168 | |
1169 | 1169 | conf = ngx_palloc(cf->pool, sizeof(ngx_http_xslt_filter_main_conf_t)); |
1170 | 1170 | if (conf == NULL) { |
1171 | return NGX_CONF_ERROR; | |
1171 | return NULL; | |
1172 | 1172 | } |
1173 | 1173 | |
1174 | 1174 | if (ngx_array_init(&conf->dtd_files, cf->pool, 1, |
1196 | 1196 | |
1197 | 1197 | conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_xslt_filter_loc_conf_t)); |
1198 | 1198 | if (conf == NULL) { |
1199 | return NGX_CONF_ERROR; | |
1199 | return NULL; | |
1200 | 1200 | } |
1201 | 1201 | |
1202 | 1202 | /* |
783 | 783 | |
784 | 784 | pmcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_perl_main_conf_t)); |
785 | 785 | if (pmcf == NULL) { |
786 | return NGX_CONF_ERROR; | |
786 | return NULL; | |
787 | 787 | } |
788 | 788 | |
789 | 789 | if (ngx_array_init(&pmcf->requires, cf->pool, 1, sizeof(u_char *)) |
868 | 868 | |
869 | 869 | plcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_perl_loc_conf_t)); |
870 | 870 | if (plcf == NULL) { |
871 | return NGX_CONF_ERROR; | |
871 | return NULL; | |
872 | 872 | } |
873 | 873 | |
874 | 874 | /* |
2702 | 2702 | |
2703 | 2703 | cmcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_core_main_conf_t)); |
2704 | 2704 | if (cmcf == NULL) { |
2705 | return NGX_CONF_ERROR; | |
2705 | return NULL; | |
2706 | 2706 | } |
2707 | 2707 | |
2708 | 2708 | if (ngx_array_init(&cmcf->servers, cf->pool, 4, |
2709 | 2709 | sizeof(ngx_http_core_srv_conf_t *)) |
2710 | 2710 | != NGX_OK) |
2711 | 2711 | { |
2712 | return NGX_CONF_ERROR; | |
2712 | return NULL; | |
2713 | 2713 | } |
2714 | 2714 | |
2715 | 2715 | cmcf->server_names_hash_max_size = NGX_CONF_UNSET_UINT; |
2761 | 2761 | |
2762 | 2762 | cscf = ngx_pcalloc(cf->pool, sizeof(ngx_http_core_srv_conf_t)); |
2763 | 2763 | if (cscf == NULL) { |
2764 | return NGX_CONF_ERROR; | |
2764 | return NULL; | |
2765 | 2765 | } |
2766 | 2766 | |
2767 | 2767 | /* |
2774 | 2774 | sizeof(ngx_http_listen_t)) |
2775 | 2775 | != NGX_OK) |
2776 | 2776 | { |
2777 | return NGX_CONF_ERROR; | |
2777 | return NULL; | |
2778 | 2778 | } |
2779 | 2779 | |
2780 | 2780 | if (ngx_array_init(&cscf->server_names, cf->temp_pool, 4, |
2781 | 2781 | sizeof(ngx_http_server_name_t)) |
2782 | 2782 | != NGX_OK) |
2783 | 2783 | { |
2784 | return NGX_CONF_ERROR; | |
2784 | return NULL; | |
2785 | 2785 | } |
2786 | 2786 | |
2787 | 2787 | cscf->connection_pool_size = NGX_CONF_UNSET_SIZE; |
2892 | 2892 | |
2893 | 2893 | lcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_core_loc_conf_t)); |
2894 | 2894 | if (lcf == NULL) { |
2895 | return NGX_CONF_ERROR; | |
2895 | return NULL; | |
2896 | 2896 | } |
2897 | 2897 | |
2898 | 2898 | /* |
4181 | 4181 | sizeof(ngx_http_upstream_srv_conf_t *)) |
4182 | 4182 | != NGX_OK) |
4183 | 4183 | { |
4184 | return NGX_CONF_ERROR; | |
4184 | return NULL; | |
4185 | 4185 | } |
4186 | 4186 | |
4187 | 4187 | return umcf; |
1301 | 1301 | |
1302 | 1302 | ahcf = ngx_pcalloc(cf->pool, sizeof(ngx_mail_auth_http_conf_t)); |
1303 | 1303 | if (ahcf == NULL) { |
1304 | return NGX_CONF_ERROR; | |
1304 | return NULL; | |
1305 | 1305 | } |
1306 | 1306 | |
1307 | 1307 | ahcf->timeout = NGX_CONF_UNSET_MSEC; |
119 | 119 | |
120 | 120 | cmcf = ngx_pcalloc(cf->pool, sizeof(ngx_mail_core_main_conf_t)); |
121 | 121 | if (cmcf == NULL) { |
122 | return NGX_CONF_ERROR; | |
122 | return NULL; | |
123 | 123 | } |
124 | 124 | |
125 | 125 | if (ngx_array_init(&cmcf->servers, cf->pool, 4, |
126 | 126 | sizeof(ngx_mail_core_srv_conf_t *)) |
127 | 127 | != NGX_OK) |
128 | 128 | { |
129 | return NGX_CONF_ERROR; | |
129 | return NULL; | |
130 | 130 | } |
131 | 131 | |
132 | 132 | if (ngx_array_init(&cmcf->listen, cf->pool, 4, sizeof(ngx_mail_listen_t)) |
133 | 133 | != NGX_OK) |
134 | 134 | { |
135 | return NGX_CONF_ERROR; | |
135 | return NULL; | |
136 | 136 | } |
137 | 137 | |
138 | 138 | return cmcf; |