[xiph-cvs] cvs commit: icecast/src connection.c

Karl Heyes karl at xiph.org
Fri Jun 20 11:50:24 PDT 2003



karl        03/06/20 14:50:24

  Modified:    src      connection.c
  Log:
  handle error returned from listening sockets, can cause busy looping

Revision  Changes    Path
1.72      +22 -2     icecast/src/connection.c

Index: connection.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/connection.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -r1.71 -r1.72
--- connection.c	5 Jun 2003 04:15:58 -0000	1.71
+++ connection.c	20 Jun 2003 18:50:24 -0000	1.72
@@ -145,11 +145,31 @@
         return -1;
     }
     else {
+        int dst;
         for(i=0; i < global.server_sockets; i++) {
-            if(ufds[i].revents == POLLIN)
+            if(ufds[i].revents & POLLIN)
                 return ufds[i].fd;
+            if(ufds[i].revents & (POLLHUP|POLLERR|POLLNVAL))
+            {
+                if (ufds[i].revents & (POLLHUP|POLLERR))
+                {
+                    close (global.serversock[i]);
+                    WARN0("Had to close a listening socket");
+                }
+                global.serversock[i] = -1;
+            }
         }
-        return -1; /* Shouldn't happen */
+        /* remove any closed sockets */
+        for(i=0, dst=0; i < global.server_sockets; i++)
+        {
+            if (global.serversock[i] == -1)
+                continue;
+            if (i!=dst)
+                global.serversock[dst] = global.serversock[i];
+            dst++;
+        }
+        global.server_sockets = dst;
+        return -1;
     }
 #else
     fd_set rfds;

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list