1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00

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.

(This used to be ctdb commit 0634d0305f42f17048b6830733767e8dc300e11c)
This commit is contained in:
David Disseldorp 2011-08-08 14:09:46 +02:00
parent 2e5b0f1eb2
commit 0628d1c0e6
11 changed files with 14 additions and 12 deletions

View 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);

View 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);

View 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);

View 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");

View 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");

View 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;

View 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");

View 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");

View 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;

View 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);

View 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;