Compare commits

..

No commits in common. "7b6c7de1fadd10f7a6400b22fd3738a9e099d11f" and "1e47b86f420df44d18b5f35982fec34d747ab9e0" have entirely different histories.

5 changed files with 22 additions and 5 deletions

View File

@ -218,7 +218,7 @@ attempt_connect:
#if defined(SOL_SOCKET) && defined(SO_REUSEADDR)
EINTRLOOP(rs, setsockopt(s_unix_fd, SOL_SOCKET, SO_REUSEADDR, (void *)&a1, sizeof a1));
#endif
EINTRLOOP(rs, connect(s_unix_fd, &s_unix.s, s_unix_l));
rs = blocking_connect(s_unix_fd, &s_unix.s, s_unix_l);
if (rs) {
retry:
/*debug("connect: %d, %s", errno, strerror(errno));*/

View File

@ -672,7 +672,7 @@ static void try_connect(struct connection *c)
#if defined(__aarch64__) && defined(__ILP32__)
errno = EINPROGRESS; /* arm64 ilp32 bug */
#endif
EINTRLOOP(rs, connect(s, (struct sockaddr *)(void *)&sa, sizeof sa));
rs = connect(s, (struct sockaddr *)(void *)&sa, sizeof sa);
#ifdef SUPPORT_IPV6
} else if (addr->af == AF_INET6) {
struct sockaddr_in6 sa;
@ -686,14 +686,14 @@ static void try_connect(struct connection *c)
#if defined(__aarch64__) && defined(__ILP32__)
errno = EINPROGRESS; /* arm64 ilp32 bug */
#endif
EINTRLOOP(rs, connect(s, (struct sockaddr *)(void *)&sa, sizeof sa));
rs = connect(s, (struct sockaddr *)(void *)&sa, sizeof sa);
#endif
} else {
rs = -1;
errno = EINVAL;
}
if (rs) {
if (errno != EALREADY && errno != EINPROGRESS) {
if (errno != EALREADY && errno != EINPROGRESS && errno != EINTR) {
#ifdef BEOS
if (errno == EWOULDBLOCK) errno = ETIMEDOUT;
#endif

2
dns.c
View File

@ -773,7 +773,7 @@ int ipv6_full_access(void)
sin6.sin6_family = AF_INET6;
sin6.sin6_port = htons(1024);
memcpy(&sin6.sin6_addr.s6_addr, "\052\001\004\060\000\015\000\000\002\314\236\377\376\044\176\032", 16);
EINTRLOOP(c, connect(h, (struct sockaddr *)(void *)&sin6, sizeof sin6));
c = blocking_connect(h, (struct sockaddr *)(void *)&sin6, sizeof sin6);
EINTRLOOP(rs, close(h));
if (!c) return 1;
#endif

View File

@ -1140,6 +1140,7 @@ extern int terminate_loop;
int can_write(int fd);
int can_read(int fd);
int can_read_timeout(int fd, int sec);
int blocking_connect(int fd, struct sockaddr *addr, socklen_t addrlen);
int close_std_handle(int);
void restore_std_handle(int, int);
unsigned long select_info(int);

View File

@ -125,6 +125,22 @@ int can_read(int fd)
}
// PATCH: Handle connect not being restartable
int blocking_connect(int fd, struct sockaddr *addr, socklen_t addrlen)
{
int connect_error;
socklen_t len = sizeof(connect_error);
if (!connect(fd, addr, addrlen)) return 0;
if (errno != EINTR) return -1;
can_do_io(fd, 1, -1); // Wait until connected/failed
getsockopt(fd, SOL_SOCKET, SO_ERROR, &connect_error, &len);
errno = connect_error;
return !connect_error ? 0 : -1;
}
int close_std_handle(int std)
{
#ifndef DOS