Make strict locking an enum. Auto means use oplock optimization.
authorjra <jra@0c0555d6-39d7-0310-84fc-f1cc0bd64818>
Sat, 11 Dec 2004 00:30:28 +0000 (00:30 +0000)
committerjra <jra@0c0555d6-39d7-0310-84fc-f1cc0bd64818>
Sat, 11 Dec 2004 00:30:28 +0000 (00:30 +0000)
Jeremy.

git-svn-id: svn+ssh://svn.samba.org/data/svn/samba/branches/SAMBA_3_0@4143 0c0555d6-39d7-0310-84fc-f1cc0bd64818

source/locking/locking.c
source/param/loadparm.c
source/smbd/reply.c

index 4c6d89571e389e34f2c468edbeb06c0ae5cc65ff..e10e8a1fa0ffc9f232426f595d2c4d84fe702752 100644 (file)
@@ -69,24 +69,31 @@ BOOL is_locked(files_struct *fsp,connection_struct *conn,
               enum brl_type lock_type)
 {
        int snum = SNUM(conn);
+       int strict_locking = lp_strict_locking(snum);
        BOOL ret;
        
        if (count == 0)
                return(False);
 
-       if (!lp_locking(snum) || !lp_strict_locking(snum))
+       if (!lp_locking(snum) || !strict_locking)
                return(False);
 
-       if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type) && (lock_type == READ_LOCK || lock_type == WRITE_LOCK)) {
-               DEBUG(10,("is_locked: optimisation - exclusive oplock on file %s\n", fsp->fsp_name ));
-               ret = 0;
-       } else if (LEVEL_II_OPLOCK_TYPE(fsp->oplock_type) && (lock_type == READ_LOCK)) {
-               DEBUG(10,("is_locked: optimisation - level II oplock on file %s\n", fsp->fsp_name ));
-               ret = 0;
+       if (strict_locking == Auto) {
+               if  (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type) && (lock_type == READ_LOCK || lock_type == WRITE_LOCK)) {
+                       DEBUG(10,("is_locked: optimisation - exclusive oplock on file %s\n", fsp->fsp_name ));
+                       ret = 0;
+               } else if (LEVEL_II_OPLOCK_TYPE(fsp->oplock_type) && (lock_type == READ_LOCK)) {
+                       DEBUG(10,("is_locked: optimisation - level II oplock on file %s\n", fsp->fsp_name ));
+                       ret = 0;
+               } else {
+                       ret = !brl_locktest(fsp->dev, fsp->inode, fsp->fnum,
+                                    global_smbpid, sys_getpid(), conn->cnum, 
+                                    offset, count, lock_type);
+               }
        } else {
                ret = !brl_locktest(fsp->dev, fsp->inode, fsp->fnum,
-                            global_smbpid, sys_getpid(), conn->cnum, 
-                            offset, count, lock_type);
+                               global_smbpid, sys_getpid(), conn->cnum,
+                               offset, count, lock_type);
        }
 
        DEBUG(10,("is_locked: brl start=%.0f len=%.0f %s for file %s\n",
index 094eff81c0c74d9a38274134ba95d1adbf283ec0..d8aef215b84a1f4d3c113073e99631480bf94b91 100644 (file)
@@ -386,7 +386,7 @@ typedef struct
        BOOL bMap_archive;
        BOOL bStoreDosAttributes;
        BOOL bLocking;
-       BOOL bStrictLocking;
+       int iStrictLocking;
        BOOL bPosixLocking;
        BOOL bShareModes;
        BOOL bOpLocks;
@@ -511,7 +511,7 @@ static service sDefault = {
        True,                   /* bMap_archive */
        False,                  /* bStoreDosAttributes */
        True,                   /* bLocking */
-       True,                   /* bStrictLocking */
+       True,                   /* iStrictLocking */
        True,                   /* bPosixLocking */
        True,                   /* bShareModes */
        True,                   /* bOpLocks */
@@ -1075,7 +1075,7 @@ static struct parm_struct parm_table[] = {
        {"oplock break wait time", P_INTEGER, P_GLOBAL, &Globals.oplock_break_wait_time, NULL, NULL, FLAG_ADVANCED | FLAG_GLOBAL}, 
        {"oplock contention limit", P_INTEGER, P_LOCAL, &sDefault.iOplockContentionLimit, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL}, 
        {"posix locking", P_BOOL, P_LOCAL, &sDefault.bPosixLocking, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL}, 
-       {"strict locking", P_BOOL, P_LOCAL, &sDefault.bStrictLocking, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL}, 
+       {"strict locking", P_ENUM, P_LOCAL, &sDefault.iStrictLocking, NULL, enum_bool_auto, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL}, 
        {"share modes", P_BOOL, P_LOCAL,  &sDefault.bShareModes, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL}, 
 
        {N_("Ldap Options"), P_SEP, P_SEPARATOR}, 
@@ -1858,7 +1858,7 @@ FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden)
 FN_LOCAL_BOOL(lp_map_archive, bMap_archive)
 FN_LOCAL_BOOL(lp_store_dos_attributes, bStoreDosAttributes)
 FN_LOCAL_BOOL(lp_locking, bLocking)
-FN_LOCAL_BOOL(lp_strict_locking, bStrictLocking)
+FN_LOCAL_INTEGER(lp_strict_locking, iStrictLocking)
 FN_LOCAL_BOOL(lp_posix_locking, bPosixLocking)
 FN_LOCAL_BOOL(lp_share_modes, bShareModes)
 FN_LOCAL_BOOL(lp_oplocks, bOpLocks)
index 507e4c1c37176d61a8d0d9ee7b6d34f76bd895f0..825f76fcd5115d2db6a9d38e34abc03607437f34 100644 (file)
@@ -4578,7 +4578,7 @@ int reply_lockingX(connection_struct *conn, char *inbuf,char *outbuf,int length,
                /* we don't support these - and CANCEL_LOCK makes w2k
                   and XP reboot so I don't really want to be
                   compatible! (tridge) */
-               return ERROR_NT(NT_STATUS_NOT_SUPPORTED);
+               return ERROR_NT(NT_STATUS_UNSUCCESSFUL);
        }
        
        if (locktype & LOCKING_ANDX_CANCEL_LOCK) {