ctdbd_conn: remove ctdb_processes_exist
authorVolker Lendecke <vl@samba.org>
Mon, 11 Apr 2016 15:15:29 +0000 (17:15 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 17 May 2016 11:18:31 +0000 (13:18 +0200)
The singular call was the only user. Remove the complex plural one. We can
always dig it up from git history if we need it.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/include/ctdbd_conn.h
source3/lib/ctdb_dummy.c
source3/lib/ctdbd_conn.c

index c91f7008831860f0dd4cfb19ce60cfa76470d1bd..026db04babd074136a8af079cc2db14343611fc4 100644 (file)
@@ -49,9 +49,6 @@ int ctdbd_messaging_send_iov(struct ctdbd_connection *conn,
 
 bool ctdbd_process_exists(struct ctdbd_connection *conn, uint32_t vnn,
                          pid_t pid);
-bool ctdb_processes_exist(struct ctdbd_connection *conn,
-                         const struct server_id *pids, int num_pids,
-                         bool *results);
 
 char *ctdbd_dbpath(struct ctdbd_connection *conn,
                   TALLOC_CTX *mem_ctx, uint32_t db_id);
index 51622425067296147c67fae39c86a22b14370c7d..1a27b4909bf7d946ec644680a847f32469017686 100644 (file)
@@ -58,13 +58,6 @@ int ctdbd_register_ips(struct ctdbd_connection *conn,
        return ENOSYS;
 }
 
-bool ctdb_processes_exist(struct ctdbd_connection *conn,
-                         const struct server_id *pids, int num_pids,
-                         bool *results)
-{
-       return false;
-}
-
 bool ctdbd_process_exists(struct ctdbd_connection *conn, uint32_t vnn, pid_t pid)
 {
        return false;
index 9ea029a9b1400ae57ce6c443f32b47debae3dff8..f14a31af0e4e3209df6d5100e83974f09987a22d 100644 (file)
@@ -692,126 +692,17 @@ static int ctdbd_control(struct ctdbd_connection *conn,
  */
 bool ctdbd_process_exists(struct ctdbd_connection *conn, uint32_t vnn, pid_t pid)
 {
-       struct server_id id;
-       bool result;
-
-       id.pid = pid;
-       id.vnn = vnn;
+       int32_t cstatus = 0;
+       int ret;
 
-       if (!ctdb_processes_exist(conn, &id, 1, &result)) {
-               DEBUG(10, ("ctdb_processes_exist failed\n"));
+       ret = ctdbd_control(conn, vnn, CTDB_CONTROL_PROCESS_EXISTS, 0, 0,
+                           (TDB_DATA) { .dptr = (uint8_t *)&pid,
+                                        .dsize = sizeof(pid) },
+                           NULL, NULL, &cstatus);
+       if (ret != 0) {
                return false;
        }
-       return result;
-}
-
-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;
-       uint32_t *reqids;
-       bool result = false;
-
-       reqids = talloc_array(talloc_tos(), uint32_t, num_pids);
-       if (reqids == NULL) {
-               goto fail;
-       }
-
-       for (i=0; i<num_pids; i++) {
-               struct ctdb_req_control_old req;
-               pid_t pid;
-               struct iovec iov[2];
-               ssize_t nwritten;
-
-               results[i] = false;
-               reqids[i] = ctdbd_next_reqid(conn);
-
-               ZERO_STRUCT(req);
-
-               /*
-                * pids[i].pid is uint64_t, scale down to pid_t which
-                * is the wire protocol towards ctdb.
-                */
-               pid = pids[i].pid;
-
-               DEBUG(10, ("Requesting PID %d/%d, reqid=%d\n",
-                          (int)pids[i].vnn, (int)pid,
-                          (int)reqids[i]));
-
-               req.hdr.length = offsetof(struct ctdb_req_control_old, data);
-               req.hdr.length += sizeof(pid);
-               req.hdr.ctdb_magic   = CTDB_MAGIC;
-               req.hdr.ctdb_version = CTDB_PROTOCOL;
-               req.hdr.operation    = CTDB_REQ_CONTROL;
-               req.hdr.reqid        = reqids[i];
-               req.hdr.destnode     = pids[i].vnn;
-               req.opcode           = CTDB_CONTROL_PROCESS_EXISTS;
-               req.srvid            = 0;
-               req.datalen          = sizeof(pid);
-               req.flags            = 0;
-
-               DEBUG(10, ("ctdbd_control: Sending ctdb packet\n"));
-               ctdb_packet_dump(&req.hdr);
-
-               iov[0].iov_base = &req;
-               iov[0].iov_len = offsetof(struct ctdb_req_control_old, data);
-               iov[1].iov_base = &pid;
-               iov[1].iov_len = sizeof(pid);
-
-               nwritten = write_data_iov(conn->fd, iov, ARRAY_SIZE(iov));
-               if (nwritten == -1) {
-                       DEBUG(10, ("write_data_iov failed: %s\n",
-                                  strerror(errno)));
-                       goto fail;
-               }
-       }
-
-       num_received = 0;
-
-       while (num_received < num_pids) {
-               struct ctdb_req_header *hdr;
-               struct ctdb_reply_control_old *reply;
-               uint32_t reqid;
-               int ret;
-
-               ret = ctdb_read_req(conn, 0, talloc_tos(), &hdr);
-               if (ret != 0) {
-                       DEBUG(10, ("ctdb_read_req failed: %s\n",
-                                  strerror(ret)));
-                       goto fail;
-               }
-
-               if (hdr->operation != CTDB_REPLY_CONTROL) {
-                       DEBUG(10, ("Received invalid reply\n"));
-                       goto fail;
-               }
-               reply = (struct ctdb_reply_control_old *)hdr;
-
-               reqid = reply->hdr.reqid;
-
-               DEBUG(10, ("Received reqid %d\n", (int)reqid));
-
-               for (i=0; i<num_pids; i++) {
-                       if (reqid == reqids[i]) {
-                               break;
-                       }
-               }
-               if (i == num_pids) {
-                       DEBUG(10, ("Received unknown record number %u\n",
-                                  (unsigned)reqid));
-                       goto fail;
-               }
-               results[i] = ((reply->status) == 0);
-               TALLOC_FREE(reply);
-               num_received += 1;
-       }
-
-       result = true;
-fail:
-       TALLOC_FREE(frame);
-       return result;
+       return (cstatus == 0);
 }
 
 /*