r23792: convert Samba4 to GPLv3
[tprouty/samba.git] / source4 / ntvfs / posix / pvfs_lock.c
index 2e0f77616bcf11cef5155ff0a458ad4a67de92bf..bf17ceb83b5e2a6602da52418e7ae0531c08d1ff 100644 (file)
@@ -7,7 +7,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -16,8 +16,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
@@ -69,8 +68,13 @@ static void pvfs_lock_async_failed(struct pvfs_state *pvfs,
                                   int i,
                                   NTSTATUS status)
 {
+       /* in SMB2 mode we also try to unlock failing lock */ 
+       if (req->ctx->protocol != PROTOCOL_SMB2) {
+               i--;
+       }
+
        /* undo the locks we just did */
-       for (i=i-1;i>=0;i--) {
+       for (;i>=0;i--) {
                brl_unlock(pvfs->brl_context,
                           f->brl_handle,
                           locks[i].pid,
@@ -125,7 +129,7 @@ static void pvfs_pending_lock_continue(void *private, enum pvfs_wait_notice reas
                 */
                status = brl_lock(pvfs->brl_context,
                                  f->brl_handle,
-                                 req->smbpid,
+                                 locks[pending->pending_lock].pid,
                                  locks[pending->pending_lock].offset,
                                  locks[pending->pending_lock].count,
                                  rw, pending);
@@ -174,7 +178,7 @@ static void pvfs_pending_lock_continue(void *private, enum pvfs_wait_notice reas
 
                status = brl_lock(pvfs->brl_context,
                                  f->brl_handle,
-                                 req->smbpid,
+                                 locks[i].pid,
                                  locks[i].offset,
                                  locks[i].count,
                                  rw, pending);
@@ -377,8 +381,12 @@ NTSTATUS pvfs_lock(struct ntvfs_module_context *ntvfs,
                                DLIST_ADD(f->pending_list, pending);
                                return NT_STATUS_OK;
                        }
+                       /* in SMB2 mode we also try to unlock failing lock */ 
+                       if (req->ctx->protocol != PROTOCOL_SMB2) {
+                               i--;
+                       }
                        /* undo the locks we just did */
-                       for (i=i-1;i>=0;i--) {
+                       for (;i>=0;i--) {
                                brl_unlock(pvfs->brl_context,
                                           f->brl_handle,
                                           locks[i].pid,