set_socket_flags(int sock_fd, int flags)
{
/* Close the socket automatically on exec */
- if (
+ if (!SCK_IsReusable(sock_fd) &&
#ifdef SOCK_CLOEXEC
- (SCK_IsReusable(sock_fd) || (supported_socket_flags & SOCK_CLOEXEC) == 0) &&
+ (supported_socket_flags & SOCK_CLOEXEC) == 0 &&
#endif
!UTI_FdSetCloexec(sock_fd))
return 0;
void
SCK_Initialise(int family)
{
+ int fd;
+
ip4_enabled = family == IPADDR_INET4 || family == IPADDR_UNSPEC;
#ifdef FEAT_IPV6
ip6_enabled = family == IPADDR_INET6 || family == IPADDR_UNSPEC;
supported_socket_flags |= SOCK_NONBLOCK;
#endif
+ for (fd = first_reusable_fd; fd < first_reusable_fd + reusable_fds; fd++)
+ UTI_FdSetCloexec(fd);
+
initialised = 1;
}