From 11d8c8e587b4f00b08b34cccba3aac36817d0125 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 f954978..6a661cd 100644 --- a/source3/lib/g_lock.c +++ b/source3/lib/g_lock.c @@ -133,7 +133,9 @@ static NTSTATUS g_lock_trylock(struct db_record *rec, struct server_id self, return NT_STATUS_INTERNAL_ERROR; } - for (i=0; i