From: Marco van Wieringen Date: Wed, 30 May 2012 14:15:36 +0000 (+0200) Subject: Tweak connect error. X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f9ec43d2a84e162eebaca9cde5a90c31ddef60c8;p=bacula%2Fbacula Tweak connect error. On lookup of a hostname we could get back both IPv4 and IPV6 addresses for a given host. But we may only support IPV4 on the local host and as such trying to create an IPV6 socket will fail. If we check the return code of the socket call for EAFNOSUPPORT we catch such an error and can continue trying to create a socket type that is supported. --- diff --git a/bacula/src/lib/bsock.c b/bacula/src/lib/bsock.c index 845e63ecff..891b10f3e4 100644 --- a/bacula/src/lib/bsock.c +++ b/bacula/src/lib/bsock.c @@ -218,9 +218,21 @@ bool BSOCK::open(JCR *jcr, const char *name, char *host, char *service, if ((sockfd = socket(ipaddr->get_family(), SOCK_STREAM, 0)) < 0) { berrno be; save_errno = errno; - *fatal = 1; - Pmsg3(000, _("Socket open error. proto=%d port=%d. ERR=%s\n"), - ipaddr->get_family(), ipaddr->get_port_host_order(), be.bstrerror()); + switch (errno) { +#ifdef EAFNOSUPPORT + case EAFNOSUPPORT: + /* + * The name lookup of the host returned an address in a protocol family + * we don't support. Suppress the error and try the next address. + */ + break; +#endif + default: + *fatal = 1; + Pmsg3(000, _("Socket open error. proto=%d port=%d. ERR=%s\n"), + ipaddr->get_family(), ipaddr->get_port_host_order(), be.bstrerror()); + break; + } continue; }