[xiph-cvs] cvs commit: net sock.c

Karl Heyes karl at xiph.org
Wed Jun 18 04:05:49 PDT 2003



karl        03/06/18 07:05:49

  Modified:    .        sock.c
  Log:
  remove file descriptor leak when IPv6 is being used.

Revision  Changes    Path
1.29      +8 -12     net/sock.c

Index: sock.c
===================================================================
RCS file: /usr/local/cvsroot/net/sock.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- sock.c	6 Jun 2003 11:19:50 -0000	1.28
+++ sock.c	18 Jun 2003 11:05:49 -0000	1.29
@@ -503,32 +503,28 @@
     ai = head;
     while (ai)
     {
-        if ((sock = socket (ai->ai_family, ai->ai_socktype, ai->ai_protocol)) 
-                > -1)
+        if ((sock = socket (ai->ai_family, ai->ai_socktype, ai->ai_protocol)) > -1)
         {
             if (timeout)
             {
                 sock_set_blocking (sock, SOCK_NONBLOCK);
                 if (connect (sock, ai->ai_addr, ai->ai_addrlen) < 0)
                 {
-                    int ret = sock_connected (sock, timeout);
-                    if (ret <= 0)
+                    if (sock_connected (sock, timeout) > 0)
                     {
-                        sock_close (sock);
-                        sock = SOCK_ERROR;
+                        sock_set_blocking(sock, SOCK_BLOCK);
+                        break;
                     }
                 }
-                sock_set_blocking(sock, SOCK_BLOCK);
             }
             else
             {
-                if (connect (sock, ai->ai_addr, ai->ai_addrlen) < 0)
-                {
-                    sock_close (sock);
-                    sock = SOCK_ERROR;
-                }
+                if (connect (sock, ai->ai_addr, ai->ai_addrlen) == 0)
+                    break;
             }
+            sock_close (sock);
         }
+        sock = SOCK_ERROR;
         ai = ai->ai_next;
     }
     if (head) freeaddrinfo (head);

<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