ctdb-daemon: Check all connections from a process in CHECK_PID_SRVID control
authorAmitay Isaacs <amitay@gmail.com>
Fri, 22 Sep 2017 03:52:09 +0000 (13:52 +1000)
committerVolker Lendecke <vl@samba.org>
Fri, 22 Sep 2017 14:59:06 +0000 (16:59 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13042

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
ctdb/server/ctdb_daemon.c

index 90e8b715bae8db051699b9b2004b7f0f198ebbee..c72f41a4b9e7bd85fb05d4b07f13ef220aa1cfec 100644 (file)
@@ -1774,7 +1774,7 @@ int32_t ctdb_control_process_exists(struct ctdb_context *ctdb, pid_t pid)
 int32_t ctdb_control_check_pid_srvid(struct ctdb_context *ctdb,
                                     TDB_DATA indata)
 {
-        struct ctdb_client *client;
+       struct ctdb_client_pid_list *client_pid;
        pid_t pid;
        uint64_t srvid;
        int ret;
@@ -1782,17 +1782,19 @@ int32_t ctdb_control_check_pid_srvid(struct ctdb_context *ctdb,
        pid = *(pid_t *)indata.dptr;
        srvid = *(uint64_t *)(indata.dptr + sizeof(pid_t));
 
-       client = ctdb_find_client_by_pid(ctdb, pid);
-       if (client == NULL) {
-               return -1;
-       }
-
-       ret = srvid_exists(ctdb->srv, srvid, client);
-       if (ret != 0) {
-               return -1;
+       for (client_pid = ctdb->client_pids;
+            client_pid != NULL;
+            client_pid = client_pid->next) {
+               if (client_pid->pid == pid) {
+                       ret = srvid_exists(ctdb->srv, srvid,
+                                          client_pid->client);
+                       if (ret == 0) {
+                               return 0;
+                       }
+               }
        }
 
-       return 0;
+       return -1;
 }
 
 int ctdb_control_getnodesfile(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata)