summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2007-08-24 02:37:38 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:02:29 -0500
commitfe5124e38d8fbc271a3b5553f54dd6ecd33cf7c7 (patch)
treed63cfee27b97fc8e12b89111ff86f944ab553f30 /source4
parent10d8f0086ba950de206f74cbdf062caeee913fde (diff)
downloadsamba-fe5124e38d8fbc271a3b5553f54dd6ecd33cf7c7.tar.gz
samba-fe5124e38d8fbc271a3b5553f54dd6ecd33cf7c7.tar.bz2
samba-fe5124e38d8fbc271a3b5553f54dd6ecd33cf7c7.zip
r24642: prevent recursion with fetch_locked
add a note about server_id exists checking (This used to be commit dd951b983c0cde2dd54c5370dc8d6440509b0559)
Diffstat (limited to 'source4')
-rw-r--r--source4/ntvfs/common/brlock_tdb.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/source4/ntvfs/common/brlock_tdb.c b/source4/ntvfs/common/brlock_tdb.c
index 25a0a040a5..0bca9d2590 100644
--- a/source4/ntvfs/common/brlock_tdb.c
+++ b/source4/ntvfs/common/brlock_tdb.c
@@ -135,9 +135,12 @@ static BOOL brl_tdb_same_context(struct lock_context *ctx1, struct lock_context
/*
see if lck1 and lck2 overlap
+
+ lck1 is the existing lock. lck2 is the new lock we are
+ looking at adding
*/
static BOOL brl_tdb_overlap(struct lock_struct *lck1,
- struct lock_struct *lck2)
+ struct lock_struct *lck2)
{
/* this extra check is not redundent - it copes with locks
that go beyond the end of 64 bit file space */
@@ -151,6 +154,15 @@ static BOOL brl_tdb_overlap(struct lock_struct *lck1,
lck2->start >= (lck1->start+lck1->size)) {
return False;
}
+
+ /* we have a conflict. Now check to see if lck1 really still
+ * exists, which involves checking if the process still
+ * exists. We leave this test to last as its the most
+ * expensive test, especially when we are clustered */
+ /* TODO: need to do this via a server_id_exists() call, which
+ * hasn't been written yet. When clustered this will need to
+ * call into ctdb */
+
return True;
}
@@ -283,14 +295,6 @@ static NTSTATUS brl_tdb_lock(struct brl_context *brl,
NTSTATUS status;
struct db_record *rec = NULL;
- kbuf.dptr = brlh->key.data;
- kbuf.dsize = brlh->key.length;
-
- rec = brl->db->fetch_locked(brl->db, brl, kbuf);
- if (rec == NULL) {
- return NT_STATUS_INTERNAL_DB_CORRUPTION;
- }
-
/* if this is a pending lock, then with the chainlock held we
try to get the real lock. If we succeed then we don't need
to make it pending. This prevents a possible race condition
@@ -305,11 +309,19 @@ static NTSTATUS brl_tdb_lock(struct brl_context *brl,
brlh->last_lock = lock;
if (NT_STATUS_IS_OK(status)) {
- talloc_free(rec);
return NT_STATUS_OK;
}
}
+ kbuf.dptr = brlh->key.data;
+ kbuf.dsize = brlh->key.length;
+
+ rec = brl->db->fetch_locked(brl->db, brl, kbuf);
+ if (rec == NULL) {
+ return NT_STATUS_INTERNAL_DB_CORRUPTION;
+ }
+
+
dbuf = rec->value;
lock.context.smbpid = smbpid;