[nginx] svn commit: r4685 - trunk/src/core

ru at nginx.com ru at nginx.com
Mon Jun 18 12:46:06 UTC 2012


Author: ru
Date: 2012-06-18 12:46:05 +0000 (Mon, 18 Jun 2012)
New Revision: 4685
URL: http://trac.nginx.org/nginx/changeset/4685/nginx

Log:
When "resolver" is configured with a domain name, only the first
resolved address was used.  Now all addresses will be used.


Modified:
   trunk/src/core/ngx_resolver.c

Modified: trunk/src/core/ngx_resolver.c
===================================================================
--- trunk/src/core/ngx_resolver.c	2012-06-18 12:30:45 UTC (rev 4684)
+++ trunk/src/core/ngx_resolver.c	2012-06-18 12:46:05 UTC (rev 4685)
@@ -96,7 +96,7 @@
 {
     ngx_str_t              s;
     ngx_url_t              u;
-    ngx_uint_t             i;
+    ngx_uint_t             i, j;
     ngx_resolver_t        *r;
     ngx_pool_cleanup_t    *cln;
     ngx_udp_connection_t  *uc;
@@ -184,16 +184,18 @@
             return NULL;
         }
 
-        uc = ngx_array_push(&r->udp_connections);
+        uc = ngx_array_push_n(&r->udp_connections, u.naddrs);
         if (uc == NULL) {
             return NULL;
         }
 
-        ngx_memzero(uc, sizeof(ngx_udp_connection_t));
+        ngx_memzero(uc, u.naddrs * sizeof(ngx_udp_connection_t));
 
-        uc->sockaddr = u.addrs->sockaddr;
-        uc->socklen = u.addrs->socklen;
-        uc->server = u.addrs->name;
+        for (j = 0; j < u.naddrs; j++) {
+            uc[j].sockaddr = u.addrs[j].sockaddr;
+            uc[j].socklen = u.addrs[j].socklen;
+            uc[j].server = u.addrs[j].name;
+        }
     }
 
     return r;



More information about the nginx-devel mailing list