[vlc-commits] file: set the non-blocking flag on pipes and sockets passed as fd://

Rémi Denis-Courmont git at videolan.org
Fri Aug 24 17:06:52 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Aug 24 18:06:12 2012 +0300| [ed68c13dee214d79d4c9c9632e4bac4b5714da32] | committer: Rémi Denis-Courmont

file: set the non-blocking flag on pipes and sockets passed as fd://

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

 modules/access/file.c |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/modules/access/file.c b/modules/access/file.c
index c6fd0dc..972e7ee 100644
--- a/modules/access/file.c
+++ b/modules/access/file.c
@@ -183,10 +183,15 @@ int FileOpen( vlc_object_t *p_this )
         goto error;
     }
 
-#ifdef S_ISSOCK
-    if (!S_ISFIFO (st.st_mode) && !S_ISSOCK (st.st_mode))
-        /* Clear non-blocking mode when not useful or not specified */
-        fcntl (fd, F_SETFL, fcntl (fd, F_GETFL) & ~O_NONBLOCK);
+#if O_NONBLOCK
+    int flags = fcntl (fd, F_GETFL);
+    if (S_ISFIFO (st.st_mode) || S_ISSOCK (st.st_mode))
+        /* Force non-blocking mode where applicable (fd://) */
+        flags |= O_NONBLOCK;
+    else
+        /* Force blocking mode when not useful or not specified */
+        flags &= ~O_NONBLOCK;
+    fcntl (fd, F_SETFL, flags);
 #endif
 
     /* Directories can be opened and read from, but only readdir() knows



More information about the vlc-commits mailing list