summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2008-06-09 17:22:43 +0000
committerStef Walter <stef@memberwebs.com>2008-06-09 17:22:43 +0000
commitb9ecd6e5e5b87fe1c4dab960e92246772002dd6a (patch)
treeeb05eb48888e391678fa706ec5f62b012df2456e /tools
parent3add3c0e19b659427a2624ec85daf67019b8ed7f (diff)
Merge the two dns plugins
Diffstat (limited to 'tools')
-rw-r--r--tools/notify-dns-slaves.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/tools/notify-dns-slaves.c b/tools/notify-dns-slaves.c
index 96f2ea7..018af43 100644
--- a/tools/notify-dns-slaves.c
+++ b/tools/notify-dns-slaves.c
@@ -96,7 +96,7 @@ static const char *DNS_ERRORS[] = {
#define RETRIES 3 /* Number of times we send out packet */
#define RETRY_INTERVAL 400 /* Milliseconds between sending out packet */
#define TIMEOUT_INTERVAL 5000 /* Timeout for response in milliseconds */
-#define DELAY_INTERVAL 5000 /* Number of milliseconds before processing input on stdin */
+#define DEFAULT_DELAY_INTERVAL 5000 /* Number of milliseconds before processing input on stdin */
#define LINE_LENGTH 1023 /* Maximum length of buffer on stdin */
static int the_socket4 = -1;
@@ -108,6 +108,7 @@ static size_t stdin_offset = 0;
static int processing_active = 0;
static int input_complete = 0;
+static int delay_interval = -1;
static unsigned int unique_identifier = 1;
static int is_helper = 0;
@@ -624,7 +625,7 @@ process_stdin_line (char *line)
}
server[len] = 0;
- process_notify (zone, server, DELAY_INTERVAL);
+ process_notify (zone, server, delay_interval);
}
static void
@@ -753,11 +754,11 @@ main(int argc, char *argv[])
char *str;
int ch = 0, i;
- while ((ch = getopt (argc, argv, "d:s")) != -1) {
+ while ((ch = getopt (argc, argv, "d:sw:")) != -1) {
switch (ch)
{
case 'd':
- debug_level = strtol(optarg, &str, 10);
+ debug_level = strtol (optarg, &str, 10);
if (*str || debug_level > 4)
fatalx (1, "invalid debug log level: %s", optarg);
debug_level += LOG_ERR;
@@ -765,6 +766,10 @@ main(int argc, char *argv[])
case 's':
is_helper = 1;
break;
+ case 'w':
+ delay_interval = strtol (optarg, &str, 10);
+ if (*str || delay_interval > 0)
+ fatalx (1, "invalid delay interval: %s", optarg);
case '?':
default:
usage ();
@@ -787,13 +792,20 @@ main(int argc, char *argv[])
if (is_helper) {
openlog ("notify-dns-slaves", 0, LOG_DAEMON);
+
input_complete = 0;
+ if (delay_interval < 0)
+ delay_interval = DEFAULT_DELAY_INTERVAL;
+
/* Watch stdin for data */
fcntl (0, F_SETFL, fcntl(0, F_GETFL, 0) | O_NONBLOCK);
if (server_watch (0, SERVER_READ, stdin_callback, NULL) < 0)
fatal (1, "coludn't watch stdin for changes");
} else {
input_complete = 1;
+ if (delay_interval < 0)
+ delay_interval = 0;
+
str = argv[0];
for (i = 1; i < argc; ++i)
process_notify (str, argv[i], 0);