From: Juho Vähä-Herttua Date: Sat, 12 May 2012 15:04:09 +0000 (+0300) Subject: Fall back to IPv4 in case initializing IPv6 socket fails X-Git-Tag: upstream/0.9.0~4^2~82 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=c5d9c5414bd2b43435f6a4c3848b827578a1c835;p=deb_shairplay.git Fall back to IPv4 in case initializing IPv6 socket fails --- diff --git a/src/lib/httpd.c b/src/lib/httpd.c index 9c17e36..971a5bf 100644 --- a/src/lib/httpd.c +++ b/src/lib/httpd.c @@ -315,6 +315,11 @@ httpd_start(httpd_t *httpd, unsigned short *port) } httpd->server_fd = netutils_init_socket(port, 1, 0); + if (httpd->server_fd == -1) { + logger_log(httpd->logger, LOGGER_INFO, "Error initialising IPv6 socket %d", SOCKET_GET_ERROR()); + logger_log(httpd->logger, LOGGER_INFO, "Attempting to fall back to IPv4"); + httpd->server_fd = netutils_init_socket(port, 0, 0); + } if (httpd->server_fd == -1) { logger_log(httpd->logger, LOGGER_INFO, "Error initialising socket %d", SOCKET_GET_ERROR()); MUTEX_UNLOCK(httpd->run_mutex);