mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2025-01-03 14:56:34 -05:00
remove file descriptor leak when IPv6 is being used.
svn path=/trunk/net/; revision=4960
This commit is contained in:
parent
49c6946c07
commit
a4d20515f1
@ -503,32 +503,28 @@ sock_t sock_connect_wto(const char *hostname, const int port, const int timeout)
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user