X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fhttpd.c;h=2bed984203ebbdd907eb480daa8ea20749f2c682;hb=72fe063cf6771a3645d8cef0ae4426ad72b16917;hp=9c17e3694668a0d1ddc6c349dc94dfae9d0989a6;hpb=46212791ac2f31ee382934c461c49495e0c66cc9;p=deb_shairplay.git diff --git a/src/lib/httpd.c b/src/lib/httpd.c index 9c17e36..2bed984 100644 --- a/src/lib/httpd.c +++ b/src/lib/httpd.c @@ -110,6 +110,7 @@ httpd_add_connection(httpd_t *httpd, int fd, unsigned char *local, int local_len } } if (i == httpd->max_connections) { + /* This code should never be reached, we do not select server_fd when full */ logger_log(httpd->logger, LOGGER_INFO, "Max connections reached"); shutdown(fd, SHUT_RDWR); closesocket(fd); @@ -315,6 +316,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);