lib: Fix pid_to_procid()
authorVolker Lendecke <vl@samba.org>
Fri, 16 Oct 2015 09:36:48 +0000 (11:36 +0200)
committerVolker Lendecke <vl@samba.org>
Mon, 19 Oct 2015 10:09:10 +0000 (12:09 +0200)
Putting in my_unique_id is just wrong. Now that we have
a cheap way to read everyone's unique ids out of the lockfile,
we can fix it.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/lib/util.c

index a0da08723c0d154ce71a3d73f8ac2f7e5b44b003..760c3ccd3a10f2fea0b8e61a063fe931f29870a6 100644 (file)
@@ -28,6 +28,7 @@
 #include "ctdbd_conn.h"
 #include "../lib/util/util_pw.h"
 #include "messages.h"
+#include "messages_dgm.h"
 #include "libcli/security/security.h"
 #include "serverid.h"
 #include "lib/util/sys_rw.h"
@@ -1968,12 +1969,17 @@ void set_my_unique_id(uint64_t unique_id)
 
 struct server_id pid_to_procid(pid_t pid)
 {
-       struct server_id result;
-       result.pid = pid;
-       result.task_id = 0;
-       result.unique_id = my_unique_id;
-       result.vnn = my_vnn;
-       return result;
+       uint64_t unique = 0;
+       int ret;
+
+       ret = messaging_dgm_get_unique(pid, &unique);
+       if (ret != 0) {
+               DBG_WARNING("%s: messaging_dgm_get_unique failed: %s\n",
+                           __func__, strerror(ret));
+       }
+
+       return (struct server_id) {
+               .pid = pid, .unique_id = unique, .vnn = my_vnn };
 }
 
 struct server_id procid_self(void)