client: add req timeout argument to ctdb_cmdline_client
authorDavid Disseldorp <ddiss@suse.de>
Mon, 8 Aug 2011 12:09:46 +0000 (14:09 +0200)
committerDavid Disseldorp <ddiss@suse.de>
Tue, 6 Sep 2011 11:56:54 +0000 (13:56 +0200)
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.

common/cmdline.c
include/ctdb_client.h
tests/src/ctdb_bench.c
tests/src/ctdb_fetch.c
tests/src/ctdb_fetch_one.c
tests/src/ctdb_persistent.c
tests/src/ctdb_randrec.c
tests/src/ctdb_store.c
tests/src/ctdb_transaction.c
tests/src/ctdb_traverse.c
tools/ctdb.c

index 145a13a81b7be3b2b97dc3b2d2e5fa8e02793650..5c00763ed7705ee52a63f53b3aef972225210b58 100644 (file)
@@ -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 tevent_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);
index 3dc115f0ccd441ba72793cef30e1cba376e22e9d..baa720dea4779f5a9991ab72fdb0a73a8ba1e12e 100644 (file)
@@ -188,7 +188,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 tevent_context *ev);
+struct ctdb_context *ctdb_cmdline_client(struct tevent_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 6d812237ec2605692be902ae96f36f5f50434ef5..cdd176ac84d128025e86f352b1f7913b349ca434 100644 (file)
@@ -222,7 +222,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 a8f38eeea3e9eb5a4dfe2df9e0221558272fa778..b97e2ef0230a2e969f6cfc1e15100238a0b0b323 100644 (file)
@@ -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 7348aa698696408f293caa8d6fa89a448d4992bc..f8fa466699073b43de3b658a5e4e9d3c9fd93a33 100644 (file)
@@ -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 6074b6a1e361e5a3f86dace78eb374b52aeb3fc0..bf975c61025161c1abc25718edfaaaa4949dfcc7 100644 (file)
@@ -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 5b7eef83d29b5f91380bbd240fc942838a9be798..128ffc877f6268be6d5cec4e7fa1d91d37d8fc5f 100644 (file)
@@ -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 82669b7b6dd784d8037cfa9d26d4922576ccf0f0..ea1486c0a0cccff66f8891a744af62a9b4efb8c7 100644 (file)
@@ -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 39e40dd16bb7f552c15ecd7d97754a2de70cea8f..1eba5c860321b56b0cf1a90aee1516a68bef7456 100644 (file)
@@ -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 c4510e43c93a41cb44238c9cd5446a77b930ae15..4d523f27ea9afd810910e33f80d7dd468c2a9571 100644 (file)
@@ -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 8528de70eec75d43434fb71b60db2b1a5f8e50be..e9c8b91492c765ea2aafef97bcd165f9f7194d0a 100644 (file)
@@ -5134,7 +5134,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) {
                                const char *socket_name;