From adac7ebee4ba7653fc81d4062aa5e66c310e1af2 Mon Sep 17 00:00:00 2001 From: Karl Heyes Date: Thu, 9 Aug 2007 03:36:03 +0000 Subject: [PATCH] if addresses come back as IPv4-mapped IPv6 then make it look like IPv4 or else we'll get queries about the access log. Fix a potential FD leak and add a small delay into the listener thread if accept fails, the usual cause is an FD limit being reached triggering logs to fill up and CPU to max out. svn path=/icecast/trunk/icecast/; revision=13492 --- src/connection.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/connection.c b/src/connection.c index cb9d7e8b..7ed7e1eb 100644 --- a/src/connection.c +++ b/src/connection.c @@ -266,18 +266,24 @@ static connection_t *_accept_connection(void) sock = sock_accept(serversock, ip, MAX_ADDR_LEN); if (sock >= 0) { + /* Make any IPv4 mapped IPv6 address look like a normal IPv4 address */ + if (strncmp (ip, "::ffff:", 7) == 0) + memmove (ip, ip+7, strlen (ip+7)+1); + con = connection_create (sock, serversock, ip); - if (con == NULL) - free (ip); - - return con; + if (con) + return con; + sock_close (sock); + } + else + { + if (!sock_recoverable(sock_error())) + { + WARN2("accept() failed with error %d: %s", sock_error(), strerror(sock_error())); + thread_sleep (500000); + } } - - if (!sock_recoverable(sock_error())) - WARN2("accept() failed with error %d: %s", sock_error(), strerror(sock_error())); - free(ip); - return NULL; }