Rev 751: add a max runtime switch to ctdb tool in
http://samba.org/~tridge/ctdb
tridge at samba.org
tridge at samba.org
Wed Jan 9 21:05:04 GMT 2008
------------------------------------------------------------
revno: 751
revision-id:tridge at samba.org-20080109210454-lgp131hsvrt1q69q
parent: tridge at samba.org-20080109064513-rbp8aevvs7aarpj1
committer: Andrew Tridgell <tridge at samba.org>
branch nick: tridge.stable
timestamp: Thu 2008-01-10 08:04:54 +1100
message:
add a max runtime switch to ctdb tool
modified:
tools/ctdb.c ctdb_control.c-20070426122705-9ehj1l5lu2gn9kuj-1
=== modified file 'tools/ctdb.c'
--- a/tools/ctdb.c 2008-01-08 12:02:43 +0000
+++ b/tools/ctdb.c 2008-01-09 21:04:54 +0000
@@ -33,6 +33,7 @@
int timelimit;
uint32_t pnn;
int machinereadable;
+ int maxruntime;
} options;
#define TIMELIMIT() timeval_current_ofs(options.timelimit, 0)
@@ -1094,6 +1095,12 @@
}
+static void ctdb_alarm(int sig)
+{
+ printf("Maximum runtime exceeded - exiting\n");
+ _exit(0);
+}
+
/*
main program
*/
@@ -1107,6 +1114,7 @@
{ "timelimit", 't', POPT_ARG_INT, &options.timelimit, 0, "timelimit", "integer" },
{ "node", 'n', POPT_ARG_STRING, &nodestring, 0, "node", "integer|all" },
{ "machinereadable", 'Y', POPT_ARG_NONE, &options.machinereadable, 0, "enable machinereadable output", NULL },
+ { "maxruntime", 'T', POPT_ARG_INT, &options.maxruntime, 0, "die if runtime exceeds this limit (in seconds)", "integer" },
POPT_TABLEEND
};
int opt;
@@ -1120,6 +1128,7 @@
setlinebuf(stdout);
/* set some defaults */
+ options.maxruntime = 0;
options.timelimit = 3;
options.pnn = CTDB_CURRENT_NODE;
@@ -1145,6 +1154,11 @@
usage();
}
+ if (options.maxruntime != 0) {
+ signal(SIGALRM, ctdb_alarm);
+ alarm(options.maxruntime);
+ }
+
/* setup the node number to contact */
if (nodestring != NULL) {
if (strcmp(nodestring, "all") == 0) {
More information about the samba-cvs
mailing list