| 77 | |
| 78 | #if !HAVE_ACCEPT4 |
| 79 | static int |
| 80 | accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags) |
| 81 | { |
| 82 | int fd, err; |
| 83 | |
| 84 | do { |
| 85 | fd = accept(sockfd, addr, addrlen); |
| 86 | if (likely(fd >= 0)) |
| 87 | break; |
| 88 | } while (transient_error()); |
| 89 | |
| 90 | if ((fd >= 0) && (flags & SOCK_CLOEXEC) && (safe_fcntl(fd, F_SETFD, FD_CLOEXEC) < 0)) { |
| 91 | err = errno; |
| 92 | close(fd); |
| 93 | errno = err; |
| 94 | return -1; |
| 95 | } |
| 96 | |
| 97 | if ((fd >= 0) && (flags & SOCK_NONBLOCK) && (safe_nonblocking(fd) < 0)) { |
| 98 | err = errno; |
| 99 | close(fd); |
| 100 | errno = err; |
| 101 | return -1; |
| 102 | } |
| 103 | |
| 104 | return fd; |
| 105 | } |
| 106 | #endif // !HAVE_ACCEPT4 |
| 107 | |
| 108 | int |
no test coverage detected