Project

General

Profile

getaddrinfo.patch

patch to resolve hostname with getaddrinfo(). But there seems to be a bug in getaddrinfo() because strangely on my system it does not work on every hostname. -- ahaikens - Anonymous, 2007-10-26 12:02

View differences:

lighttpd-1.4.18/src/mod_fastcgi.c (working copy)
168 168
	 */
169 169
	buffer *host;
170 170
	unsigned short port;
171
	size_t  ai_addrlen;
172
	struct sockaddr_in ai_addr;
171 173

  
172 174
	/*
173 175
	 * Unix Domain Socket
......
1287 1289

  
1288 1290
							return HANDLER_ERROR;
1289 1291
						}
1292
						{
1293
						   int r;
1294
						   struct addrinfo* addr_info;
1295
						   
1296
						   if (0 != (r = getaddrinfo(host->host->ptr, NULL, NULL, &addr_info)))
1297
						   {
1298
							  log_error_write(srv, __FILE__, __LINE__, "sss",
1299
											  "getaddrinfo() failed for", host->host,
1300
											  gai_strerror(r));
1301
							  return HANDLER_ERROR;
1302
						   }
1303
						   memcpy(&(host->ai_addr), addr_info->ai_addr, addr_info->ai_addrlen);
1304
						   host->ai_addrlen = addr_info->ai_addrlen;
1305
						   if (addr_info) {
1306
							  freeaddrinfo(addr_info);
1307
						   }
1308
						}
1290 1309
					}
1291 1310

  
1292 1311
					if (!buffer_is_empty(host->bin_path)) {
......
1652 1671

  
1653 1672
static connection_result_t fcgi_establish_connection(server *srv, handler_ctx *hctx) {
1654 1673
	struct sockaddr *fcgi_addr;
1655
	struct sockaddr_in fcgi_addr_in;
1656 1674
#ifdef HAVE_SYS_UN_H
1657 1675
	struct sockaddr_un fcgi_addr_un;
1658 1676
#endif
......
1686 1704
		return -1;
1687 1705
#endif
1688 1706
	} else {
1689
		fcgi_addr_in.sin_family = AF_INET;
1690
		if (0 == inet_aton(host->host->ptr, &(fcgi_addr_in.sin_addr))) {
1691
			log_error_write(srv, __FILE__, __LINE__, "sbs",
1692
					"converting IP address failed for", host->host,
1693
					"\nBe sure to specify an IP address here");
1707
		host->ai_addr.sin_port = htons(proc->port);
1708
		servlen = host->ai_addrlen;
1709
		fcgi_addr = (struct sockaddr *) &(host->ai_addr);
1694 1710

  
1695
			return -1;
1696
		}
1697
		fcgi_addr_in.sin_port = htons(proc->port);
1698
		servlen = sizeof(fcgi_addr_in);
1699

  
1700
		fcgi_addr = (struct sockaddr *) &fcgi_addr_in;
1701

  
1702 1711
		if (buffer_is_empty(proc->connection_name)) {
1703 1712
			/* on remote spawing we have to set the connection-name now */
1704 1713
			buffer_copy_string(proc->connection_name, "tcp:");