commit fc51256badca9685a016a5e9d956095e917437cd
Author: David Disseldorp <ddiss@suse.de>
Date:   Mon Aug 8 14:09:46 2011 +0200

    client: add req timeout argument to ctdb_cmdline_client
    
    Following connection to the local ctdbd, ctdb_cmdline_client() currently
    issues a CTDB_CONTROL_GET_PNN request with a fixed 3 second timeout.
    
    The ctdb cmd line client accepts a --timelimit argument for specifying
    a per request timeout, pass this value through to ctdb_cmdline_client()
    for use as a CTDB_CONTROL_GET_PNN request timeout.

diff --git a/common/cmdline.c b/common/cmdline.c
index 332a448..abf1adc 100644
--- a/common/cmdline.c
+++ b/common/cmdline.c
@@ -111,7 +111,8 @@ struct ctdb_context *ctdb_cmdline_init(struct event_context *ev)
 /*
   startup a client only ctdb context
  */
-struct ctdb_context *ctdb_cmdline_client(struct event_context *ev)
+struct ctdb_context *ctdb_cmdline_client(struct event_context *ev,
+					 struct timeval req_timeout)
 {
 	struct ctdb_context *ctdb;
 	char *socket_name;
@@ -152,7 +153,7 @@ struct ctdb_context *ctdb_cmdline_client(struct event_context *ev)
 	}
 
 	/* get our pnn */
-	ctdb->pnn = ctdb_ctrl_getpnn(ctdb, timeval_current_ofs(3, 0), CTDB_CURRENT_NODE);
+	ctdb->pnn = ctdb_ctrl_getpnn(ctdb, req_timeout, CTDB_CURRENT_NODE);
 	if (ctdb->pnn == (uint32_t)-1) {
 		DEBUG(DEBUG_CRIT,(__location__ " Failed to get ctdb pnn\n"));
 		talloc_free(ctdb);
diff --git a/include/ctdb.h b/include/ctdb.h
index a6cafe3..de44503 100644
--- a/include/ctdb.h
+++ b/include/ctdb.h
@@ -295,7 +295,8 @@ int ctdb_register_message_handler(struct ctdb_context *ctdb,
 struct ctdb_db_context *find_ctdb_db(struct ctdb_context *ctdb, uint32_t id);
 
 
-struct ctdb_context *ctdb_cmdline_client(struct event_context *ev);
+struct ctdb_context *ctdb_cmdline_client(struct event_context *ev,
+					 struct timeval req_timeout);
 
 struct ctdb_statistics;
 int ctdb_ctrl_statistics(struct ctdb_context *ctdb, uint32_t destnode, struct ctdb_statistics *status);
diff --git a/tests/src/ctdb_bench.c b/tests/src/ctdb_bench.c
index 52e5b50..c56aec1 100644
--- a/tests/src/ctdb_bench.c
+++ b/tests/src/ctdb_bench.c
@@ -217,7 +217,7 @@ int main(int argc, const char *argv[])
 	ev = event_context_init(NULL);
 
 	/* initialise ctdb */
-	ctdb = ctdb_cmdline_client(ev);
+	ctdb = ctdb_cmdline_client(ev, timeval_current_ofs(3, 0));
 
 	/* attach to a specific database */
 	ctdb_db = ctdb_attach(ctdb, "test.tdb", false, 0);
diff --git a/tests/src/ctdb_fetch.c b/tests/src/ctdb_fetch.c
index 35257e2..d0e78f1 100644
--- a/tests/src/ctdb_fetch.c
+++ b/tests/src/ctdb_fetch.c
@@ -207,7 +207,7 @@ int main(int argc, const char *argv[])
 
 	ev = event_context_init(NULL);
 
-	ctdb = ctdb_cmdline_client(ev);
+	ctdb = ctdb_cmdline_client(ev, timeval_current_ofs(3, 0));
 
 	if (ctdb == NULL) {
 		printf("failed to connect to ctdb daemon.\n");
diff --git a/tests/src/ctdb_fetch_one.c b/tests/src/ctdb_fetch_one.c
index ef0f9da..5fd9de9 100644
--- a/tests/src/ctdb_fetch_one.c
+++ b/tests/src/ctdb_fetch_one.c
@@ -114,7 +114,7 @@ int main(int argc, const char *argv[])
 
 	ev = event_context_init(NULL);
 
-	ctdb = ctdb_cmdline_client(ev);
+	ctdb = ctdb_cmdline_client(ev, timeval_current_ofs(3, 0));
 
 	if (ctdb == NULL) {
 		printf("failed to connect to ctdb deamon.\n");
diff --git a/tests/src/ctdb_persistent.c b/tests/src/ctdb_persistent.c
index 4a50aa7..85cd457 100644
--- a/tests/src/ctdb_persistent.c
+++ b/tests/src/ctdb_persistent.c
@@ -220,7 +220,7 @@ int main(int argc, const char *argv[])
 
 	ev = event_context_init(NULL);
 
-	ctdb = ctdb_cmdline_client(ev);
+	ctdb = ctdb_cmdline_client(ev, timeval_current_ofs(3, 0));
 	if (ctdb == NULL) {
 		printf("Could not attach to daemon\n");
 		return 1;
diff --git a/tests/src/ctdb_randrec.c b/tests/src/ctdb_randrec.c
index e281a85..8600bb3 100644
--- a/tests/src/ctdb_randrec.c
+++ b/tests/src/ctdb_randrec.c
@@ -181,7 +181,7 @@ int main(int argc, const char *argv[])
 
 	ev = event_context_init(NULL);
 
-	ctdb = ctdb_cmdline_client(ev);
+	ctdb = ctdb_cmdline_client(ev, timeval_current_ofs(3, 0));
 
 	if (ctdb == NULL) {
 		printf("failed to connect to daemon\n");
diff --git a/tests/src/ctdb_store.c b/tests/src/ctdb_store.c
index 9ab5525..e9d7aa0 100644
--- a/tests/src/ctdb_store.c
+++ b/tests/src/ctdb_store.c
@@ -136,7 +136,7 @@ int main(int argc, const char *argv[])
 
 	ev = event_context_init(NULL);
 
-	ctdb = ctdb_cmdline_client(ev);
+	ctdb = ctdb_cmdline_client(ev, timeval_current_ofs(3, 0));
 
 	if (ctdb == NULL) {
 		printf("failed to connect to ctdb daemon.\n");
diff --git a/tests/src/ctdb_transaction.c b/tests/src/ctdb_transaction.c
index b70621f..2c60b95 100644
--- a/tests/src/ctdb_transaction.c
+++ b/tests/src/ctdb_transaction.c
@@ -252,7 +252,7 @@ int main(int argc, const char *argv[])
 
 	ev = event_context_init(NULL);
 
-	ctdb = ctdb_cmdline_client(ev);
+	ctdb = ctdb_cmdline_client(ev, timeval_current_ofs(3, 0));
 	if (ctdb == NULL) {
 		DEBUG(DEBUG_ERR, ("Could not attach to daemon\n"));
 		return 1;
diff --git a/tests/src/ctdb_traverse.c b/tests/src/ctdb_traverse.c
index 1726b23..4616d01 100644
--- a/tests/src/ctdb_traverse.c
+++ b/tests/src/ctdb_traverse.c
@@ -89,7 +89,7 @@ int main(int argc, const char *argv[])
 
 	ev = event_context_init(NULL);
 
-	ctdb = ctdb_cmdline_client(ev);
+	ctdb = ctdb_cmdline_client(ev, timeval_current_ofs(3, 0));
 
 	/* attach to a specific database */
 	ctdb_db = ctdb_attach(ctdb, dbname, false, 0);
diff --git a/tools/ctdb.c b/tools/ctdb.c
index 09c849c..25a6165 100644
--- a/tools/ctdb.c
+++ b/tools/ctdb.c
@@ -4531,7 +4531,7 @@ int main(int argc, const char *argv[])
 			}
 
 			/* initialise ctdb */
-			ctdb = ctdb_cmdline_client(ev);
+			ctdb = ctdb_cmdline_client(ev, TIMELIMIT());
 
 			if (ctdb_commands[i].without_daemon == false) {
 				if (ctdb == NULL) {
