1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

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 <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
Martin Schwenke 2018-04-18 10:36:05 +10:00 committed by Martin Schwenke
parent f4fe768ca3
commit 4eea531416
3 changed files with 37 additions and 50 deletions

View 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
*/

View 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
*/

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