s4-smb2: SMB2 uses NT_STATUS_CANCELLED for cancelled locks
[ira/wip.git] / source4 / ntvfs / posix / pvfs_lock.c
index 0054455838a98246df26b0410e20bd2666d6bd5f..11757deea49d02c6c903a1f8bb89eb9cd97121c1 100644 (file)
@@ -22,7 +22,7 @@
 #include "includes.h"
 #include "vfs_posix.h"
 #include "system/time.h"
-#include "lib/util/dlinklist.h"
+#include "../lib/util/dlinklist.h"
 #include "messaging/messaging.h"
 
 
@@ -88,9 +88,10 @@ static void pvfs_lock_async_failed(struct pvfs_state *pvfs,
   range, so we should try the lock again. Note that on timeout we
   do retry the lock, giving it a last chance.
 */
-static void pvfs_pending_lock_continue(void *private, enum pvfs_wait_notice reason)
+static void pvfs_pending_lock_continue(void *private_data, enum pvfs_wait_notice reason)
 {
-       struct pvfs_pending_lock *pending = private;
+       struct pvfs_pending_lock *pending = talloc_get_type(private_data,
+                                           struct pvfs_pending_lock);
        struct pvfs_state *pvfs = pending->pvfs;
        struct pvfs_file *f = pending->f;
        struct ntvfs_request *req = pending->req;
@@ -115,7 +116,11 @@ static void pvfs_pending_lock_continue(void *private, enum pvfs_wait_notice reas
 
        /* we don't retry on a cancel */
        if (reason == PVFS_WAIT_CANCEL) {
-               status = NT_STATUS_FILE_LOCK_CONFLICT;
+               if (pvfs->ntvfs->ctx->protocol != PROTOCOL_SMB2) {
+                       status = NT_STATUS_FILE_LOCK_CONFLICT;
+               } else {
+                       status = NT_STATUS_CANCELLED;
+               }
        } else {
                /* 
                 * here it's important to pass the pending pointer
@@ -277,7 +282,8 @@ static NTSTATUS pvfs_lock_cancel(struct pvfs_state *pvfs, struct ntvfs_request *
 NTSTATUS pvfs_lock(struct ntvfs_module_context *ntvfs,
                   struct ntvfs_request *req, union smb_lock *lck)
 {
-       struct pvfs_state *pvfs = ntvfs->private_data;
+       struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data,
+                                 struct pvfs_state);
        struct pvfs_file *f;
        struct smb_lock_entry *locks;
        int i;