From 29e4554a9be9e8c25f200c3012e7fa4c2d03aaef Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 26 Oct 2010 12:41:30 +0200 Subject: [PATCH] tcp comstack: change behavior for @-specs (anyaddr) @ listens on AF_INET (IPV4) peers, and @6 listens to AF_INET6 (ipv6) peers. Previously @ listened on AF_INET6 which accepted both IPV4 and IPV6 peers on some Linux systems. However, in general that does not work so YAZ can not rely on that to work. Debian changed behavior in this respect from Debian lenny to Debian squeeze (still testing as of Oct 2010). Refer to: http://www.mail-archive.com/debian-devel@lists.debian.org/msg277726.html --- NEWS | 9 +++++++++ src/tcpip.c | 27 ++++++++++----------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/NEWS b/NEWS index e761eff..fed8f3b 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,12 @@ +tcp comstack: change behavior for @-specs (anyaddr). @ listens on +AF_INET (IPV4) peers, and @6 listens to AF_INET6 (ipv6) peers. +Previously @ listened on AF_INET6 which accepted both IPV4 and IPV6 +peers on some Linux systems. However, in general that does not work +so YAZ can not rely on that to work. Debian changed behavior in this +respect from Debian lenny to Debian squeeze (still testing as of Oct +2010). Refer to: +http://www.mail-archive.com/debian-devel@lists.debian.org/msg277726.html + --- 4.1.1 2010/10/05 Fix yaz-config output: echo_source not set correctly by configure. diff --git a/src/tcpip.c b/src/tcpip.c index d72bc44..dc1d127 100644 --- a/src/tcpip.c +++ b/src/tcpip.c @@ -363,6 +363,13 @@ struct addrinfo *tcpip_getaddrinfo(const char *str, const char *port) if (!strcmp("@", host)) { hints.ai_flags = AI_PASSIVE; + hints.ai_family = AF_INET; + error = getaddrinfo(0, port, &hints, &res); + } + else if (!strcmp("@6", host)) + { + hints.ai_flags = AI_PASSIVE; + hints.ai_family = AF_INET6; error = getaddrinfo(0, port, &hints, &res); } else @@ -434,25 +441,11 @@ void *tcpip_straddr(COMSTACK h, const char *str) if (sp->ai && h->state == CS_ST_UNBND) { int s = -1; - /* try to make IPV6 socket first */ for (ai = sp->ai; ai; ai = ai->ai_next) { - if (ai->ai_family == AF_INET6) - { - s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); - if (s != -1) - break; - } - } - if (s == -1) - { - /* no IPV6 could be made.. Try them all */ - for (ai = sp->ai; ai; ai = ai->ai_next) - { - s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); - if (s != -1) - break; - } + s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); + if (s != -1) + break; } if (s == -1) return 0; -- 1.7.10.4