From 762b2cb8dc3eb46fb8f348f3dd04611f049a32e2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 20 Dec 2017 08:25:19 +0100 Subject: [PATCH] g_lock: fix cleanup of stale entries in g_lock_trylock() g_lock_trylock() always incremented the counter 'i', even after cleaning a stale entry at position 'i', which means it skipped checking for a conflict against the new entry at position 'i'. As result a process could get a write lock, while there're still some read lock holders. Once we get into that problem, also more than one write lock are possible. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13195 Signed-off-by: Stefan Metzmacher Reviewed-by: Volker Lendecke Autobuild-User(master): Volker Lendecke Autobuild-Date(master): Wed Dec 20 20:31:48 CET 2017 on sn-devel-144 (similar to commit 576fb4fb5dc506bf55e5cf87973999dca444149b) --- source3/lib/g_lock.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source3/lib/g_lock.c b/source3/lib/g_lock.c index 198fe56..2e8f232 100644 --- a/source3/lib/g_lock.c +++ b/source3/lib/g_lock.c @@ -301,9 +301,11 @@ static NTSTATUS g_lock_trylock(struct db_record *rec, struct server_id self, } } - for (i=0; i= num_locks) { -- 1.9.1