Make the maximum number of clients configurable
[deb_shairplay.git] / src / lib / httpd.c
index 9c17e3694668a0d1ddc6c349dc94dfae9d0989a6..2bed984203ebbdd907eb480daa8ea20749f2c682 100644 (file)
@@ -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);