Fix EINTR handling for close

This commit is contained in:
2025-08-23 20:14:24 -04:00
parent 7db0e331e4
commit 18a1b30d9f
6 changed files with 86 additions and 78 deletions

View File

@@ -94,10 +94,11 @@ int getConnectFd(const char *node, const char *service) {
break; /* Success */
}
int e;
do {
e = close(sfd);
} while (e == -1 && errno == EINTR);
int e = close(sfd);
if (e == -1 && errno != EINTR) {
perror("close sfd (load_tester)");
abort();
}
}
freeaddrinfo(result); /* No longer needed */
@@ -252,11 +253,8 @@ struct Connection {
bool error = false;
~Connection() {
int e;
do {
e = close(fd);
} while (e == -1 && errno == EINTR);
if (e == -1) {
int e = close(fd);
if (e == -1 && errno != EINTR) {
perror("close");
abort();
}
@@ -830,9 +828,10 @@ int main(int argc, char *argv[]) {
// Clean up epoll file descriptors
for (int epollfd : g_epoll_fds) {
int e;
do {
e = close(epollfd);
} while (e == -1 && errno == EINTR);
int e = close(epollfd);
if (e == -1 && errno != EINTR) {
perror("close epollfd");
abort();
}
}
}