Index: lighttpd-1.4.18/src/mod_fastcgi.c =================================================================== --- lighttpd-1.4.18/src/mod_fastcgi.c (revision 2048) +++ lighttpd-1.4.18/src/mod_fastcgi.c (working copy) @@ -168,6 +168,8 @@ */ buffer *host; unsigned short port; + size_t ai_addrlen; + struct sockaddr_in ai_addr; /* * Unix Domain Socket @@ -1287,6 +1289,23 @@ return HANDLER_ERROR; } + { + int r; + struct addrinfo* addr_info; + + if (0 != (r = getaddrinfo(host->host->ptr, NULL, NULL, &addr_info))) + { + log_error_write(srv, __FILE__, __LINE__, "sss", + "getaddrinfo() failed for", host->host, + gai_strerror(r)); + return HANDLER_ERROR; + } + memcpy(&(host->ai_addr), addr_info->ai_addr, addr_info->ai_addrlen); + host->ai_addrlen = addr_info->ai_addrlen; + if (addr_info) { + freeaddrinfo(addr_info); + } + } } if (!buffer_is_empty(host->bin_path)) { @@ -1652,7 +1671,6 @@ static connection_result_t fcgi_establish_connection(server *srv, handler_ctx *hctx) { struct sockaddr *fcgi_addr; - struct sockaddr_in fcgi_addr_in; #ifdef HAVE_SYS_UN_H struct sockaddr_un fcgi_addr_un; #endif @@ -1686,19 +1704,10 @@ return -1; #endif } else { - fcgi_addr_in.sin_family = AF_INET; - if (0 == inet_aton(host->host->ptr, &(fcgi_addr_in.sin_addr))) { - log_error_write(srv, __FILE__, __LINE__, "sbs", - "converting IP address failed for", host->host, - "\nBe sure to specify an IP address here"); + host->ai_addr.sin_port = htons(proc->port); + servlen = host->ai_addrlen; + fcgi_addr = (struct sockaddr *) &(host->ai_addr); - return -1; - } - fcgi_addr_in.sin_port = htons(proc->port); - servlen = sizeof(fcgi_addr_in); - - fcgi_addr = (struct sockaddr *) &fcgi_addr_in; - if (buffer_is_empty(proc->connection_name)) { /* on remote spawing we have to set the connection-name now */ buffer_copy_string(proc->connection_name, "tcp:");