ctdb-daemon: Move ctdb_init() to the only place it is used
authorMartin Schwenke <martin@meltin.net>
Wed, 18 Apr 2018 00:36:05 +0000 (10:36 +1000)
committerMartin Schwenke <martins@samba.org>
Tue, 1 May 2018 11:31:19 +0000 (13:31 +0200)
This used to be used by client code but not anymore, so move it to
where it is used.  Drop the comment because it is wrong.  Modernise
logging.

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

index e7f741927459e505f7ba4b747eeeb2625a624bcc..323df7f74743a4cb8c23ec34a4d20af060a2a04a 100644 (file)
@@ -238,11 +238,6 @@ int ctdb_ctrl_get_all_tunables(struct ctdb_context *ctdb,
                               struct timeval timeout, uint32_t destnode,
                               struct ctdb_tunable_list *tunables);
 
-/*
-  initialise ctdb subsystem
-*/
-struct ctdb_context *ctdb_init(struct tevent_context *ev);
-
 /*
   set some flags
 */
index 574e0e559a01530797e5ca32eeae8b6c3e885391..67c89dee3d08b9f596f0d84e52252161e43b202f 100644 (file)
@@ -1578,51 +1578,6 @@ int ctdb_ctrl_get_all_tunables(struct ctdb_context *ctdb,
        return 0;
 }
 
-/*
-  initialise the ctdb daemon for client applications
-
-  NOTE: In current code the daemon does not fork. This is for testing purposes only
-  and to simplify the code.
-*/
-struct ctdb_context *ctdb_init(struct tevent_context *ev)
-{
-       int ret;
-       struct ctdb_context *ctdb;
-
-       ctdb = talloc_zero(ev, struct ctdb_context);
-       if (ctdb == NULL) {
-               DEBUG(DEBUG_ERR,(__location__ " talloc_zero failed.\n"));
-               return NULL;
-       }
-       ctdb->ev  = ev;
-       /* Wrap early to exercise code. */
-       ret = reqid_init(ctdb, INT_MAX-200, &ctdb->idr);
-       if (ret != 0) {
-               DEBUG(DEBUG_ERR, ("reqid_init failed (%s)\n", strerror(ret)));
-               talloc_free(ctdb);
-               return NULL;
-       }
-
-       ret = srvid_init(ctdb, &ctdb->srv);
-       if (ret != 0) {
-               DEBUG(DEBUG_ERR, ("srvid_init failed (%s)\n", strerror(ret)));
-               talloc_free(ctdb);
-               return NULL;
-       }
-
-       ret = ctdb_set_socketname(ctdb, CTDB_SOCKET);
-       if (ret != 0) {
-               DEBUG(DEBUG_ERR,(__location__ " ctdb_set_socketname failed.\n"));
-               talloc_free(ctdb);
-               return NULL;
-       }
-
-       ctdb->statistics.statistics_start_time = timeval_current();
-
-       return ctdb;
-}
-
-
 /*
   set some ctdb flags
 */
index 7bbc547c1fde4c917347f51b3f4495fd9cddd2e0..2046f7a55bc3e042c9fdb1368c66b4ddceb16bbf 100644 (file)
@@ -95,6 +95,43 @@ static const struct ctdb_upcalls ctdb_upcalls = {
        .node_connected = ctdb_node_connected
 };
 
+static struct ctdb_context *ctdb_init(struct tevent_context *ev)
+{
+       int ret;
+       struct ctdb_context *ctdb;
+
+       ctdb = talloc_zero(ev, struct ctdb_context);
+       if (ctdb == NULL) {
+               DBG_ERR("Memory error\n");
+               return NULL;
+       }
+       ctdb->ev  = ev;
+       /* Wrap early to exercise code. */
+       ret = reqid_init(ctdb, INT_MAX-200, &ctdb->idr);
+       if (ret != 0) {
+               D_ERR("reqid_init failed (%s)\n", strerror(ret));
+               talloc_free(ctdb);
+               return NULL;
+       }
+
+       ret = srvid_init(ctdb, &ctdb->srv);
+       if (ret != 0) {
+               D_ERR("srvid_init failed (%s)\n", strerror(ret));
+               talloc_free(ctdb);
+               return NULL;
+       }
+
+       ret = ctdb_set_socketname(ctdb, CTDB_SOCKET);
+       if (ret != 0) {
+               DBG_ERR("ctdb_set_socketname failed.\n");
+               talloc_free(ctdb);
+               return NULL;
+       }
+
+       ctdb->statistics.statistics_start_time = timeval_current();
+
+       return ctdb;
+}
 
 
 /*