summaryrefslogtreecommitdiffstats
path: root/ctdb
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2014-08-13 14:46:31 +1000
committerAmitay Isaacs <amitay@samba.org>2014-09-12 08:46:14 +0200
commit2e17b0ecddffb8590c4e8b9afaf1767ef7e8f89c (patch)
tree616eab73014d6dca0fab2ce31110e14f574ed4c5 /ctdb
parent8c1b1435fe102d36fbea54a941b04570d529a44c (diff)
downloadsamba-2e17b0ecddffb8590c4e8b9afaf1767ef7e8f89c.tar.gz
samba-2e17b0ecddffb8590c4e8b9afaf1767ef7e8f89c.tar.xz
samba-2e17b0ecddffb8590c4e8b9afaf1767ef7e8f89c.zip
ctdb-locking: Add argc parameter to lock_helper_args()
To make this sane, also add an argv parameter and change the return type to bool. Anticipating a subsequent change, make the type of argv match what is needed by vfork_with_logging() and cast it when passing to execv(). This also means changing the type of the name member of struct db_namelist. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/server/ctdb_lock.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/ctdb/server/ctdb_lock.c b/ctdb/server/ctdb_lock.c
index e1a9fed772..47bba74e8b 100644
--- a/ctdb/server/ctdb_lock.c
+++ b/ctdb/server/ctdb_lock.c
@@ -549,7 +549,7 @@ static int db_count_handler(struct ctdb_db_context *ctdb_db, uint32_t priority,
}
struct db_namelist {
- char **names;
+ const char **names;
int n;
};
@@ -564,10 +564,12 @@ static int db_name_handler(struct ctdb_db_context *ctdb_db, uint32_t priority,
return 0;
}
-static char **lock_helper_args(TALLOC_CTX *mem_ctx, struct lock_context *lock_ctx, int fd)
+static bool lock_helper_args(TALLOC_CTX *mem_ctx,
+ struct lock_context *lock_ctx, int fd,
+ int *argc, const char ***argv)
{
struct ctdb_context *ctdb = lock_ctx->ctdb;
- char **args = NULL;
+ const char **args = NULL;
int nargs, i;
int priority;
struct db_namelist list;
@@ -597,9 +599,9 @@ static char **lock_helper_args(TALLOC_CTX *mem_ctx, struct lock_context *lock_ct
/* Add extra argument for null termination */
nargs++;
- args = talloc_array(mem_ctx, char *, nargs);
+ args = talloc_array(mem_ctx, const char *, nargs);
if (args == NULL) {
- return NULL;
+ return false;
}
args[0] = talloc_strdup(args, "ctdb_lock_helper");
@@ -645,11 +647,13 @@ static char **lock_helper_args(TALLOC_CTX *mem_ctx, struct lock_context *lock_ct
for (i=0; i<nargs-1; i++) {
if (args[i] == NULL) {
talloc_free(args);
- return NULL;
+ return false;
}
}
- return args;
+ *argc = nargs;
+ *argv = args;
+ return true;
}
/*
@@ -718,11 +722,11 @@ static struct lock_context *ctdb_find_lock_context(struct ctdb_context *ctdb)
static void ctdb_lock_schedule(struct ctdb_context *ctdb)
{
struct lock_context *lock_ctx;
- int ret;
+ int ret, argc;
TALLOC_CTX *tmp_ctx;
const char *helper = BINDIR "/ctdb_lock_helper";
static const char *prog = NULL;
- char **args;
+ const char **args;
if (prog == NULL) {
const char *t;
@@ -761,8 +765,8 @@ static void ctdb_lock_schedule(struct ctdb_context *ctdb)
}
/* Create arguments for lock helper */
- args = lock_helper_args(tmp_ctx, lock_ctx, lock_ctx->fd[1]);
- if (args == NULL) {
+ if (!lock_helper_args(tmp_ctx, lock_ctx, lock_ctx->fd[1],
+ &argc, &args)) {
DEBUG(DEBUG_ERR, ("Failed to create lock helper args\n"));
close(lock_ctx->fd[0]);
close(lock_ctx->fd[1]);
@@ -783,7 +787,7 @@ static void ctdb_lock_schedule(struct ctdb_context *ctdb)
/* Child process */
if (lock_ctx->child == 0) {
- ret = execv(prog, args);
+ ret = execv(prog, (char * const*) args);
if (ret < 0) {
DEBUG(DEBUG_ERR, ("Failed to execute helper %s (%d, %s)\n",
prog, errno, strerror(errno)));