Mercurial > hg > nginx
comparison src/http/ngx_http_upstream.c @ 906:a0310ac2814f
rewritten upstream
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 12 Dec 2006 16:46:16 +0000 |
parents | cc4273a2597e |
children | bf1785dfb75f |
comparison
equal
deleted
inserted
replaced
905:be52cfdb3e31 | 906:a0310ac2814f |
---|---|
2596 | 2596 |
2597 ngx_memzero(&u, sizeof(ngx_url_t)); | 2597 ngx_memzero(&u, sizeof(ngx_url_t)); |
2598 | 2598 |
2599 value = cf->args->elts; | 2599 value = cf->args->elts; |
2600 u.host = value[1]; | 2600 u.host = value[1]; |
2601 u.upstream = 1; | |
2602 u.no_resolve = 1; | 2601 u.no_resolve = 1; |
2603 | 2602 |
2604 uscf = ngx_http_upstream_add(cf, &u, NGX_HTTP_UPSTREAM_CREATE | 2603 uscf = ngx_http_upstream_add(cf, &u, NGX_HTTP_UPSTREAM_CREATE |
2605 |NGX_HTTP_UPSTREAM_WEIGHT | 2604 |NGX_HTTP_UPSTREAM_WEIGHT |
2606 |NGX_HTTP_UPSTREAM_MAX_FAILS | 2605 |NGX_HTTP_UPSTREAM_MAX_FAILS |
2720 value = cf->args->elts; | 2719 value = cf->args->elts; |
2721 | 2720 |
2722 ngx_memzero(&u, sizeof(ngx_url_t)); | 2721 ngx_memzero(&u, sizeof(ngx_url_t)); |
2723 | 2722 |
2724 u.url = value[1]; | 2723 u.url = value[1]; |
2725 u.default_portn = 80; | 2724 u.default_port = 80; |
2726 | 2725 |
2727 if (ngx_parse_url(cf, &u) != NGX_OK) { | 2726 if (ngx_parse_url(cf, &u) != NGX_OK) { |
2728 if (u.err) { | 2727 if (u.err) { |
2729 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 2728 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
2730 "%s in upstream \"%V\"", u.err, &u.url); | 2729 "%s in upstream \"%V\"", u.err, &u.url); |
2841 umcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_upstream_module); | 2840 umcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_upstream_module); |
2842 | 2841 |
2843 uscfp = umcf->upstreams.elts; | 2842 uscfp = umcf->upstreams.elts; |
2844 | 2843 |
2845 for (i = 0; i < umcf->upstreams.nelts; i++) { | 2844 for (i = 0; i < umcf->upstreams.nelts; i++) { |
2846 if ((uscfp[i]->port && uscfp[i]->port != u->portn) | 2845 |
2847 || uscfp[i]->host.len != u->host.len | 2846 if (uscfp[i]->host.len != u->host.len |
2848 || ngx_strncasecmp(uscfp[i]->host.data, u->host.data, u->host.len) | 2847 || ngx_strncasecmp(uscfp[i]->host.data, u->host.data, u->host.len) |
2849 != 0) | 2848 != 0) |
2850 { | 2849 { |
2851 continue; | 2850 continue; |
2852 } | 2851 } |
2857 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 2856 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
2858 "duplicate upstream \"%V\"", &u->host); | 2857 "duplicate upstream \"%V\"", &u->host); |
2859 return NULL; | 2858 return NULL; |
2860 } | 2859 } |
2861 | 2860 |
2862 if (uscfp[i]->port == 0 && u->portn && !u->no_port) { | 2861 if ((uscfp[i]->flags & NGX_HTTP_UPSTREAM_CREATE) && u->port) { |
2863 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, | 2862 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, |
2864 "upstream \"%V\" port %d is ignored", | 2863 "upstream \"%V\" may not have port %d", |
2865 &u->host, u->portn); | 2864 &u->host, u->port); |
2865 return NULL; | |
2866 } | |
2867 | |
2868 if ((flags & NGX_HTTP_UPSTREAM_CREATE) && uscfp[i]->port) { | |
2869 ngx_log_error(NGX_LOG_WARN, cf->log, 0, | |
2870 "upstream \"%V\" may not have port %d in %s:%ui", | |
2871 &u->host, uscfp[i]->port, | |
2872 uscfp[i]->file_name.data, uscfp[i]->line); | |
2873 return NULL; | |
2874 } | |
2875 | |
2876 if (uscfp[i]->port != u->port) { | |
2877 continue; | |
2866 } | 2878 } |
2867 | 2879 |
2868 return uscfp[i]; | 2880 return uscfp[i]; |
2869 } | 2881 } |
2870 | 2882 |
2875 | 2887 |
2876 uscf->flags = flags; | 2888 uscf->flags = flags; |
2877 uscf->host = u->host; | 2889 uscf->host = u->host; |
2878 uscf->file_name = cf->conf_file->file.name; | 2890 uscf->file_name = cf->conf_file->file.name; |
2879 uscf->line = cf->conf_file->line; | 2891 uscf->line = cf->conf_file->line; |
2880 uscf->port = u->portn; | 2892 uscf->port = u->port; |
2893 uscf->default_port = u->default_port; | |
2881 | 2894 |
2882 if (u->naddrs == 1) { | 2895 if (u->naddrs == 1) { |
2883 uscf->servers = ngx_array_create(cf->pool, 1, | 2896 uscf->servers = ngx_array_create(cf->pool, 1, |
2884 sizeof(ngx_http_upstream_server_t)); | 2897 sizeof(ngx_http_upstream_server_t)); |
2885 if (uscf->servers == NULL) { | 2898 if (uscf->servers == NULL) { |