ctdb-daemon: Remove unused controls related to server_id
authorAmitay Isaacs <amitay@gmail.com>
Thu, 21 Apr 2016 05:18:33 +0000 (15:18 +1000)
committerMartin Schwenke <martins@samba.org>
Sat, 23 Apr 2016 21:55:14 +0000 (23:55 +0200)
These controls have never been used and also they do not use the server_id
structure defined in samba.  In future, similar controls can be added to
register/unregister using proper server_id structure.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/common/cmdline.c
ctdb/include/ctdb_private.h
ctdb/server/ctdb_control.c
ctdb/server/ctdb_serverids.c [deleted file]
ctdb/tests/src/ctdbd_test.c
ctdb/wscript

index 02083e88838a397ef91086f01ee3a10203a04928..3a4557eab1770f084c921c086d25f89cc231f967 100644 (file)
@@ -113,9 +113,6 @@ struct ctdb_context *ctdb_cmdline_init(struct tevent_context *ev)
                DEBUGLEVEL = debug_level_to_int(DEBUG_NOTICE);
        }
 
-       /* set up the tree to store server ids */
-       ctdb->server_ids = trbt_create(ctdb, 0);
-
        return ctdb;
 }
 
index b17af53e744ba728e94c75696e83e725642577a7..41b9f4f6ce92838302e8bc893639e317b5e48df4 100644 (file)
@@ -335,7 +335,6 @@ struct ctdb_context {
        uint32_t recovery_master;
        struct ctdb_client_ip *client_ip_list;
        bool do_checkpublicip;
-       struct trbt_tree *server_ids; 
        bool do_setsched;
        const char *event_script_dir;
        const char *notification_script;
index c795a3f9b84e77fda41394a4e437beed0d85e90f..9819176c97046ce8b0c569429d5a20d7c2dfd7a7 100644 (file)
@@ -418,21 +418,17 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
                /* data size is verified in the called function */
                return ctdb_control_set_tcp_tickle_list(ctdb, indata);
 
-       case CTDB_CONTROL_REGISTER_SERVER_ID: 
-               CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_client_id));
-               return ctdb_control_register_server_id(ctdb, client_id, indata);
+       case CTDB_CONTROL_REGISTER_SERVER_ID:
+               return control_not_implemented("REGISTER_SERVER_ID", NULL);
 
-       case CTDB_CONTROL_UNREGISTER_SERVER_ID: 
-               CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_client_id));
-               return ctdb_control_unregister_server_id(ctdb, indata);
+       case CTDB_CONTROL_UNREGISTER_SERVER_ID:
+               return control_not_implemented("UNREGISTER_SERVER_ID", NULL);
 
-       case CTDB_CONTROL_CHECK_SERVER_ID: 
-               CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_client_id));
-               return ctdb_control_check_server_id(ctdb, indata);
+       case CTDB_CONTROL_CHECK_SERVER_ID:
+               return control_not_implemented("CHECK_SERVER_ID", NULL);
 
        case CTDB_CONTROL_GET_SERVER_ID_LIST:
-               CHECK_CONTROL_DATA_SIZE(0);
-               return ctdb_control_get_server_id_list(ctdb, outdata);
+               return control_not_implemented("SERVER_ID_LIST", NULL);
 
        case CTDB_CONTROL_PERSISTENT_STORE:
                return control_not_implemented("PERSISTENT_STORE", NULL);
diff --git a/ctdb/server/ctdb_serverids.c b/ctdb/server/ctdb_serverids.c
deleted file mode 100644 (file)
index 11ee99b..0000000
+++ /dev/null
@@ -1,200 +0,0 @@
-/* 
-   ctdb_control protocol code to manage server ids
-
-   Copyright (C) Ronnie Sahlberg 2007
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-   
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-   
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, see <http://www.gnu.org/licenses/>.
-*/
-#include "replace.h"
-#include "system/network.h"
-
-#include <talloc.h>
-
-#include "lib/util/debug.h"
-
-#include "ctdb_private.h"
-
-#include "common/rb_tree.h"
-#include "common/reqid.h"
-#include "common/common.h"
-#include "common/logging.h"
-
-
-#define SERVER_ID_KEY_SIZE 3
-static uint32_t *get_server_id_key(struct ctdb_client_id *server_id)
-{
-       static uint32_t key[SERVER_ID_KEY_SIZE];
-
-       key[0] = server_id->type;
-       key[1] = server_id->pnn;
-       key[2] = server_id->server_id;
-
-       return &key[0];
-}
-
-/* add a server_id to the tree.
-   if we had already 'data' in the tree then this is a duplicate and we can
-   just talloc_free the structure in parm and leave data in the tree.
-   othervise if this is a new node we return parm and that is inserted
-   into the tree.
-*/
-static void *add_server_id_callback(void *parm, void *data)
-{
-       if (data) {
-               talloc_free(parm);
-               return data;
-       }
-       return parm;
-}
-
-/*
-  register a server id
-  a serverid that is registered with ctdb will be automatically unregistered
-  once the client domain socket dissappears.
- */
-int32_t ctdb_control_register_server_id(struct ctdb_context *ctdb, 
-                                uint32_t client_id,
-                                TDB_DATA indata)
-{
-       struct ctdb_client_id *server_id;
-       struct ctdb_client *client = reqid_find(ctdb->idr, client_id, struct ctdb_client);
-
-
-       if (client == NULL) {
-               DEBUG(DEBUG_ERR,(__location__ " Could not find client parent structure. You can not send this control to a remote node\n"));
-               return 1;
-       }
-
-       /* hang the server_id structure off client before storing it in the
-          tree so that is will be automatically destroyed when client
-          is destroyed. 
-          when the structure is free'd it will be automatically
-          removed from the tree
-       */
-       server_id = talloc_zero(client, struct ctdb_client_id);
-       CTDB_NO_MEMORY(ctdb, server_id);
-       memcpy(server_id, indata.dptr, sizeof(struct ctdb_client_id));
-
-       trbt_insertarray32_callback(ctdb->server_ids, SERVER_ID_KEY_SIZE,
-               get_server_id_key(server_id), 
-               add_server_id_callback, server_id);
-
-       return 0;
-}
-
-
-/*
-  check whether a server id exists
- */
-int32_t ctdb_control_check_server_id(struct ctdb_context *ctdb, 
-                                TDB_DATA indata)
-{
-       struct ctdb_client_id *server_id = (struct ctdb_client_id *)indata.dptr;
-
-       return trbt_lookuparray32(ctdb->server_ids, 
-                                 SERVER_ID_KEY_SIZE,
-                                 get_server_id_key(server_id)) == NULL? 0 : 1;
-}
-
-/*
-  unregisters a server id
- */
-int32_t ctdb_control_unregister_server_id(struct ctdb_context *ctdb, 
-                                TDB_DATA indata)
-{
-       struct ctdb_client_id *server_id = (struct ctdb_client_id *)indata.dptr;
-
-       talloc_free(trbt_lookuparray32(ctdb->server_ids, 
-                       SERVER_ID_KEY_SIZE,
-                       get_server_id_key(server_id)));
-       return 0;
-}
-
-
-
-
-struct count_server_ids {
-       int count;
-       struct ctdb_client_id_list_old *list;
-};
-
-static int server_id_count(void *param, void *data)
-{
-       struct count_server_ids *svid = talloc_get_type(param, 
-                                               struct count_server_ids);
-
-       if (svid == NULL) {
-               DEBUG(DEBUG_ERR, (__location__ " Got null pointer for svid\n"));
-               return -1;
-       }
-
-       svid->count++;
-       return 0;
-}
-
-static int server_id_store(void *param, void *data)
-{
-       struct count_server_ids *svid = talloc_get_type(param, 
-                                               struct count_server_ids);
-       struct ctdb_client_id *server_id = talloc_get_type(data,
-                                               struct ctdb_client_id);
-
-       if (svid == NULL) {
-               DEBUG(DEBUG_ERR, (__location__ " Got null pointer for svid\n"));
-               return -1;
-       }
-
-       if (svid->count >= svid->list->num) {
-               DEBUG(DEBUG_ERR, (__location__ " size of server id tree changed during traverse\n"));
-               return -1;
-       }
-
-       memcpy(&svid->list->server_ids[svid->count], server_id, sizeof(struct ctdb_client_id));
-       svid->count++;
-       return 0;
-}
-
-/* 
-   returns a list of all registered server ids for a node
-*/
-int32_t ctdb_control_get_server_id_list(struct ctdb_context *ctdb, TDB_DATA *outdata)
-{
-       struct count_server_ids *svid;
-
-
-       svid = talloc_zero(outdata, struct count_server_ids);
-       CTDB_NO_MEMORY(ctdb, svid);
-
-
-       /* first we must count how many entries we have */
-       trbt_traversearray32(ctdb->server_ids, SERVER_ID_KEY_SIZE,
-                       server_id_count, svid);
-
-
-       outdata->dsize = offsetof(struct ctdb_client_id_list_old, server_ids)
-                       + sizeof(struct ctdb_client_id) * svid->count;
-       outdata->dptr  = talloc_size(outdata, outdata->dsize);
-       CTDB_NO_MEMORY(ctdb, outdata->dptr);
-
-
-       /* now fill the structure in */
-       svid->list = (struct ctdb_client_id_list_old *)(outdata->dptr);
-       svid->list->num = svid->count;
-       svid->count=0;
-       trbt_traversearray32(ctdb->server_ids, SERVER_ID_KEY_SIZE,
-                       server_id_store, svid);
-
-
-       return 0;
-}
index 5fa70144ed4995dd4a547268b9f69d371ca7520d..77fac08a6ad70cbd09a59134e7cf1d53c3e4d135 100644 (file)
@@ -62,7 +62,6 @@ bool fast_start;
 #include "server/ipalloc_lcp2.c"
 #include "server/ipalloc.c"
 #include "server/ctdb_takeover.c"
-#include "server/ctdb_serverids.c"
 #include "server/ctdb_persistent.c"
 #include "server/ctdb_keepalive.c"
 #include "server/ctdb_logging.c"
index 55b50eda81958e8141cc6bfa70297969fe5fce83..d88fcfc9a13090365ac043fe4a39b34ae9d93938 100755 (executable)
@@ -392,7 +392,7 @@ def build(bld):
                                              ctdb_server.c ctdb_control.c
                                              ctdb_call.c ctdb_ltdb_server.c
                                              ctdb_traverse.c eventscript.c
-                                             ctdb_takeover.c ctdb_serverids.c
+                                             ctdb_takeover.c
                                              ctdb_persistent.c ctdb_keepalive.c
                                              ctdb_logging.c
                                              ctdb_logging_syslog.c