]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Always open files with O_NONBLOCK
authorVolker Lendecke <vl@samba.org>
Mon, 29 Jul 2019 18:45:51 +0000 (20:45 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 30 Jul 2019 22:37:26 +0000 (22:37 +0000)
It's perfectly possible that someone else takes a kernel oplock and
makes us block, independent of our own kernel oplock setting.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=14060
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/open.c

index 2ee4a2c4fcae88260b3bea7f3215b7bdad5afd72..6838354a7d496e8c43205a784743a1355b364b9a 100644 (file)
@@ -3214,21 +3214,19 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
                flags2 &= ~(O_CREAT|O_TRUNC);
        }
 
-       if (lp_kernel_oplocks(SNUM(conn))) {
-               /*
-                * With kernel oplocks the open breaking an oplock
-                * blocks until the oplock holder has given up the
-                * oplock or closed the file. We prevent this by always
-                * trying to open the file with O_NONBLOCK (see "man
-                * fcntl" on Linux).
-                *
-                * If a process that doesn't use the smbd open files
-                * database or communication methods holds a kernel
-                * oplock we must periodically poll for available open
-                * using O_NONBLOCK.
-                */
-               flags2 |= O_NONBLOCK;
-       }
+       /*
+        * With kernel oplocks the open breaking an oplock
+        * blocks until the oplock holder has given up the
+        * oplock or closed the file. We prevent this by always
+        * trying to open the file with O_NONBLOCK (see "man
+        * fcntl" on Linux).
+        *
+        * If a process that doesn't use the smbd open files
+        * database or communication methods holds a kernel
+        * oplock we must periodically poll for available open
+        * using O_NONBLOCK.
+        */
+       flags2 |= O_NONBLOCK;
 
        /*
         * Ensure we can't write on a read-only share or file.