summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2017-08-30 16:18:02 +1000
committerMartin Schwenke <martins@samba.org>2017-09-21 08:53:26 +0200
commit02ae3d9fab6cdaaa1a2999a57a37ecc281f7f608 (patch)
tree694dbdedbad5e6d4b56699cfc103b418f99f5925
parent7115378f7534f79043ab1b5d2b8fb265145537aa (diff)
downloadsamba-02ae3d9fab6cdaaa1a2999a57a37ecc281f7f608.tar.gz
ctdb-daemon: Add implementation of control CHECK_PID_SRVID
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13042 Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
-rw-r--r--ctdb/include/ctdb_private.h2
-rw-r--r--ctdb/server/ctdb_control.c4
-rw-r--r--ctdb/server/ctdb_daemon.c24
3 files changed, 30 insertions, 0 deletions
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index 9be81ff8603..227d518c0ce 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -582,6 +582,8 @@ struct ctdb_client *ctdb_find_client_by_pid(struct ctdb_context *ctdb,
pid_t pid);
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);
int ctdb_control_getnodesfile(struct ctdb_context *ctdb, uint32_t opcode,
TDB_DATA indata, TDB_DATA *outdata);
diff --git a/ctdb/server/ctdb_control.c b/ctdb/server/ctdb_control.c
index 9f74011e0a5..9aeaa235830 100644
--- a/ctdb/server/ctdb_control.c
+++ b/ctdb/server/ctdb_control.c
@@ -696,6 +696,10 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
return 0;
}
+ case CTDB_CONTROL_CHECK_PID_SRVID:
+ CHECK_CONTROL_DATA_SIZE((sizeof(pid_t) + sizeof(uint64_t)));
+ return ctdb_control_check_pid_srvid(ctdb, indata);
+
default:
DEBUG(DEBUG_CRIT,(__location__ " Unknown CTDB control opcode %u\n", opcode));
return -1;
diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c
index 8ae43517a85..90e8b715bae 100644
--- a/ctdb/server/ctdb_daemon.c
+++ b/ctdb/server/ctdb_daemon.c
@@ -1771,6 +1771,30 @@ int32_t ctdb_control_process_exists(struct ctdb_context *ctdb, pid_t pid)
return kill(pid, 0);
}
+int32_t ctdb_control_check_pid_srvid(struct ctdb_context *ctdb,
+ TDB_DATA indata)
+{
+ struct ctdb_client *client;
+ pid_t pid;
+ uint64_t srvid;
+ int ret;
+
+ 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;
+ }
+
+ return 0;
+}
+
int ctdb_control_getnodesfile(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata)
{
struct ctdb_node_map_old *node_map = NULL;