Commit bc43f3ac authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

posix: revector vlc_accept()

parent 3d710f64
...@@ -318,35 +318,29 @@ int vlc_socket (int pf, int type, int proto, bool nonblock) ...@@ -318,35 +318,29 @@ int vlc_socket (int pf, int type, int proto, bool nonblock)
*/ */
int vlc_accept (int lfd, struct sockaddr *addr, socklen_t *alen, bool nonblock) int vlc_accept (int lfd, struct sockaddr *addr, socklen_t *alen, bool nonblock)
{ {
int fd;
#ifdef HAVE_ACCEPT4 #ifdef HAVE_ACCEPT4
int flags = SOCK_CLOEXEC; int flags = SOCK_CLOEXEC;
if (nonblock) if (nonblock)
flags |= SOCK_NONBLOCK; flags |= SOCK_NONBLOCK;
do do
{ fd = accept4 (lfd, addr, alen, flags);
int fd = accept4 (lfd, addr, alen, flags); while (fd == -1 && errno == EINTR);
if (fd != -1)
return fd;
}
while (errno == EINTR);
if (errno != ENOSYS) if (fd != -1 || errno != ENOSYS)
return -1; return fd;
#endif #endif
do do
fd = accept (lfd, addr, alen);
while (fd == -1 && errno == EINTR);
if (fd != -1)
{ {
int fd = accept (lfd, addr, alen); fcntl (fd, F_SETFD, FD_CLOEXEC);
if (fd != -1) if (nonblock)
{ fcntl (fd, F_SETFL, fcntl (fd, F_GETFL, 0) | O_NONBLOCK);
fcntl (fd, F_SETFD, FD_CLOEXEC);
if (nonblock)
fcntl (fd, F_SETFL, fcntl (fd, F_GETFL, 0) | O_NONBLOCK);
return fd;
}
} }
while (errno == EINTR); return fd;
return -1;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment