]> git.sesse.net Git - vlc/commitdiff
file: set the non-blocking flag on pipes and sockets passed as fd://
authorRémi Denis-Courmont <remi@remlab.net>
Fri, 24 Aug 2012 15:06:12 +0000 (18:06 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Fri, 24 Aug 2012 15:06:50 +0000 (18:06 +0300)
modules/access/file.c

index c6fd0dcd616fd82d81e9ee9f92d62e6cc3829617..972e7eec03a79d75366cf9ec5d374cac186da39c 100644 (file)
@@ -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