From be389e25ddff982a490c2b88c4649ce437a0d4d7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 10 Mar 2002 23:17:07 +0000 Subject: this attempts to handle the rather bizarre lock cache semantics in w2k. It isn't entirely accurate, but its close (This used to be commit e02d7364707c4939efa4ff0ddf9b6d4f48e5d411) --- source3/locking/brlock.c | 14 ++++++++++++++ source3/locking/locking.c | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c index 10c1d5053b..e7fa4022f6 100644 --- a/source3/locking/brlock.c +++ b/source3/locking/brlock.c @@ -285,6 +285,8 @@ NTSTATUS brl_lock(SMB_DEV_T dev, SMB_INO_T ino, int fnum, struct lock_struct lock, *locks; char *tp; NTSTATUS status = NT_STATUS_OK; + static int last_failed = -1; + static br_off last_failed_start; kbuf = locking_key(dev,ino); @@ -348,6 +350,18 @@ NTSTATUS brl_lock(SMB_DEV_T dev, SMB_INO_T ino, int fnum, return NT_STATUS_OK; fail: + /* this is a nasty hack to try to simulate the lock result cache code in w2k. + It isn't completely accurate as I haven't yet worked out the correct + semantics (tridge) + */ + if (last_failed == fnum && + last_failed_start == start && + NT_STATUS_EQUAL(status, NT_STATUS_LOCK_NOT_GRANTED)) { + status = NT_STATUS_FILE_LOCK_CONFLICT; + } + last_failed = fnum; + last_failed_start = start; + SAFE_FREE(dbuf.dptr); tdb_chainunlock(tdb, kbuf); return status; diff --git a/source3/locking/locking.c b/source3/locking/locking.c index 97366a1f9b..dd6ca62e70 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -171,7 +171,7 @@ NTSTATUS do_unlock(files_struct *fsp,connection_struct *conn, uint16 lock_pid, if (!ok) { DEBUG(10,("do_unlock: returning ERRlock.\n" )); - return NT_STATUS_LOCK_NOT_GRANTED; + return NT_STATUS_RANGE_NOT_LOCKED; } if (!lp_posix_locking(SNUM(conn))) -- cgit