Do not return `-EINVAL` as socket value (obviously not a good idea).

Also, fix socket descriptor leak in `tr_netBindTCPImpl` if `IPV6_V6ONLY` is defined.
This commit is contained in:
Mike Gelfand 2015-03-26 18:29:11 +00:00
parent cefc477918
commit 12095175a1
1 changed files with 2 additions and 1 deletions

View File

@ -241,7 +241,7 @@ tr_netOpenPeerSocket (tr_session * session,
assert (tr_address_is_valid (addr));
if (!tr_address_is_valid_for_peers (addr, port))
return -EINVAL;
return TR_BAD_SOCKET; /* -EINVAL */
s = tr_fdSocketCreate (session, domains[addr->type], SOCK_STREAM);
if (s == TR_BAD_SOCKET)
@ -350,6 +350,7 @@ tr_netBindTCPImpl (const tr_address * addr,
if (setsockopt (fd, IPPROTO_IPV6, IPV6_V6ONLY, (const void *) &optval, sizeof (optval)) == -1)
if (sockerrno != ENOPROTOOPT) { /* if the kernel doesn't support it, ignore it */
*errOut = sockerrno;
tr_netCloseSocket (fd);
return TR_BAD_SOCKET;
}
#endif