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.

Index: ctdb-1.0.114.6/common/cmdline.c
===================================================================
--- ctdb-1.0.114.6.orig/common/cmdline.c
+++ ctdb-1.0.114.6/common/cmdline.c
@@ -111,7 +111,8 @@ struct ctdb_context *ctdb_cmdline_init(s
 /*
   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
 	}
 
 	/* 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);
Index: ctdb-1.0.114.6/include/ctdb.h
===================================================================
--- ctdb-1.0.114.6.orig/include/ctdb.h
+++ ctdb-1.0.114.6/include/ctdb.h
@@ -295,7 +295,8 @@ int ctdb_register_message_handler(struct
 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);
Index: ctdb-1.0.114.6/tests/src/ctdb_bench.c
===================================================================
--- ctdb-1.0.114.6.orig/tests/src/ctdb_bench.c
+++ ctdb-1.0.114.6/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);
Index: ctdb-1.0.114.6/tests/src/ctdb_fetch.c
===================================================================
--- ctdb-1.0.114.6.orig/tests/src/ctdb_fetch.c
+++ ctdb-1.0.114.6/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");
Index: ctdb-1.0.114.6/tests/src/ctdb_fetch_one.c
===================================================================
--- ctdb-1.0.114.6.orig/tests/src/ctdb_fetch_one.c
+++ ctdb-1.0.114.6/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");
Index: ctdb-1.0.114.6/tests/src/ctdb_persistent.c
===================================================================
--- ctdb-1.0.114.6.orig/tests/src/ctdb_persistent.c
+++ ctdb-1.0.114.6/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;
Index: ctdb-1.0.114.6/tests/src/ctdb_randrec.c
===================================================================
--- ctdb-1.0.114.6.orig/tests/src/ctdb_randrec.c
+++ ctdb-1.0.114.6/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");
Index: ctdb-1.0.114.6/tests/src/ctdb_store.c
===================================================================
--- ctdb-1.0.114.6.orig/tests/src/ctdb_store.c
+++ ctdb-1.0.114.6/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");
Index: ctdb-1.0.114.6/tests/src/ctdb_transaction.c
===================================================================
--- ctdb-1.0.114.6.orig/tests/src/ctdb_transaction.c
+++ ctdb-1.0.114.6/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;
Index: ctdb-1.0.114.6/tests/src/ctdb_traverse.c
===================================================================
--- ctdb-1.0.114.6.orig/tests/src/ctdb_traverse.c
+++ ctdb-1.0.114.6/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);
Index: ctdb-1.0.114.6/tools/ctdb.c
===================================================================
--- ctdb-1.0.114.6.orig/tools/ctdb.c
+++ ctdb-1.0.114.6/tools/ctdb.c
@@ -4588,7 +4588,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) {
