~ubuntu-branches/ubuntu/jaunty/nginx/jaunty-updates

« back to all changes in this revision

Viewing changes to src/http/ngx_http.c

  • Committer: Bazaar Package Importer
  • Author(s): Jose Parrella
  • Date: 2007-12-08 11:27:54 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20071208112754-23ohg2b1zshkdayw
Tags: 0.5.33-1
* New stable upstream release (Closes: #451173)
* nginx now provides httpd, httpd-cgi virtual packages
  (Closes: #439468, #452025)
* sites-enabled/default link is now provided only on fresh 
  installations (Closes: #432961)
* Updated code for online upgrading of nginx (Closes: #445246)
* Reviewed maintainer scripts for correct behaviour on updates
  (Closes: #452787, #435965)
* Removed debian/nginx.links and debian/preinst.
* Changing Maintainer address to bureado@debian.org.
* Welcoming Fabio Tranchitella <kobold@debian.org> as an nginx 
  uploader for Debian. Thanks for your patches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
74
74
{
75
75
    char                        *rv;
76
 
    u_char                       ch;
77
76
    ngx_int_t                    rc, j;
78
77
    ngx_uint_t                   mi, m, s, l, p, a, i, n;
79
78
    ngx_uint_t                   find_config_index, use_rewrite, use_access;
99
98
    ngx_http_core_loc_conf_t    *clcf;
100
99
    ngx_http_phase_handler_pt    checker;
101
100
    ngx_http_core_main_conf_t   *cmcf;
 
101
#if (NGX_PCRE)
 
102
    ngx_uint_t                   regex;
 
103
#endif
102
104
#if (NGX_WIN32)
103
105
    ngx_iocp_conf_t             *iocpcf;
104
106
#endif
402
404
 
403
405
 
404
406
    cmcf->phase_engine.server_rewrite_index = (ngx_uint_t) -1;
 
407
    cmcf->phase_engine.location_rewrite_index = (ngx_uint_t) -1;
405
408
    find_config_index = 0;
406
409
    use_rewrite = cmcf->phases[NGX_HTTP_REWRITE_PHASE].handlers.nelts ? 1 : 0;
407
410
    use_access = cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers.nelts ? 1 : 0;
443
446
 
444
447
            continue;
445
448
 
 
449
        case NGX_HTTP_REWRITE_PHASE:
 
450
            if (cmcf->phase_engine.location_rewrite_index == (ngx_uint_t) -1) {
 
451
                cmcf->phase_engine.location_rewrite_index = n;
 
452
            }
 
453
            checker = ngx_http_core_generic_phase;
 
454
 
 
455
            break;
 
456
 
446
457
        case NGX_HTTP_POST_REWRITE_PHASE:
447
458
            if (use_rewrite) {
448
459
                ph->checker = ngx_http_core_post_rewrite_phase;
542
553
 
543
554
                        if (in_addr[a].default_server) {
544
555
                            ngx_log_error(NGX_LOG_ERR, cf->log, 0,
545
 
                                        "the duplicate default server in %V:%d",
546
 
                                        &lscf[l].file_name, lscf[l].line);
 
556
                                      "the duplicate default server in %s:%ui",
 
557
                                       &lscf[l].file_name, lscf[l].line);
547
558
 
548
559
                            return NGX_CONF_ERROR;
549
560
                        }
647
658
                return NGX_CONF_ERROR;
648
659
            }
649
660
 
 
661
#if (NGX_PCRE)
 
662
            regex = 0;
 
663
#endif
 
664
 
650
665
            name = in_addr[a].names.elts;
651
 
            for (s = 0; s < in_addr[a].names.nelts; s++) {
652
 
 
653
 
                ch = name[s].name.data[0];
654
 
 
655
 
                if (ch == '*' || ch == '.') {
656
 
                    continue;
657
 
                }
658
 
 
659
 
                rc = ngx_hash_add_key(&ha, &name[s].name, name[s].core_srv_conf,
660
 
                                      0);
661
 
 
662
 
                if (rc == NGX_ERROR) {
663
 
                    return NGX_CONF_ERROR;
664
 
                }
665
 
 
666
 
                if (rc == NGX_BUSY) {
667
 
                    ngx_log_error(NGX_LOG_WARN, cf->log, 0,
668
 
                                "conflicting server name \"%V\" on %s, ignored",
669
 
                                &name[s].name, in_addr[a].listen_conf->addr);
670
 
                }
671
 
            }
672
 
 
673
 
            for (s = 0; s < in_addr[a].names.nelts; s++) {
674
 
 
675
 
                ch = name[s].name.data[0];
676
 
 
677
 
                if (ch != '*' && ch != '.') {
678
 
                    continue;
679
 
                }
 
666
 
 
667
            for (s = 0; s < in_addr[a].names.nelts; s++) {
 
668
 
 
669
#if (NGX_PCRE)
 
670
                if (name[s].regex) {
 
671
                    regex++;
 
672
                    continue;
 
673
                }
 
674
#endif
680
675
 
681
676
                rc = ngx_hash_add_key(&ha, &name[s].name, name[s].core_srv_conf,
682
677
                                      NGX_HASH_WILDCARD_KEY);
685
680
                    return NGX_CONF_ERROR;
686
681
                }
687
682
 
 
683
                if (rc == NGX_DECLINED) {
 
684
                    ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
 
685
                                "invalid server name or wildcard \"%V\" on %s",
 
686
                                &name[s].name, in_addr[a].listen_conf->addr);
 
687
                    return NGX_CONF_ERROR;
 
688
                }
 
689
 
688
690
                if (rc == NGX_BUSY) {
689
691
                    ngx_log_error(NGX_LOG_WARN, cf->log, 0,
690
692
                                "conflicting server name \"%V\" on %s, ignored",
709
711
                }
710
712
            }
711
713
 
712
 
            if (ha.dns_wildcards.nelts) {
713
 
 
714
 
                ngx_qsort(ha.dns_wildcards.elts,
715
 
                          (size_t) ha.dns_wildcards.nelts,
716
 
                          sizeof(ngx_hash_key_t),
717
 
                          ngx_http_cmp_dns_wildcards);
718
 
 
719
 
                hash.hash = NULL;
720
 
                hash.temp_pool = ha.temp_pool;
721
 
 
722
 
                if (ngx_hash_wildcard_init(&hash, ha.dns_wildcards.elts,
723
 
                                           ha.dns_wildcards.nelts)
724
 
                    != NGX_OK)
725
 
                {
726
 
                    ngx_destroy_pool(ha.temp_pool);
727
 
                    return NGX_CONF_ERROR;
728
 
                }
729
 
 
730
 
                in_addr[a].dns_wildcards = (ngx_hash_wildcard_t *) hash.hash;
 
714
            if (ha.dns_wc_head.nelts) {
 
715
 
 
716
                ngx_qsort(ha.dns_wc_head.elts,
 
717
                          (size_t) ha.dns_wc_head.nelts,
 
718
                          sizeof(ngx_hash_key_t),
 
719
                          ngx_http_cmp_dns_wildcards);
 
720
 
 
721
                hash.hash = NULL;
 
722
                hash.temp_pool = ha.temp_pool;
 
723
 
 
724
                if (ngx_hash_wildcard_init(&hash, ha.dns_wc_head.elts,
 
725
                                           ha.dns_wc_head.nelts)
 
726
                    != NGX_OK)
 
727
                {
 
728
                    ngx_destroy_pool(ha.temp_pool);
 
729
                    return NGX_CONF_ERROR;
 
730
                }
 
731
 
 
732
                in_addr[a].wc_head = (ngx_hash_wildcard_t *) hash.hash;
 
733
            }
 
734
 
 
735
            if (ha.dns_wc_tail.nelts) {
 
736
 
 
737
                ngx_qsort(ha.dns_wc_tail.elts,
 
738
                          (size_t) ha.dns_wc_tail.nelts,
 
739
                          sizeof(ngx_hash_key_t),
 
740
                          ngx_http_cmp_dns_wildcards);
 
741
 
 
742
                hash.hash = NULL;
 
743
                hash.temp_pool = ha.temp_pool;
 
744
 
 
745
                if (ngx_hash_wildcard_init(&hash, ha.dns_wc_tail.elts,
 
746
                                           ha.dns_wc_tail.nelts)
 
747
                    != NGX_OK)
 
748
                {
 
749
                    ngx_destroy_pool(ha.temp_pool);
 
750
                    return NGX_CONF_ERROR;
 
751
                }
 
752
 
 
753
                in_addr[a].wc_tail = (ngx_hash_wildcard_t *) hash.hash;
731
754
            }
732
755
 
733
756
            ngx_destroy_pool(ha.temp_pool);
 
757
 
 
758
#if (NGX_PCRE)
 
759
 
 
760
            if (regex == 0) {
 
761
                continue;
 
762
            }
 
763
 
 
764
            in_addr[a].nregex = regex;
 
765
            in_addr[a].regex = ngx_palloc(cf->pool,
 
766
                                       regex * sizeof(ngx_http_server_name_t));
 
767
 
 
768
            if (in_addr[a].regex == NULL) {
 
769
                return NGX_CONF_ERROR;
 
770
            }
 
771
 
 
772
            for (i = 0, s = 0; s < in_addr[a].names.nelts; s++) {
 
773
                if (name[s].regex) {
 
774
                    in_addr[a].regex[i++] = name[s];
 
775
                }
 
776
            }
 
777
#endif
734
778
        }
735
779
 
736
780
        in_addr = in_port[p].addrs.elts;
848
892
                hip->addrs[i].core_srv_conf = in_addr[i].core_srv_conf;
849
893
 
850
894
                if (in_addr[i].hash.buckets == NULL
851
 
                    && (in_addr[i].dns_wildcards == NULL
852
 
                        || in_addr[i].dns_wildcards->hash.buckets == NULL))
 
895
                    && (in_addr[i].wc_head == NULL
 
896
                        || in_addr[i].wc_head->hash.buckets == NULL)
 
897
                    && (in_addr[i].wc_head == NULL
 
898
                        || in_addr[i].wc_head->hash.buckets == NULL))
853
899
                {
854
900
                    continue;
855
901
                }
860
906
                }
861
907
                hip->addrs[i].virtual_names = vn;
862
908
 
863
 
                vn->hash = in_addr[i].hash;
864
 
                vn->dns_wildcards = in_addr[i].dns_wildcards;
 
909
                vn->names.hash = in_addr[i].hash;
 
910
                vn->names.wc_head = in_addr[i].wc_head;
 
911
                vn->names.wc_tail = in_addr[i].wc_tail;
 
912
#if (NGX_PCRE)
 
913
                vn->nregex = in_addr[i].nregex;
 
914
                vn->regex = in_addr[i].regex;
 
915
#endif
865
916
            }
866
917
 
867
918
            if (done) {
920
971
 
921
972
    if (in_port->addrs.elts == NULL) {
922
973
        if (ngx_array_init(&in_port->addrs, cf->temp_pool, 4,
923
 
                           sizeof(ngx_http_conf_in_addr_t)) != NGX_OK)
 
974
                           sizeof(ngx_http_conf_in_addr_t))
 
975
            != NGX_OK)
924
976
        {
925
977
            return NGX_ERROR;
926
978
        }
934
986
    in_addr->addr = lscf->addr;
935
987
    in_addr->hash.buckets = NULL;
936
988
    in_addr->hash.size = 0;
937
 
    in_addr->dns_wildcards = NULL;
 
989
    in_addr->wc_head = NULL;
 
990
    in_addr->wc_tail = NULL;
938
991
    in_addr->names.elts = NULL;
 
992
#if (NGX_PCRE)
 
993
    in_addr->nregex = 0;
 
994
    in_addr->regex = NULL;
 
995
#endif
939
996
    in_addr->core_srv_conf = cscf;
940
997
    in_addr->default_server = lscf->conf.default_server;
941
998
    in_addr->bind = lscf->conf.bind;
968
1025
 
969
1026
    if (in_addr->names.elts == NULL) {
970
1027
        if (ngx_array_init(&in_addr->names, cf->temp_pool, 4,
971
 
                           sizeof(ngx_http_server_name_t)) != NGX_OK)
 
1028
                           sizeof(ngx_http_server_name_t))
 
1029
            != NGX_OK)
972
1030
        {
973
1031
            return NGX_ERROR;
974
1032
        }
975
1033
    }
976
1034
 
977
1035
    server_names = cscf->server_names.elts;
 
1036
 
978
1037
    for (i = 0; i < cscf->server_names.nelts; i++) {
979
1038
 
980
1039
        for (n = 0; n < server_names[i].name.len; n++) {
985
1044
        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, cf->log, 0,
986
1045
                       "name: %V", &server_names[i].name);
987
1046
 
988
 
 
989
1047
        name = ngx_array_push(&in_addr->names);
990
1048
        if (name == NULL) {
991
1049
            return NGX_ERROR;