]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-client: Remove client functions related to server_id
authorAmitay Isaacs <amitay@gmail.com>
Thu, 21 Apr 2016 05:22:47 +0000 (15:22 +1000)
committerMartin Schwenke <martins@samba.org>
Sat, 23 Apr 2016 21:55:14 +0000 (23:55 +0200)
These functions were used in the transaction code.  These controls did
not use server_id structure defined in samba, so samba would not use them.
Instead check if the process exists for conflicting g_lock entry.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/client/client.h
ctdb/client/client_control_sync.c
ctdb/client/ctdb_client.c
ctdb/include/ctdb_client.h

index 1060d2e175db41551a12956b06a12b62e476a3fd..e8288dc3f07ed19e8d03f53ff1f3adc86cf02e45 100644 (file)
@@ -397,29 +397,6 @@ int ctdb_ctrl_set_tcp_tickle_list(TALLOC_CTX *mem_ctx,
                                  int destnode, struct timeval timeout,
                                  struct ctdb_tickle_list *tickles);
 
-int ctdb_ctrl_register_server_id(TALLOC_CTX *mem_ctx,
-                                struct tevent_context *ev,
-                                struct ctdb_client_context *client,
-                                int destnode, struct timeval timeout,
-                                struct ctdb_client_id *cid);
-
-int ctdb_ctrl_unregister_server_id(TALLOC_CTX *mem_ctx,
-                                  struct tevent_context *ev,
-                                  struct ctdb_client_context *client,
-                                  int destnode, struct timeval timeout,
-                                  struct ctdb_client_id *cid);
-
-int ctdb_ctrl_check_server_id(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
-                             struct ctdb_client_context *client,
-                             int destnode, struct timeval timeout,
-                             struct ctdb_client_id *cid);
-
-int ctdb_ctrl_get_server_id_list(TALLOC_CTX *mem_ctx,
-                                struct tevent_context *ev,
-                                struct ctdb_client_context *client,
-                                int destnode, struct timeval timeout,
-                                struct ctdb_client_id_map **cid_map);
-
 int ctdb_ctrl_db_attach_persistent(TALLOC_CTX *mem_ctx,
                                   struct tevent_context *ev,
                                   struct ctdb_client_context *client,
index 2c71b36458ffe3c76f6c9f605ba60419a7273e73..e14b02c6b2c4f673b60ff34ebc70156416dfbdd1 100644 (file)
@@ -1145,125 +1145,6 @@ int ctdb_ctrl_set_tcp_tickle_list(TALLOC_CTX *mem_ctx,
        return 0;
 }
 
-int ctdb_ctrl_register_server_id(TALLOC_CTX *mem_ctx,
-                                struct tevent_context *ev,
-                                struct ctdb_client_context *client,
-                                int destnode, struct timeval timeout,
-                                struct ctdb_client_id *cid)
-{
-       struct ctdb_req_control request;
-       struct ctdb_reply_control *reply;
-       int ret;
-
-       ctdb_req_control_register_server_id(&request, cid);
-       ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
-                                 &request, &reply);
-       if (ret != 0) {
-               DEBUG(DEBUG_ERR,
-                     ("Control REGISTER_SERVER_ID failed to node %u, ret=%d\n",
-                      destnode, ret));
-               return ret;
-       }
-
-       ret = ctdb_reply_control_register_server_id(reply);
-       if (ret != 0) {
-               DEBUG(DEBUG_ERR,
-                     ("Control REGISTER_SERVER_ID failed, ret=%d\n", ret));
-               return ret;
-       }
-
-       return 0;
-}
-
-int ctdb_ctrl_unregister_server_id(TALLOC_CTX *mem_ctx,
-                                  struct tevent_context *ev,
-                                  struct ctdb_client_context *client,
-                                  int destnode, struct timeval timeout,
-                                  struct ctdb_client_id *cid)
-{
-       struct ctdb_req_control request;
-       struct ctdb_reply_control *reply;
-       int ret;
-
-       ctdb_req_control_unregister_server_id(&request, cid);
-       ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
-                                 &request, &reply);
-       if (ret != 0) {
-               DEBUG(DEBUG_ERR,
-                     ("Control UNREGISTER_SERVER_ID failed to node %u, ret=%d\n",
-                      destnode, ret));
-               return ret;
-       }
-
-       ret = ctdb_reply_control_unregister_server_id(reply);
-       if (ret != 0) {
-               DEBUG(DEBUG_ERR,
-                     ("Control UNREGISTER_SERVER_ID failed, ret=%d\n", ret));
-               return ret;
-       }
-
-       return 0;
-}
-
-int ctdb_ctrl_check_server_id(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
-                             struct ctdb_client_context *client,
-                             int destnode, struct timeval timeout,
-                             struct ctdb_client_id *cid)
-{
-       struct ctdb_req_control request;
-       struct ctdb_reply_control *reply;
-       int ret;
-
-       ctdb_req_control_check_server_id(&request, cid);
-       ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
-                                 &request, &reply);
-       if (ret != 0) {
-               DEBUG(DEBUG_ERR,
-                     ("Control CHECK_SERVER_ID failed to node %u, ret=%d\n",
-                      destnode, ret));
-               return ret;
-       }
-
-       ret = ctdb_reply_control_check_server_id(reply);
-       if (ret != 0) {
-               DEBUG(DEBUG_ERR,
-                     ("Control CHECK_SERVER_ID failed, ret=%d\n", ret));
-               return ret;
-       }
-
-       return 0;
-}
-
-int ctdb_ctrl_get_server_id_list(TALLOC_CTX *mem_ctx,
-                                struct tevent_context *ev,
-                                struct ctdb_client_context *client,
-                                int destnode, struct timeval timeout,
-                                struct ctdb_client_id_map **cid_map)
-{
-       struct ctdb_req_control request;
-       struct ctdb_reply_control *reply;
-       int ret;
-
-       ctdb_req_control_get_server_id_list(&request);
-       ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
-                                 &request, &reply);
-       if (ret != 0) {
-               DEBUG(DEBUG_ERR,
-                     ("Control GET_SERVER_ID_LIST failed to node %u, ret=%d\n",
-                      destnode, ret));
-               return ret;
-       }
-
-       ret = ctdb_reply_control_get_server_id_list(reply, mem_ctx, cid_map);
-       if (ret != 0) {
-               DEBUG(DEBUG_ERR,
-                     ("Control GET_SERVER_ID_LIST failed, ret=%d\n", ret));
-               return ret;
-       }
-
-       return 0;
-}
-
 int ctdb_ctrl_db_attach_persistent(TALLOC_CTX *mem_ctx,
                                   struct tevent_context *ev,
                                   struct ctdb_client_context *client,
index aae3853ed487de3c7d120ea8699a7f161204d0fc..19f126ce87142772f35b82a3c1796b3de8f78451 100644 (file)
@@ -3171,117 +3171,6 @@ int ctdb_ctrl_get_tcp_tickles(struct ctdb_context *ctdb,
        return status;
 }
 
-/*
-  register a server id
- */
-int ctdb_ctrl_register_server_id(struct ctdb_context *ctdb,
-                                struct timeval timeout,
-                                struct ctdb_client_id *id)
-{
-       TDB_DATA data;
-       int32_t res;
-       int ret;
-
-       data.dsize = sizeof(struct ctdb_client_id);
-       data.dptr  = (unsigned char *)id;
-
-       ret = ctdb_control(ctdb, CTDB_CURRENT_NODE, 0, 
-                       CTDB_CONTROL_REGISTER_SERVER_ID, 
-                       0, data, NULL,
-                       NULL, &res, &timeout, NULL);
-       if (ret != 0 || res != 0) {
-               DEBUG(DEBUG_ERR,(__location__ " ctdb_control for register server id failed\n"));
-               return -1;
-       }
-
-       return 0;
-}
-
-/*
-  unregister a server id
- */
-int ctdb_ctrl_unregister_server_id(struct ctdb_context *ctdb,
-                                  struct timeval timeout,
-                                  struct ctdb_client_id *id)
-{
-       TDB_DATA data;
-       int32_t res;
-       int ret;
-
-       data.dsize = sizeof(struct ctdb_client_id);
-       data.dptr  = (unsigned char *)id;
-
-       ret = ctdb_control(ctdb, CTDB_CURRENT_NODE, 0, 
-                       CTDB_CONTROL_UNREGISTER_SERVER_ID, 
-                       0, data, NULL,
-                       NULL, &res, &timeout, NULL);
-       if (ret != 0 || res != 0) {
-               DEBUG(DEBUG_ERR,(__location__ " ctdb_control for unregister server id failed\n"));
-               return -1;
-       }
-
-       return 0;
-}
-
-
-/*
-  check if a server id exists
-
-  if a server id does exist, return *status == 1, otherwise *status == 0
- */
-int ctdb_ctrl_check_server_id(struct ctdb_context *ctdb,
-                             struct timeval timeout, uint32_t destnode,
-                             struct ctdb_client_id *id, uint32_t *status)
-{
-       TDB_DATA data;
-       int32_t res;
-       int ret;
-
-       data.dsize = sizeof(struct ctdb_client_id);
-       data.dptr  = (unsigned char *)id;
-
-       ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_CHECK_SERVER_ID, 
-                       0, data, NULL,
-                       NULL, &res, &timeout, NULL);
-       if (ret != 0) {
-               DEBUG(DEBUG_ERR,(__location__ " ctdb_control for check server id failed\n"));
-               return -1;
-       }
-
-       if (res) {
-               *status = 1;
-       } else {
-               *status = 0;
-       }
-
-       return 0;
-}
-
-/*
-   get the list of server ids that are registered on a node
-*/
-int ctdb_ctrl_get_server_id_list(struct ctdb_context *ctdb,
-                                TALLOC_CTX *mem_ctx,
-                                struct timeval timeout, uint32_t destnode,
-                                struct ctdb_client_id_list_old **svid_list)
-{
-       int ret;
-       TDB_DATA outdata;
-       int32_t res;
-
-       ret = ctdb_control(ctdb, destnode, 0, 
-                          CTDB_CONTROL_GET_SERVER_ID_LIST, 0, tdb_null, 
-                          mem_ctx, &outdata, &res, &timeout, NULL);
-       if (ret != 0 || res != 0) {
-               DEBUG(DEBUG_ERR,(__location__ " ctdb_control for get_server_id_list failed\n"));
-               return -1;
-       }
-
-       *svid_list = (struct ctdb_client_id_list_old *)talloc_steal(mem_ctx, outdata.dptr);
-
-       return 0;
-}
-
 /*
   initialise the ctdb daemon for client applications
 
@@ -3832,24 +3721,13 @@ static bool ctdb_server_id_equal(struct ctdb_server_id *id1, struct ctdb_server_
        return true;
 }
 
-static bool server_id_exists(struct ctdb_context *ctdb, struct ctdb_server_id *id)
+static bool server_id_exists(struct ctdb_context *ctdb,
+                            struct ctdb_server_id *id)
 {
-       struct ctdb_client_id sid;
        int ret;
-       uint32_t result = 0;
-
-       sid.type = SERVER_TYPE_SAMBA;
-       sid.pnn = id->vnn;
-       sid.server_id = id->pid;
 
-       ret = ctdb_ctrl_check_server_id(ctdb, timeval_current_ofs(3,0),
-                                       id->vnn, &sid, &result);
-       if (ret != 0) {
-               /* If control times out, assume server_id exists. */
-               return true;
-       }
-
-       if (result) {
+       ret = ctdb_ctrl_process_exists(ctdb, id->vnn, id->pid);
+       if (ret == 0) {
                return true;
        }
 
@@ -4079,7 +3957,6 @@ struct ctdb_transaction_handle *ctdb_transaction_start(struct ctdb_db_context *c
                                                       TALLOC_CTX *mem_ctx)
 {
        struct ctdb_transaction_handle *h;
-       struct ctdb_client_id id;
 
        h = talloc_zero(mem_ctx, struct ctdb_transaction_handle);
        if (h == NULL) {
@@ -4104,17 +3981,6 @@ struct ctdb_transaction_handle *ctdb_transaction_start(struct ctdb_db_context *c
                return NULL;
        }
 
-       id.type = SERVER_TYPE_SAMBA;
-       id.pnn = ctdb_get_pnn(ctdb_db->ctdb);
-       id.server_id = getpid();
-
-       if (ctdb_ctrl_register_server_id(ctdb_db->ctdb, timeval_current_ofs(3,0),
-                                        &id) != 0) {
-               DEBUG(DEBUG_ERR, (__location__ " unable to register server id\n"));
-               talloc_free(h);
-               return NULL;
-       }
-
        h->reqid = reqid_new(h->ctdb_db->ctdb->idr, h);
 
        if (!g_lock_lock(h, h->g_lock_db, h->lock_name, h->reqid)) {
index 08ba9206c52f6068fc3bfcc69786eb0027644b39..a39d09693bc8dc31d466ae2f5be114ba72b2fd97 100644 (file)
@@ -415,20 +415,6 @@ int ctdb_ctrl_get_tcp_tickles(struct ctdb_context *ctdb,
                              TALLOC_CTX *mem_ctx, ctdb_sock_addr *addr,
                              struct ctdb_tickle_list_old **list);
 
-int ctdb_ctrl_register_server_id(struct ctdb_context *ctdb,
-                                struct timeval timeout,
-                                struct ctdb_client_id *id);
-int ctdb_ctrl_unregister_server_id(struct ctdb_context *ctdb,
-                                  struct timeval timeout,
-                                  struct ctdb_client_id *id);
-int ctdb_ctrl_check_server_id(struct ctdb_context *ctdb,
-                             struct timeval timeout, uint32_t destnode,
-                             struct ctdb_client_id *id, uint32_t *status);
-int ctdb_ctrl_get_server_id_list(struct ctdb_context *ctdb,
-                                TALLOC_CTX *mem_ctx,
-                                struct timeval timeout, uint32_t destnode,
-                                struct ctdb_client_id_list_old **svid_list);
-
 /*
   initialise ctdb subsystem
 */