From: Martin Schwenke Date: Tue, 28 Aug 2018 22:23:51 +0000 (+1000) Subject: ctdb-tests: Use path_socket() in dummy client X-Git-Tag: tdb-1.3.17~906 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d246b1dadfca00e09bdd3d8bae2d03e108a70276;p=thirdparty%2Fsamba.git ctdb-tests: Use path_socket() in dummy client Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- 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 #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) {