summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2017-09-22 14:04:50 +1000
committerVolker Lendecke <vl@samba.org>2017-09-22 16:59:06 +0200
commit6ed2ed7e2dc55e2508f31f32e53db5dab1fce2a8 (patch)
treec42b7c7a143513c0722d5eb758a6e996ec101adb
parente342f1f078fa50904216e6e45fb9b6e40043eb98 (diff)
downloadsamba-6ed2ed7e2dc55e2508f31f32e53db5dab1fce2a8.tar.gz
ctdb-tests: Check all connections from a process in CHECK_PID_SRVID control
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>
-rw-r--r--ctdb/tests/src/fake_ctdbd.c49
1 files changed, 30 insertions, 19 deletions
diff --git a/ctdb/tests/src/fake_ctdbd.c b/ctdb/tests/src/fake_ctdbd.c
index 8b3a0c44887..98aacbe37df 100644
--- a/ctdb/tests/src/fake_ctdbd.c
+++ b/ctdb/tests/src/fake_ctdbd.c
@@ -2792,35 +2792,46 @@ static void control_check_pid_srvid(TALLOC_CTX *mem_ctx,
struct client_state *state = tevent_req_data(
req, struct client_state);
struct ctdbd_context *ctdb = state->ctdb;
+ struct ctdb_client *client;
struct client_state *cstate;
struct ctdb_reply_control reply;
+ bool pid_found, srvid_found;
int ret;
reply.rdata.opcode = request->opcode;
- cstate = client_find(ctdb, request->rdata.data.pid_srvid->pid);
- if (cstate == NULL) {
- reply.status = -1;
- reply.errmsg = "No client for PID";
- } else {
- ret = srvid_exists(ctdb->srv,
- request->rdata.data.pid_srvid->srvid,
- cstate);
- if (ret != 0) {
- reply.status = -1;
- reply.errmsg = "No client for PID and SRVID";
- } else {
- ret = kill(cstate->pid, 0);
- if (ret != 0) {
- reply.status = ret;
- reply.errmsg = strerror(errno);
- } else {
- reply.status = 0;
- reply.errmsg = NULL;
+ pid_found = false;
+ srvid_found = false;
+
+ for (client=ctdb->client_list; client != NULL; client=client->next) {
+ if (client->pid == request->rdata.data.pid_srvid->pid) {
+ pid_found = true;
+ cstate = (struct client_state *)client->state;
+ ret = srvid_exists(ctdb->srv,
+ request->rdata.data.pid_srvid->srvid,
+ cstate);
+ if (ret == 0) {
+ srvid_found = true;
+ ret = kill(cstate->pid, 0);
+ if (ret != 0) {
+ reply.status = ret;
+ reply.errmsg = strerror(errno);
+ } else {
+ reply.status = 0;
+ reply.errmsg = NULL;
+ }
}
}
}
+ if (! pid_found) {
+ reply.status = -1;
+ reply.errmsg = "No client for PID";
+ } else if (! srvid_found) {
+ reply.status = -1;
+ reply.errmsg = "No client for PID and SRVID";
+ }
+
client_send_control(req, header, &reply);
}