[vlc-commits] file: do not use non-blocking mode when unknown/unspecified/useless

Rémi Denis-Courmont git at videolan.org
Wed Jun 20 07:25:29 CEST 2012


vlc/vlc-2.0 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Jun 20 08:16:16 2012 +0300| [da7b4234c23c113013903955bd21be1249db195f] | committer: Rémi Denis-Courmont

file: do not use non-blocking mode when unknown/unspecified/useless

For FIFO and sockets, non-blocking is wanted. For character device,
the effects depend on the device driver. For other types, non-blocking
mode has either no effects or is unspecified.
(cherry picked from commit bd19904c7d2ab50b83d98c64244cb0d54ff46da7)

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

 modules/access/file.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/modules/access/file.c b/modules/access/file.c
index 44c5870..a7d1126 100644
--- a/modules/access/file.c
+++ b/modules/access/file.c
@@ -192,6 +192,11 @@ int FileOpen( vlc_object_t *p_this )
         msg_Err (p_access, "failed to read (%m)");
         goto error;
     }
+
+    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);
+
     /* Directories can be opened and read from, but only readdir() knows
      * how to parse the data. The directory plugin will do it. */
     if (S_ISDIR (st.st_mode))



More information about the vlc-commits mailing list