There's no point in calling FLOCK on a non-existing fd
authorVolker Lendecke <vl@samba.org>
Fri, 11 Jan 2008 20:53:29 +0000 (21:53 +0100)
committerVolker Lendecke <vl@samba.org>
Sat, 12 Jan 2008 19:11:10 +0000 (20:11 +0100)
source/smbd/open.c

index 59699dfbd0f67b08a95798d92a87fcb2bac9082e..d1679209bb1783007d034b01805af33fffe169db 100644 (file)
@@ -1761,14 +1761,16 @@ NTSTATUS open_file_ntcreate(connection_struct *conn,
            the kernel refuses the operations then the kernel is wrong.
           note that GPFS supports it as well - jmcd */
 
-       ret_flock = SMB_VFS_KERNEL_FLOCK(fsp, share_access);
-       if(ret_flock == -1 ){
+       if (fsp->fh->fd != -1) {
+               ret_flock = SMB_VFS_KERNEL_FLOCK(fsp, share_access);
+               if(ret_flock == -1 ){
 
-               TALLOC_FREE(lck);
-               fd_close(fsp);
-               file_free(fsp);
-               
-               return NT_STATUS_SHARING_VIOLATION;
+                       TALLOC_FREE(lck);
+                       fd_close(fsp);
+                       file_free(fsp);
+
+                       return NT_STATUS_SHARING_VIOLATION;
+               }
        }
 
        /*