/*
create a database
*/
-int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode,
- TALLOC_CTX *mem_ctx, const char *name, bool persistent)
+int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout,
+ uint32_t destnode,
+ const char *name, bool persistent)
{
int ret;
- int32_t res;
- TDB_DATA data;
+ ctdb_handle *handle;
- data.dptr = discard_const(name);
- data.dsize = strlen(name)+1;
+ handle = ctdb_createdb_send(ctdb, destnode, name, persistent, NULL, NULL);
+ if (handle == NULL) {
+ DEBUG(DEBUG_ERR, (__location__ " Failed to send createdb control\n"));
+ return -1;
+ }
- ret = ctdb_control(ctdb, destnode, 0,
- persistent?CTDB_CONTROL_DB_ATTACH_PERSISTENT:CTDB_CONTROL_DB_ATTACH,
- 0, data,
- mem_ctx, &data, &res, &timeout, NULL);
+ if (!timeval_is_zero(&timeout)) {
+ event_add_timed(ctdb->ev, handle, timeout, ctdb_control_timeout_func, handle);
+ }
- if (ret != 0 || res != 0) {
+ ret = ctdb_createdb_recv(ctdb, handle);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR,(__location__ " ctdb control for createdb failed\n"));
return -1;
}
data, NULL, NULL, &status, NULL, NULL);
if (ret != 0 || status != 0) {
DEBUG(DEBUG_ERR,("ctdb_traverse_all failed\n"));
- ctdb_remove_message_handler(ctdb_db->ctdb, srvid, &state);
+ ctdb_remove_message_handler(ctdb_db->ctdb, srvid);
return -1;
}
event_loop_once(ctdb_db->ctdb->ev);
}
- ret = ctdb_remove_message_handler(ctdb_db->ctdb, srvid, &state);
+ ret = ctdb_remove_message_handler(ctdb_db->ctdb, srvid);
if (ret != 0) {
DEBUG(DEBUG_ERR,("Failed to remove ctdb_traverse handler\n"));
return -1;
ret = ctdb_getpnn_recv(ctdb, handle, &pnn);
if (ret != 0) {
- DEBUG(DEBUG_ERR,(__location__ " ctdb_control for getpnn failed\n"));
+ DEBUG(DEBUG_ERR,(__location__ " ctdb control for getpnn failed\n"));
return -1;
}
ctdb_handle *
ctdb_createdb_send(struct ctdb_context *ctdb, uint32_t destnode,
- const char *name, bool persistent,
+ const char *name, int persistent,
ctdb_createdb_cb callback,
void *private_data);
int ctdb_createdb_recv(struct ctdb_context *ctdb,
ctdb_handle *handle);
int ctdb_createdb(struct ctdb_context *ctdb, uint32_t destnode,
- const char *name, bool persistent);
+ const char *name, int persistent);
uint32_t destnode,
uint32_t dbid, TALLOC_CTX *mem_ctx,
const char **reason);
-int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, TALLOC_CTX *mem_ctx, const char *name, bool persistent);
+int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, const char *name, bool persistent);
int ctdb_ctrl_process_exists(struct ctdb_context *ctdb, uint32_t destnode, pid_t pid);
ctdb_handle *
ctdb_createdb_send(struct ctdb_context *ctdb, uint32_t destnode,
- const char *name, bool persistent,
+ const char *name, int persistent,
ctdb_createdb_cb callback,
void *private_data)
return state->status;
}
-int ctdb_createdb(struct ctdb_context *ctdb, uint32_t destnode, const char *name, bool persistent)
+int ctdb_createdb(struct ctdb_context *ctdb, uint32_t destnode, const char *name, int persistent)
{
struct ctdb_client_control_state *state;
return -1;
}
ctdb_ctrl_createdb(ctdb, CONTROL_TIMEOUT(), nodemap->nodes[j].pnn,
- mem_ctx, name, dbmap->dbs[db].persistent);
+ name, dbmap->dbs[db].persistent);
if (ret != 0) {
DEBUG(DEBUG_ERR, (__location__ " Unable to create remote db:%s\n", name));
return -1;
nodemap->nodes[j].pnn));
return -1;
}
- ctdb_ctrl_createdb(ctdb, CONTROL_TIMEOUT(), pnn, mem_ctx, name,
+ ctdb_ctrl_createdb(ctdb, CONTROL_TIMEOUT(), pnn, name,
remote_dbmap->dbs[db].persistent);
if (ret != 0) {
DEBUG(DEBUG_ERR, (__location__ " Unable to create local db:%s\n", name));