summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2011-11-29 14:38:39 +1100
committerMartin Schwenke <martin@meltin.net>2011-12-06 13:59:32 +1100
commitba6e6f689c30f30cd66c7b46741fe35918c745ad (patch)
tree83eb66feaf3bd6851fc7008b3ba70064482099c7
parent7e9f998745765372e8b5fa0f8ab930d75b23a6b5 (diff)
downloadsamba-ba6e6f689c30f30cd66c7b46741fe35918c745ad.tar.gz
samba-ba6e6f689c30f30cd66c7b46741fe35918c745ad.tar.xz
samba-ba6e6f689c30f30cd66c7b46741fe35918c745ad.zip
ctdb tool - short circuit most of the logic in main for non-daemon commands
This allows all that logic to be hacked a little more easily. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit f93ffeee7b9e9ca5dd116655bdc7f89fc987ed8a)
-rw-r--r--ctdb/tools/ctdb.c46
1 files changed, 22 insertions, 24 deletions
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index f48217b8da..f7f683642d 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -5265,6 +5265,7 @@ int main(int argc, const char *argv[])
poptContext pc;
struct event_context *ev;
const char *control;
+ const char *socket_name;
setlinebuf(stdout);
@@ -5344,39 +5345,36 @@ int main(int argc, const char *argv[])
exit(1);
}
close(2);
+ return ctdb_commands[i].fn(NULL, extra_argc-1, extra_argv+1);
}
/* initialise ctdb */
ctdb = ctdb_cmdline_client(ev, TIMELIMIT());
- if (ctdb_commands[i].without_daemon == false) {
- const char *socket_name;
-
- if (ctdb == NULL) {
- DEBUG(DEBUG_ERR, ("Failed to init ctdb\n"));
- exit(1);
- }
+ if (ctdb == NULL) {
+ DEBUG(DEBUG_ERR, ("Failed to init ctdb\n"));
+ exit(1);
+ }
- /* initialize a libctdb connection as well */
- socket_name = ctdb_get_socketname(ctdb);
- ctdb_connection = ctdb_connect(socket_name,
- ctdb_log_file, stderr);
- if (ctdb_connection == NULL) {
- fprintf(stderr, "Failed to connect to daemon from libctdb\n");
- exit(1);
- }
+ /* initialize a libctdb connection as well */
+ socket_name = ctdb_get_socketname(ctdb);
+ ctdb_connection = ctdb_connect(socket_name,
+ ctdb_log_file, stderr);
+ if (ctdb_connection == NULL) {
+ fprintf(stderr, "Failed to connect to daemon from libctdb\n");
+ exit(1);
+ }
- /* verify the node exists */
- verify_node(ctdb);
+ /* verify the node exists */
+ verify_node(ctdb);
- if (options.pnn == CTDB_CURRENT_NODE) {
- int pnn;
- pnn = ctdb_ctrl_getpnn(ctdb, TIMELIMIT(), options.pnn);
- if (pnn == -1) {
- return -1;
- }
- options.pnn = pnn;
+ if (options.pnn == CTDB_CURRENT_NODE) {
+ int pnn;
+ pnn = ctdb_ctrl_getpnn(ctdb, TIMELIMIT(), options.pnn);
+ if (pnn == -1) {
+ return -1;
}
+ options.pnn = pnn;
}
if (ctdb_commands[i].auto_all &&