s3 oplocks: Remove oplocks before handling delete on close semantics
authorTim Prouty <tprouty@samba.org>
Wed, 4 Feb 2009 07:17:48 +0000 (23:17 -0800)
committerVolker Lendecke <vl@samba.org>
Fri, 15 Jan 2010 16:45:11 +0000 (17:45 +0100)
Unlinking a file while still holding an oplock can cause problems with
kernel oplocks.  This simply releases the oplock before actually
unlinking the file.

source/smbd/close.c

index 81d25efa51e4efc284bca528397abea4db92e804..114de2d4ace676639ec1d779f1b4e01a0ff53dcc 100644 (file)
@@ -553,6 +553,11 @@ static NTSTATUS close_normal_file(files_struct *fsp, enum file_close_type close_
                return NT_STATUS_OK;
        }
 
+       /* Remove the oplock before potentially deleting the file. */
+       if(fsp->oplock_type) {
+               release_file_oplock(fsp);
+       }
+
        /* If this is an old DOS or FCB open and we have multiple opens on
           the same handle we only have one share mode. Ensure we only remove
           the share mode on the last close. */
@@ -562,10 +567,6 @@ static NTSTATUS close_normal_file(files_struct *fsp, enum file_close_type close_
                saved_status3 = close_remove_share_mode(fsp, close_type);
        }
 
-       if(fsp->oplock_type) {
-               release_file_oplock(fsp);
-       }
-
        locking_close_file(smbd_messaging_context(), fsp);
 
        status = fd_close(fsp);