From: Ronnie Sahlberg Date: Fri, 14 May 2010 03:13:49 +0000 (+1000) Subject: change ctdb_ctrl_attach to use the new libctdb versions to create the database X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=92953f7b0bee7f5312f5ef340a9638fbe4ba8f54;hp=016c664a1fe96c901b895c45934ede8200b9f2bb;p=sahlberg%2Fctdb.git change ctdb_ctrl_attach to use the new libctdb versions to create the database --- diff --git a/client/ctdb_client.c b/client/ctdb_client.c index 27f25ce1..14005bca 100644 --- a/client/ctdb_client.c +++ b/client/ctdb_client.c @@ -1032,9 +1032,9 @@ static int ctdb_fetch_func(struct ctdb_call_info *call) struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb, const char *name, bool persistent, uint32_t tdb_flags) { struct ctdb_db_context *ctdb_db; - TDB_DATA data; int ret; - int32_t res; + uint32_t db_id; + ctdb_handle *handle; ctdb_db = ctdb_db_handle(ctdb, name); if (ctdb_db) { @@ -1048,21 +1048,24 @@ struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb, const char *name, ctdb_db->db_name = talloc_strdup(ctdb_db, name); CTDB_NO_MEMORY_NULL(ctdb, ctdb_db->db_name); - data.dptr = discard_const(name); - data.dsize = strlen(name)+1; - /* tell ctdb daemon to attach */ - ret = ctdb_control(ctdb, CTDB_CURRENT_NODE, tdb_flags, - persistent?CTDB_CONTROL_DB_ATTACH_PERSISTENT:CTDB_CONTROL_DB_ATTACH, - 0, data, ctdb_db, &data, &res, NULL, NULL); - if (ret != 0 || res != 0 || data.dsize != sizeof(uint32_t)) { + handle = ctdb_createdb_send(ctdb, CTDB_CURRENT_NODE, + name, persistent, tdb_flags, + NULL, NULL); + if (handle == NULL) { + DEBUG(DEBUG_ERR, (__location__ " Failed to send CREATEDB control\n")); + talloc_free(ctdb_db); + return NULL; + } + + ret = ctdb_createdb_recv(ctdb, handle, &db_id); + if (ret != 0) { DEBUG(DEBUG_ERR,("Failed to attach to database '%s'\n", name)); talloc_free(ctdb_db); return NULL; } - ctdb_db->db_id = *(uint32_t *)data.dptr; - talloc_free(data.dptr); + ctdb_db->db_id = db_id; ret = ctdb_ctrl_getdbpath(ctdb, timeval_current_ofs(2, 0), CTDB_CURRENT_NODE, ctdb_db->db_id, ctdb_db, &ctdb_db->db_path); if (ret != 0) {