s3:g_lock: use serverid_exists() with SERVERID_UNIQUE_ID_NOT_TO_VERIFY
authorStefan Metzmacher <metze@samba.org>
Wed, 22 Aug 2012 10:35:29 +0000 (12:35 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 24 Aug 2012 11:43:31 +0000 (13:43 +0200)
metze

source3/lib/g_lock.c

index 4535b355690a64fc418ed307a24a3e28960f0a91..fbd90225f094a74f36a9adecfc0b2780e052219f 100644 (file)
@@ -29,6 +29,7 @@
 #include "../lib/util/tevent_ntstatus.h"
 #include "system/select.h"
 #include "messages.h"
+#include "serverid.h"
 
 struct g_lock_ctx {
        struct db_context *db;
@@ -124,8 +125,16 @@ static NTSTATUS g_lock_trylock(struct db_record *rec, struct server_id self,
                        goto done;
                }
                if (g_lock_conflicts(type, locks[i].lock_type)) {
+                       struct server_id pid = locks[i].pid;
 
-                       if (process_exists(locks[i].pid)) {
+                       /*
+                        * As the serverid_exists might recurse into
+                        * the g_lock code, we use
+                        * SERVERID_UNIQUE_ID_NOT_TO_VERIFY to avoid the loop
+                        */
+                       pid.unique_id = SERVERID_UNIQUE_ID_NOT_TO_VERIFY;
+
+                       if (serverid_exists(&pid)) {
                                status = NT_STATUS_LOCK_NOT_GRANTED;
                                goto done;
                        }