sorry, the diff file in the last file is bad, use this one.<br><br>This is a new implementation according to your comments.<br><br>Here is my comments to this patch<br><br>1. ngx_inet_sock_addr is removed. You are right, ngx_parse_url can do that job. So no need to change ngx_inet.h<br>
<br>
2. the old "gethostbyname" implementation will be used if "--with-ipv6"
is not set; when "--with-ipv6" is set, "getaddrinfo" will be used<br><br>3.
now when "ngx_inet_parse_url" find u->host might be a hostname, it
will invoke new added function "ngx_inet_resolve_hostname".<br>
<br>4. seems there is a bug in old file's line 829. Only when uri is NULL, len = last - port.<br><br>5.
now "ngx_inet6_parse_url" will finally invoke new added
"ngx_inet6_resolve_host", just like what "ngx_inet_parse_url" does. I
think it should be done but the old code doesn't do that. Please confirm
this is valid.<br>
<br>6. I try to remove duplicated code as much as possible, so the
"ngx_inet_resolve_host" is almost rewritten. Now, it will first handle
the u->host as it's an IP; if not, it will try to resolve them.<br>
<br>7. In "ngx_inet_parse_url", it firstly assume it's AF_INET and
allocate the memory. I think it's not suitable in the new
implementation, but I didn't touch this part of code.<br><br>8. All the fix are tested as before (with and without "--with-ipv6"), all test are passed.<br>
<br>9. I make this implementation based on 0.9.3. I compare the
ngx_inet.c in official 0.9.3 and 0.9.5, and find there is a difference:<br><br>- for (i = 0; i < u->naddrs; i++) {<br>+ for (i = 0; h->h_addr_list[i] != NULL; i++) {<br>
<br>Since my implementation use "getaddrinfo", h_addr_list[i] will be invalid when "--with-ipv6" is set.<br><br>Thanks.<br>