From 3bb6e111d59c77f9506b45181fd73c0274a81135 Mon Sep 17 00:00:00 2001 From: Erwan Tulou Date: Sat, 3 Apr 2010 17:30:17 +0200 Subject: [PATCH] net: fix socket blocking if accept4 not available same options needed for vlc_accept as those for vlc_socket --- src/text/filesystem.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/text/filesystem.c b/src/text/filesystem.c index 40a158a75c..e230f058c1 100644 --- a/src/text/filesystem.c +++ b/src/text/filesystem.c @@ -636,7 +636,7 @@ int vlc_socket (int pf, int type, int proto, bool nonblock) type |= SOCK_CLOEXEC; if (nonblock) type |= SOCK_NONBLOCK; - fd = socket (pf, type | SOCK_NONBLOCK | SOCK_CLOEXEC, proto); + fd = socket (pf, type, proto); if (fd != -1 || errno != EINVAL) return fd; @@ -693,7 +693,17 @@ int vlc_accept (int lfd, struct sockaddr *addr, socklen_t *alen, bool nonblock) { int fd = accept (lfd, addr, alen); if (fd != -1) + { +#ifndef WIN32 + fcntl (fd, F_SETFD, FD_CLOEXEC); + if (nonblock) + fcntl (fd, F_SETFL, fcntl (fd, F_GETFL, 0) | O_NONBLOCK); +#else + if (nonblock) + ioctlsocket (fd, FIONBIO, &(unsigned long){ 1 }); +#endif return fd; + } } while (errno == EINTR); -- 2.39.2