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; +} /*