mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
ctdb-tests: Implement control CHECK_PID_SRVID in fake daemon
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>
This commit is contained in:
parent
c480cc0152
commit
7d034fe139
@ -1651,9 +1651,6 @@ static void control_deregister_srvid(TALLOC_CTX *mem_ctx,
|
||||
reply.status = 0;
|
||||
reply.errmsg = NULL;
|
||||
|
||||
client_send_control(req, header, &reply);
|
||||
return;
|
||||
|
||||
fail:
|
||||
client_send_control(req, header, &reply);
|
||||
}
|
||||
@ -2787,6 +2784,46 @@ fail:
|
||||
client_send_control(req, header, &reply);
|
||||
}
|
||||
|
||||
static void control_check_pid_srvid(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_req *req,
|
||||
struct ctdb_req_header *header,
|
||||
struct ctdb_req_control *request)
|
||||
{
|
||||
struct client_state *state = tevent_req_data(
|
||||
req, struct client_state);
|
||||
struct ctdbd_context *ctdb = state->ctdb;
|
||||
struct client_state *cstate;
|
||||
struct ctdb_reply_control reply;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
client_send_control(req, header, &reply);
|
||||
}
|
||||
|
||||
static bool fake_control_failure(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_req *req,
|
||||
struct ctdb_req_header *header,
|
||||
@ -3376,6 +3413,10 @@ static void client_process_control(struct tevent_req *req,
|
||||
control_get_nodes_file(mem_ctx, req, &header, &request);
|
||||
break;
|
||||
|
||||
case CTDB_CONTROL_CHECK_PID_SRVID:
|
||||
control_check_pid_srvid(mem_ctx, req, &header, &request);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (! (request.flags & CTDB_CTRL_FLAG_NOREPLY)) {
|
||||
control_error(mem_ctx, req, &header, &request);
|
||||
|
Loading…
Reference in New Issue
Block a user