[PATCH] fix getaddrinfo usage

Marco d'Itri md at Linux.IT
Sat Aug 26 21:09:19 UTC 2006


This patch fixes a problem with the IPv6-mode address resolution
in innfeed. The upstream code neglects to tell getaddrinfo(3) that it
wants a SOCK_STREAM; thus each address for the hostname thrice gets
reported thrice: one with each of SOCK_STREAM, SOCK_DGRAM and
SOCK_RAW. Therefore an address that is unreachable will be tried
three times before innfeed goes on to try another address.

This patch amends the getaddrinfo(3) call to request a SOCK_STREAM
address.

Created by Henning Makholm <henning at makholm.net> on 2005-10-30 while
investigating Debian bug #336264. This patch is in the public domain.

diff -ruN inn-2.4.2.orig/innfeed/host.c inn-2.4.2/innfeed/host.c
--- inn-2.4.2.orig/innfeed/host.c	2004-12-22 05:21:19.000000000 +0100
+++ inn-2.4.2/innfeed/host.c	2005-10-30 11:20:07.903313828 +0100
@@ -1122,10 +1122,12 @@
 #ifdef HAVE_INET6
       int gai_ret;
       struct addrinfo *res, *p;
+      struct addrinfo template = {0};
+      template.ai_family = PF_UNSPEC;
+      template.ai_socktype = SOCK_STREAM;
 
-      if(( gai_ret = getaddrinfo(host->params->ipName, NULL, NULL, &res)) != 0
-		      || res == NULL )
-
+      gai_ret = getaddrinfo(host->params->ipName, NULL, &template, &res);
+      if( gai_ret != 0 || res == NULL )
 	{
           warn ("%s can't resolve hostname %s: %s", host->params->peerName,
 		host->params->ipName, gai_ret == 0 ? "no addresses returned"

-- 
ciao,
Marco


More information about the inn-workers mailing list