diff src/http/ngx_http_upstream_round_robin.c @ 266:251bcd11a5b8 NGINX_0_5_3

nginx 0.5.3 *) Feature: the ngx_http_perl_module supports the $r->status, $r->log_error, and $r->sleep methods. *) Feature: the $r->variable method supports variables that do not exist in nginx configuration. *) Bugfix: the $r->has_request_body method did not work.
author Igor Sysoev <http://sysoev.ru>
date Wed, 13 Dec 2006 00:00:00 +0300
parents e0b1d0a6c629
children 9b7db0df50f0
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 = (in_port_t) (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)