Fix EINTR handling for close
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user