diff src/http/ngx_http_upstream_round_robin.c @ 906:a0310ac2814f

rewritten upstream
author Igor Sysoev <igor@sysoev.ru>
date Tue, 12 Dec 2006 16:46:16 +0000
parents f247db60fc85
children 327aef5c6ac4
line wrap: on
line diff
--- a/src/http/ngx_http_upstream_round_robin.c
+++ b/src/http/ngx_http_upstream_round_robin.c
@@ -61,10 +61,17 @@ ngx_http_upstream_init_round_robin(ngx_c
 
     /* an upstream implicitly defined by proxy_pass, etc. */
 
+    if (us->port == 0 && us->default_port == 0) {
+        ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
+                      "no port in upstream \"%V\" in %s:%ui",
+                      &us->host, us->file_name.data, us->line);
+        return NGX_ERROR;
+    }
+
     ngx_memzero(&u, sizeof(ngx_url_t));
 
     u.host = us->host;
-    u.portn = us->port;
+    u.port = us->port ? us->port : us->default_port;
 
     if (ngx_inet_resolve_host(cf, &u) != NGX_OK) {
         if (u.err) {
@@ -76,13 +83,6 @@ ngx_http_upstream_init_round_robin(ngx_c
         return NGX_ERROR;
     }
 
-    if (us->port == 0) {
-        ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
-                      "no port in upstream \"%V\" in %s:%ui",
-                      &us->host, us->file_name.data, us->line);
-        return NGX_ERROR;
-    }
-
     n = u.naddrs;
 
     peers = ngx_pcalloc(cf->pool, sizeof(ngx_http_upstream_rr_peers_t)