From: Volker Lendecke Date: Mon, 29 Jul 2019 18:45:51 +0000 (+0200) Subject: smbd: Always open files with O_NONBLOCK X-Git-Tag: tdb-1.4.2~395 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ef582ffcf3a220b73f678d9bce0fd37800f76c54;p=thirdparty%2Fsamba.git smbd: Always open files with O_NONBLOCK 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 Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 2ee4a2c4fca..6838354a7d4 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -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.