| 178 | } |
| 179 | |
| 180 | int ff_socket(int af, int type, int proto, void *logctx) |
| 181 | { |
| 182 | int fd; |
| 183 | |
| 184 | #ifdef SOCK_CLOEXEC |
| 185 | fd = socket(af, type | SOCK_CLOEXEC, proto); |
| 186 | if (fd == -1 && errno == EINVAL) |
| 187 | #endif |
| 188 | { |
| 189 | fd = socket(af, type, proto); |
| 190 | #if HAVE_FCNTL |
| 191 | if (fd != -1) { |
| 192 | if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) |
| 193 | av_log(logctx, AV_LOG_DEBUG, "Failed to set close on exec\n"); |
| 194 | } |
| 195 | #endif |
| 196 | } |
| 197 | #ifdef SO_NOSIGPIPE |
| 198 | if (fd != -1) { |
| 199 | if (setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &(int){1}, sizeof(int))) { |
| 200 | av_log(logctx, AV_LOG_WARNING, "setsockopt(SO_NOSIGPIPE) failed\n"); |
| 201 | } |
| 202 | } |
| 203 | #endif |
| 204 | return fd; |
| 205 | } |
| 206 | |
| 207 | int ff_listen(int fd, const struct sockaddr *addr, |
| 208 | socklen_t addrlen, void *logctx) |
no test coverage detected