summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2017-08-23 12:09:22 +1000
committerMartin Schwenke <martins@samba.org>2017-08-25 09:41:26 +0200
commit9987fe7209c3bd44ea0015d98d0f92b65ec70700 (patch)
treef5d999a0db9b49afb8effd639e0d0d1f5335b490
parent4bd0a20a75db3b3c409c25a4bc59aed30464f047 (diff)
downloadsamba-9987fe7209c3bd44ea0015d98d0f92b65ec70700.tar.gz
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>
-rw-r--r--ctdb/client/ctdb_client.c11
-rw-r--r--ctdb/include/ctdb_client.h2
-rw-r--r--ctdb/server/ctdb_recoverd.c4
3 files changed, 13 insertions, 4 deletions
diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c
index 74874bab2b2..05710c964fa 100644
--- a/ctdb/client/ctdb_client.c
+++ b/ctdb/client/ctdb_client.c
@@ -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,
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;
int32_t res;
@@ -1937,6 +1937,15 @@ int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout,
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;
}
diff --git a/ctdb/include/ctdb_client.h b/ctdb/include/ctdb_client.h
index 8aaf9c4d643..7314760fdc8 100644
--- a/ctdb/include/ctdb_client.h
+++ b/ctdb/include/ctdb_client.h
@@ -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,
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,
int32_t *level);
diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c
index 05aee463bef..386b72065e4 100644
--- a/ctdb/server/ctdb_recoverd.c
+++ b/ctdb/server/ctdb_recoverd.c
@@ -472,7 +472,7 @@ static int create_missing_remote_databases(struct ctdb_context *ctdb, struct ctd
ret = ctdb_ctrl_createdb(ctdb, CONTROL_TIMEOUT(),
nodemap->nodes[j].pnn,
mem_ctx, name,
- dbmap->dbs[db].flags);
+ dbmap->dbs[db].flags, NULL);
if (ret != 0) {
DEBUG(DEBUG_ERR, (__location__ " Unable to create remote db:%s\n", name));
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,
mem_ctx, name,
- remote_dbmap->dbs[db].flags);
+ remote_dbmap->dbs[db].flags, NULL);
if (ret != 0) {
DEBUG(DEBUG_ERR, (__location__ " Unable to create local db:%s\n", name));
return -1;