diff options
author | Martin Schwenke <martin@meltin.net> | 2018-08-29 08:23:51 +1000 |
---|---|---|
committer | Amitay Isaacs <amitay@samba.org> | 2018-11-06 07:16:14 +0100 |
commit | d246b1dadfca00e09bdd3d8bae2d03e108a70276 (patch) | |
tree | 824993038b1ecc13b6c6e125eb5641419a9ca7ca /ctdb/tests/src | |
parent | 3b1e5977d81a23553ce63e6aa3ee4c157b6f73dd (diff) | |
download | samba-d246b1dadfca00e09bdd3d8bae2d03e108a70276.tar.gz |
ctdb-tests: Use path_socket() in dummy client
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/tests/src')
-rw-r--r-- | ctdb/tests/src/dummy_client.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/ctdb/tests/src/dummy_client.c b/ctdb/tests/src/dummy_client.c index cc6444de968..22ba40f6e3b 100644 --- a/ctdb/tests/src/dummy_client.c +++ b/ctdb/tests/src/dummy_client.c @@ -25,6 +25,7 @@ #include <tevent.h> #include "common/logging.h" +#include "common/path.h" #include "client/client.h" @@ -64,24 +65,18 @@ int main(int argc, const char *argv[]) struct tevent_context *ev; struct ctdb_client_context **client; struct ctdb_client_context *last_client; - const char *ctdb_socket; poptContext pc; int opt, ret, i; int log_level; bool status, done; /* Set default options */ - options.sockpath = CTDB_SOCKET; + options.sockpath = NULL; options.debuglevel = "ERR"; options.num_connections = 1; options.timelimit = 60; options.srvidstr = NULL; - ctdb_socket = getenv("CTDB_SOCKET"); - if (ctdb_socket != NULL) { - options.sockpath = ctdb_socket; - } - pc = poptGetContext(argv[0], argc, argv, cmdline_options, POPT_CONTEXT_KEEP_FIRST); while ((opt = poptGetNextOpt(pc)) != -1) { @@ -89,12 +84,6 @@ int main(int argc, const char *argv[]) exit(1); } - if (options.sockpath == NULL) { - fprintf(stderr, "Please specify socket path\n"); - poptPrintHelp(pc, stdout, 0); - exit(1); - } - mem_ctx = talloc_new(NULL); if (mem_ctx == NULL) { fprintf(stderr, "Memory allocation error\n"); @@ -117,6 +106,14 @@ int main(int argc, const char *argv[]) setup_logging("dummy_client", DEBUG_STDERR); DEBUGLEVEL = log_level; + if (options.sockpath == NULL) { + options.sockpath = path_socket(mem_ctx, "ctdbd"); + if (options.sockpath == NULL) { + D_ERR("Memory allocation error\n"); + exit(1); + } + } + client = talloc_array(mem_ctx, struct ctdb_client_context *, options.num_connections); if (client == NULL) { |