[xiph-commits] r13492 - icecast/trunk/icecast/src

karl at svn.xiph.org karl at svn.xiph.org
Wed Aug 8 20:36:03 PDT 2007


Author: karl
Date: 2007-08-08 20:36:03 -0700 (Wed, 08 Aug 2007)
New Revision: 13492

Modified:
   icecast/trunk/icecast/src/connection.c
Log:
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.



Modified: icecast/trunk/icecast/src/connection.c
===================================================================
--- icecast/trunk/icecast/src/connection.c	2007-08-09 03:19:24 UTC (rev 13491)
+++ icecast/trunk/icecast/src/connection.c	2007-08-09 03:36:03 UTC (rev 13492)
@@ -266,18 +266,24 @@
     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);
     }
-
-    if (!sock_recoverable(sock_error()))
-        WARN2("accept() failed with error %d: %s", sock_error(), strerror(sock_error()));
-    
+    else
+    {
+        if (!sock_recoverable(sock_error()))
+        {
+            WARN2("accept() failed with error %d: %s", sock_error(), strerror(sock_error()));
+            thread_sleep (500000);
+        }
+    }
     free(ip);
-
     return NULL;
 }
 



More information about the commits mailing list