From: Martin Schwenke Date: Wed, 18 Apr 2018 00:36:05 +0000 (+1000) Subject: ctdb-daemon: Move ctdb_init() to the only place it is used X-Git-Tag: ldb-1.4.0~482 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4eea531416ab0516f82bffa4f35345d8d0785d36;p=thirdparty%2Fsamba.git ctdb-daemon: Move ctdb_init() to the only place it is used 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 Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/include/ctdb_client.h b/ctdb/include/ctdb_client.h index e7f74192745..323df7f7474 100644 --- a/ctdb/include/ctdb_client.h +++ b/ctdb/include/ctdb_client.h @@ -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 */ diff --git a/ctdb/server/ctdb_client.c b/ctdb/server/ctdb_client.c index 574e0e559a0..67c89dee3d0 100644 --- a/ctdb/server/ctdb_client.c +++ b/ctdb/server/ctdb_client.c @@ -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 */ diff --git a/ctdb/server/ctdbd.c b/ctdb/server/ctdbd.c index 7bbc547c1fd..2046f7a55bc 100644 --- a/ctdb/server/ctdbd.c +++ b/ctdb/server/ctdbd.c @@ -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; +} /*