commit 66a9e15fffca15357c25040490959a817862f3ef
Author: David Disseldorp <ddiss@suse.de>
Date:   Mon Aug 8 16:35:56 2011 +0200

    client: add timeout argument to ctdb_attach
    
    Rather than using a fixed 2 second CTDB_CONTROL_GETDBPATH timeout.

Index: ctdb-1.0.114.6/client/ctdb_client.c
===================================================================
--- ctdb-1.0.114.6.orig/client/ctdb_client.c
+++ ctdb-1.0.114.6/client/ctdb_client.c
@@ -1706,7 +1706,11 @@ static int ctdb_fetch_func(struct ctdb_c
 /*
   attach to a specific database - client call
 */
-struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb, const char *name, bool persistent, uint32_t tdb_flags)
+struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb,
+				    struct timeval timeout,
+				    const char *name,
+				    bool persistent,
+				    uint32_t tdb_flags)
 {
 	struct ctdb_db_context *ctdb_db;
 	TDB_DATA data;
@@ -1741,7 +1745,7 @@ struct ctdb_db_context *ctdb_attach(stru
 	ctdb_db->db_id = *(uint32_t *)data.dptr;
 	talloc_free(data.dptr);
 
-	ret = ctdb_ctrl_getdbpath(ctdb, timeval_current_ofs(2, 0), CTDB_CURRENT_NODE, ctdb_db->db_id, ctdb_db, &ctdb_db->db_path);
+	ret = ctdb_ctrl_getdbpath(ctdb, timeout, CTDB_CURRENT_NODE, ctdb_db->db_id, ctdb_db, &ctdb_db->db_path);
 	if (ret != 0) {
 		DEBUG(DEBUG_ERR,("Failed to get dbpath for database '%s'\n", name));
 		talloc_free(ctdb_db);
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
@@ -214,7 +214,11 @@ int ctdb_start_daemon(struct ctdb_contex
 /*
   attach to a ctdb database
 */
-struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb, const char *name, bool persistent, uint32_t tdb_flags);
+struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb,
+				    struct timeval timeout,
+				    const char *name,
+				    bool persistent,
+				    uint32_t tdb_flags);
 
 /*
   find an attached ctdb_db handle given a name
Index: ctdb-1.0.114.6/server/ctdb_recoverd.c
===================================================================
--- ctdb-1.0.114.6.orig/server/ctdb_recoverd.c
+++ ctdb-1.0.114.6/server/ctdb_recoverd.c
@@ -844,7 +844,7 @@ static void vacuum_fetch_handler(struct
 	}
 
 	/* attach to it */
-	ctdb_db = ctdb_attach(ctdb, name, persistent, 0);
+	ctdb_db = ctdb_attach(ctdb, CONTROL_TIMEOUT(), name, persistent, 0);
 	if (ctdb_db == NULL) {
 		DEBUG(DEBUG_ERR,(__location__ " Failed to attach to database '%s'\n", name));
 		talloc_free(tmp_ctx);
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
@@ -220,7 +220,8 @@ int main(int argc, const char *argv[])
 	ctdb = ctdb_cmdline_client(ev, timeval_current_ofs(3, 0));
 
 	/* attach to a specific database */
-	ctdb_db = ctdb_attach(ctdb, "test.tdb", false, 0);
+	ctdb_db = ctdb_attach(ctdb, timeval_current_ofs(2, 0), "test.tdb",
+			      false, 0);
 	if (!ctdb_db) {
 		printf("ctdb_attach failed - %s\n", ctdb_errstr(ctdb));
 		exit(1);
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
@@ -218,7 +218,8 @@ int main(int argc, const char *argv[])
 				 &cluster_ready);
 
 	/* attach to a specific database */
-	ctdb_db = ctdb_attach(ctdb, "test.tdb", false, 0);
+	ctdb_db = ctdb_attach(ctdb, timeval_current_ofs(2, 0), "test.tdb",
+			      false, 0);
 	if (!ctdb_db) {
 		printf("ctdb_attach failed - %s\n", ctdb_errstr(ctdb));
 		exit(1);
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
@@ -122,7 +122,8 @@ int main(int argc, const char *argv[])
 	}
 
 	/* attach to a specific database */
-	ctdb_db = ctdb_attach(ctdb, "test.tdb", false, 0);
+	ctdb_db = ctdb_attach(ctdb, timeval_current_ofs(2, 0), "test.tdb",
+			      false, 0);
 	if (!ctdb_db) {
 		printf("ctdb_attach failed - %s\n", ctdb_errstr(ctdb));
 		exit(1);
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
@@ -228,9 +228,11 @@ int main(int argc, const char *argv[])
 
 	/* attach to a specific database */
 	if (unsafe_writes == 1) {
-		ctdb_db = ctdb_attach(ctdb, "persistent.tdb", true, TDB_NOSYNC);
+		ctdb_db = ctdb_attach(ctdb, timeval_current_ofs(2, 0),
+				      "persistent.tdb", true, TDB_NOSYNC);
 	} else {
-		ctdb_db = ctdb_attach(ctdb, "persistent.tdb", true, 0);
+		ctdb_db = ctdb_attach(ctdb, timeval_current_ofs(2, 0),
+				      "persistent.tdb", true, 0);
 	}
 
 	if (!ctdb_db) {
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
@@ -189,7 +189,8 @@ int main(int argc, const char *argv[])
 	}
 
 	/* attach to a specific database */
-	ctdb_db = ctdb_attach(ctdb, "test.tdb", false, 0);
+	ctdb_db = ctdb_attach(ctdb, timeval_current_ofs(2, 0), "test.tdb",
+			      false, 0);
 	if (!ctdb_db) {
 		printf("ctdb_attach failed - %s\n", ctdb_errstr(ctdb));
 		exit(1);
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
@@ -144,7 +144,7 @@ int main(int argc, const char *argv[])
 	}
 
 	/* attach to a specific database */
-	ctdb_db = ctdb_attach(ctdb, "test.tdb", false, 0);
+	ctdb_db = ctdb_attach(ctdb, timeval_current_ofs(2, 0), "test.tdb", false, 0);
 	if (!ctdb_db) {
 		printf("ctdb_attach failed - %s\n", ctdb_errstr(ctdb));
 		exit(1);
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
@@ -260,9 +260,11 @@ int main(int argc, const char *argv[])
 
 	/* attach to a specific database */
 	if (unsafe_writes == 1) {
-		ctdb_db = ctdb_attach(ctdb, "transaction.tdb", true, TDB_NOSYNC);
+		ctdb_db = ctdb_attach(ctdb, timeval_current_ofs(2, 0),
+				      "transaction.tdb", true, TDB_NOSYNC);
 	} else {
-		ctdb_db = ctdb_attach(ctdb, "transaction.tdb", true, 0);
+		ctdb_db = ctdb_attach(ctdb, timeval_current_ofs(2, 0),
+				      "transaction.tdb", true, 0);
 	}
 
 	if (!ctdb_db) {
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
@@ -92,7 +92,7 @@ int main(int argc, const char *argv[])
 	ctdb = ctdb_cmdline_client(ev, timeval_current_ofs(3, 0));
 
 	/* attach to a specific database */
-	ctdb_db = ctdb_attach(ctdb, dbname, false, 0);
+	ctdb_db = ctdb_attach(ctdb, timeval_current_ofs(2, 0), dbname, false, 0);
 	if (!ctdb_db) {
 		printf("ctdb_attach failed - %s\n", ctdb_errstr(ctdb));
 		exit(1);
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
@@ -2714,7 +2714,7 @@ static int control_catdb(struct ctdb_con
 		return -1;
 	}
 
-	ctdb_db = ctdb_attach(ctdb, db_name, persistent, 0);
+	ctdb_db = ctdb_attach(ctdb, TIMELIMIT(), db_name, persistent, 0);
 
 	if (ctdb_db == NULL) {
 		DEBUG(DEBUG_ERR,("Unable to attach to database '%s'\n", db_name));
@@ -3347,7 +3347,7 @@ static int control_attach(struct ctdb_co
 		persistent = true;
 	}
 
-	ctdb_db = ctdb_attach(ctdb, db_name, persistent, 0);
+	ctdb_db = ctdb_attach(ctdb, TIMELIMIT(), db_name, persistent, 0);
 	if (ctdb_db == NULL) {
 		DEBUG(DEBUG_ERR,("Unable to attach to database '%s'\n", db_name));
 		return -1;
@@ -3555,7 +3555,7 @@ static int control_backupdb(struct ctdb_
 				     allow_unhealthy));
 	}
 
-	ctdb_db = ctdb_attach(ctdb, argv[0], dbmap->dbs[i].persistent, 0);
+	ctdb_db = ctdb_attach(ctdb, TIMELIMIT(), argv[0], dbmap->dbs[i].persistent, 0);
 	if (ctdb_db == NULL) {
 		DEBUG(DEBUG_ERR,("Unable to attach to database '%s'\n", argv[0]));
 		talloc_free(tmp_ctx);
@@ -3693,7 +3693,7 @@ static int control_restoredb(struct ctdb
 		dbhdr.name, tbuf);
 
 
-	ctdb_db = ctdb_attach(ctdb, dbhdr.name, dbhdr.persistent, 0);
+	ctdb_db = ctdb_attach(ctdb, TIMELIMIT(), dbhdr.name, dbhdr.persistent, 0);
 	if (ctdb_db == NULL) {
 		DEBUG(DEBUG_ERR,("Unable to attach to database '%s'\n", dbhdr.name));
 		talloc_free(tmp_ctx);
@@ -3954,7 +3954,7 @@ static int control_wipedb(struct ctdb_co
 		return -1;
 	}
 
-	ctdb_db = ctdb_attach(ctdb, argv[0], dbmap->dbs[i].persistent, 0);
+	ctdb_db = ctdb_attach(ctdb, TIMELIMIT(), argv[0], dbmap->dbs[i].persistent, 0);
 	if (ctdb_db == NULL) {
 		DEBUG(DEBUG_ERR, ("Unable to attach to database '%s'\n",
 				  argv[0]));
Index: ctdb-1.0.114.6/tools/ctdb_vacuum.c
===================================================================
--- ctdb-1.0.114.6.orig/tools/ctdb_vacuum.c
+++ ctdb-1.0.114.6/tools/ctdb_vacuum.c
@@ -144,7 +144,7 @@ static int ctdb_repack_db(struct ctdb_co
 		return -1;
 	}
 
-	ctdb_db = ctdb_attach(ctdb, name, persistent, 0);
+	ctdb_db = ctdb_attach(ctdb, TIMELIMIT(), name, persistent, 0);
 	if (ctdb_db == NULL) {
 		DEBUG(DEBUG_ERR,(__location__ " Failed to attach to database '%s'\n", name));
 		return -1;
