summaryrefslogtreecommitdiffstats
path: root/source/locking/brlock.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-04-30 13:28:41 +0000
committerJeremy Allison <jra@samba.org>2002-04-30 13:28:41 +0000
commitd04b55f2186fb8af998cf61c576771a5f72f4892 (patch)
tree9ff8c3a7cf34cefc0ee9a550a3bb1236a9e77595 /source/locking/brlock.c
parent73267ca42d9eddabb71b31b4c5068ebbe7bc9f7c (diff)
downloadsamba-d04b55f2186fb8af998cf61c576771a5f72f4892.tar.gz
samba-d04b55f2186fb8af998cf61c576771a5f72f4892.tar.xz
samba-d04b55f2186fb8af998cf61c576771a5f72f4892.zip
Start of merge to 2_2_RELEASE branch for release.
Jeremy.
Diffstat (limited to 'source/locking/brlock.c')
-rw-r--r--source/locking/brlock.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/source/locking/brlock.c b/source/locking/brlock.c
index cbf98c46a5e..8c22f7d7ab2 100644
--- a/source/locking/brlock.c
+++ b/source/locking/brlock.c
@@ -1,6 +1,5 @@
/*
- Unix SMB/Netbios implementation.
- Version 3.0
+ Unix SMB/CIFS implementation.
byte range locking code
Updated to handle range splits/merges.
@@ -163,6 +162,10 @@ static BOOL brl_conflict_other(struct lock_struct *lck1, struct lock_struct *lck
}
+#if DONT_DO_THIS
+ /* doing this traversal could kill solaris machines under high load (tridge) */
+ /* delete any dead locks */
+
/****************************************************************************
Delete a record if it is for a dead process, if check_self is true, then
delete any records belonging to this pid also (there shouldn't be any).
@@ -216,6 +219,7 @@ static int delete_fn(TDB_CONTEXT *ttdb, TDB_DATA kbuf, TDB_DATA dbuf, void *stat
tdb_chainunlock(tdb, kbuf);
return 0;
}
+#endif
/****************************************************************************
Open up the brlock.tdb database.
@@ -223,8 +227,6 @@ static int delete_fn(TDB_CONTEXT *ttdb, TDB_DATA kbuf, TDB_DATA dbuf, void *stat
void brl_init(int read_only)
{
- BOOL check_self = False;
-
if (tdb)
return;
tdb = tdb_open_log(lock_path("brlock.tdb"), 0, TDB_DEFAULT|(read_only?0x0:TDB_CLEAR_IF_FIRST),
@@ -234,9 +236,14 @@ void brl_init(int read_only)
return;
}
+#if DONT_DO_THIS
+ /* doing this traversal could kill solaris machines under high load (tridge) */
/* delete any dead locks */
- if (!read_only)
+ if (!read_only) {
+ BOOL check_self = False;
tdb_traverse(tdb, delete_fn, &check_self);
+ }
+#endif
}
/****************************************************************************
@@ -245,14 +252,17 @@ void brl_init(int read_only)
void brl_shutdown(int read_only)
{
- BOOL check_self = True;
-
if (!tdb)
return;
+#if DONT_DO_THIS
+ /* doing this traversal could kill solaris machines under high load (tridge) */
/* delete any dead locks */
- if (!read_only)
+ if (!read_only) {
+ BOOL check_self = True;
tdb_traverse(tdb, delete_fn, &check_self);
+ }
+#endif
tdb_close(tdb);
}
@@ -286,6 +296,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);
@@ -294,7 +306,6 @@ NTSTATUS brl_lock(SMB_DEV_T dev, SMB_INO_T ino, int fnum,
#if !ZERO_ZERO
if (start == 0 && size == 0) {
DEBUG(0,("client sent 0/0 lock - please report this\n"));
- return NT_STATUS_INVALID_PARAMETER;
}
#endif
@@ -350,6 +361,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;