From 1c4fe3903333e9fa24c375c95cfc52a608f9b27b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 23 Oct 2011 21:38:54 +0200 Subject: s3-ctdb: Add ctdb_processes_exist This sends out a number of process_exists controls in parallel and collects the replies as they come in. --- source3/lib/ctdbd_conn.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) (limited to 'source3/lib/ctdbd_conn.c') diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index f94860a762..f172bdfed4 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -932,6 +932,104 @@ bool ctdbd_process_exists(struct ctdbd_connection *conn, uint32 vnn, pid_t pid) return cstatus == 0; } +bool ctdb_processes_exist(struct ctdbd_connection *conn, + const struct server_id *pids, int num_pids, + bool *results) +{ + TALLOC_CTX *frame = talloc_stackframe(); + int i, num_received; + NTSTATUS status; + uint32_t *reqids; + bool result = false; + + reqids = talloc_array(talloc_tos(), uint32_t, num_pids); + if (reqids == NULL) { + goto fail; + } + + for (i=0; ipkt, 2, + data_blob_const( + &req, offsetof(struct ctdb_req_control, data)), + data_blob_const(&pids[i].pid, sizeof(pids[i].pid))); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("ctdb_packet_send failed: %s\n", + nt_errstr(status))); + goto fail; + } + } + + status = ctdb_packet_flush(conn->pkt); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("ctdb_packet_flush failed: %s\n", + nt_errstr(status))); + goto fail; + } + + num_received = 0; + + while (num_received < num_pids) { + struct ctdb_reply_control *reply = NULL; + uint32_t reqid; + + status = ctdb_read_req(conn, 0, talloc_tos(), (void *)&reply); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(10, ("ctdb_read_req failed: %s\n", + nt_errstr(status))); + goto fail; + } + + if (reply->hdr.operation != CTDB_REPLY_CONTROL) { + DEBUG(10, ("Received invalid reply\n")); + goto fail; + } + + reqid = reply->hdr.reqid; + + for (i=0; istatus) == 0); + TALLOC_FREE(reply); + num_received += 1; + } + + result = true; +fail: + TALLOC_FREE(frame); + return result; +} + /* * Get a db path */ -- cgit