[vlc-commits] commit: net: fix socket blocking if accept4 not available (Erwan Tulou )

git at videolan.org git at videolan.org
Sat Apr 3 18:55:42 CEST 2010


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Sat Apr  3 17:30:17 2010 +0200| [3bb6e111d59c77f9506b45181fd73c0274a81135] | committer: Erwan Tulou 

net: fix socket blocking if accept4 not available

same options needed for vlc_accept as those for vlc_socket

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3bb6e111d59c77f9506b45181fd73c0274a81135
---

 src/text/filesystem.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/src/text/filesystem.c b/src/text/filesystem.c
index 40a158a..e230f05 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);
 



More information about the vlc-commits mailing list