1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-26 21:57:41 +03:00

ctdb-client: Optionally return database id from ctdb_ctrl_createdb()

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12978

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
Amitay Isaacs 2017-08-23 12:09:22 +10:00 committed by Martin Schwenke
parent 4bd0a20a75
commit 9987fe7209
3 changed files with 13 additions and 4 deletions

View File

@ -1912,7 +1912,7 @@ int ctdb_ctrl_getdbseqnum(struct ctdb_context *ctdb, struct timeval timeout,
*/ */
int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout, int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout,
uint32_t destnode, TALLOC_CTX *mem_ctx, uint32_t destnode, TALLOC_CTX *mem_ctx,
const char *name, uint8_t db_flags) const char *name, uint8_t db_flags, uint32_t *db_id)
{ {
int ret; int ret;
int32_t res; int32_t res;
@ -1937,6 +1937,15 @@ int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout,
return -1; return -1;
} }
if (data.dsize != sizeof(uint32_t)) {
TALLOC_FREE(data.dptr);
return -1;
}
if (db_id != NULL) {
*db_id = *(uint32_t *)data.dptr;
}
talloc_free(data.dptr);
return 0; return 0;
} }

View File

@ -251,7 +251,7 @@ int ctdb_ctrl_getdbseqnum(struct ctdb_context *ctdb, struct timeval timeout,
int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout, int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout,
uint32_t destnode, TALLOC_CTX *mem_ctx, uint32_t destnode, TALLOC_CTX *mem_ctx,
const char *name, uint8_t db_flags); const char *name, uint8_t db_flags, uint32_t *db_id);
int ctdb_ctrl_get_debuglevel(struct ctdb_context *ctdb, uint32_t destnode, int ctdb_ctrl_get_debuglevel(struct ctdb_context *ctdb, uint32_t destnode,
int32_t *level); int32_t *level);

View File

@ -472,7 +472,7 @@ static int create_missing_remote_databases(struct ctdb_context *ctdb, struct ctd
ret = ctdb_ctrl_createdb(ctdb, CONTROL_TIMEOUT(), ret = ctdb_ctrl_createdb(ctdb, CONTROL_TIMEOUT(),
nodemap->nodes[j].pnn, nodemap->nodes[j].pnn,
mem_ctx, name, mem_ctx, name,
dbmap->dbs[db].flags); dbmap->dbs[db].flags, NULL);
if (ret != 0) { if (ret != 0) {
DEBUG(DEBUG_ERR, (__location__ " Unable to create remote db:%s\n", name)); DEBUG(DEBUG_ERR, (__location__ " Unable to create remote db:%s\n", name));
return -1; return -1;
@ -536,7 +536,7 @@ static int create_missing_local_databases(struct ctdb_context *ctdb, struct ctdb
} }
ctdb_ctrl_createdb(ctdb, CONTROL_TIMEOUT(), pnn, ctdb_ctrl_createdb(ctdb, CONTROL_TIMEOUT(), pnn,
mem_ctx, name, mem_ctx, name,
remote_dbmap->dbs[db].flags); remote_dbmap->dbs[db].flags, NULL);
if (ret != 0) { if (ret != 0) {
DEBUG(DEBUG_ERR, (__location__ " Unable to create local db:%s\n", name)); DEBUG(DEBUG_ERR, (__location__ " Unable to create local db:%s\n", name));
return -1; return -1;