summaryrefslogtreecommitdiff
path: root/tools/notify-dns-slaves.c
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2008-06-09 19:21:43 +0000
committerStef Walter <stef@memberwebs.com>2008-06-09 19:21:43 +0000
commit3f65ea3cb042826f7343d80a2a1c048fba16edfa (patch)
treef71ac23a5bf8a9dd2b4ab15ccc5758bb95ef3083 /tools/notify-dns-slaves.c
parentb9ecd6e5e5b87fe1c4dab960e92246772002dd6a (diff)
Bug fixes.
Diffstat (limited to 'tools/notify-dns-slaves.c')
-rw-r--r--tools/notify-dns-slaves.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/tools/notify-dns-slaves.c b/tools/notify-dns-slaves.c
index 018af43..4af4b8c 100644
--- a/tools/notify-dns-slaves.c
+++ b/tools/notify-dns-slaves.c
@@ -103,7 +103,7 @@ static int the_socket4 = -1;
static int the_socket6 = -1;
static char stdin_buffer[LINE_LENGTH + 1];
-static size_t stdin_offset = 0;
+static ssize_t stdin_offset = 0;
static int processing_active = 0;
static int input_complete = 0;
@@ -147,9 +147,9 @@ vmessage(int level, int erno, const char* msg, va_list ap)
char buf[MAX_MSGLEN];
size_t len;
- if(debug_level < level)
+/* if(debug_level < level)
return;
-
+*/
assert (msg);
strncpy (buf, msg, MAX_MSGLEN);
@@ -165,7 +165,7 @@ vmessage(int level, int erno, const char* msg, va_list ap)
}
/* Either to syslog or stderr */
- if (is_helper && level != LOG_DEBUG)
+/* if (is_helper && level != LOG_DEBUG) */
vsyslog (level, buf, ap);
vwarnx (buf, ap);
@@ -636,7 +636,7 @@ stdin_callback (int fd, int type, void *arg)
assert (fd == 0);
- num = read (fd, stdin_buffer, LINE_LENGTH - stdin_offset);
+ num = read (fd, stdin_buffer + stdin_offset, LINE_LENGTH - stdin_offset);
if (num < 0) {
if (errno == EAGAIN || errno == EINTR)
return;
@@ -660,15 +660,18 @@ stdin_callback (int fd, int type, void *arg)
line = stdin_buffer + LINE_LENGTH;
}
- if (!line) /* Wait for more data */
+ if (!line) /* Wait for more data */ {
+fprintf (stderr, "waiting for more data %d\n", stdin_offset);
break;
+}
*line = 0;
num = (line + 1) - stdin_buffer;
process_stdin_line (stdin_buffer);
- stdin_offset = LINE_LENGTH - num;
- memmove (stdin_buffer, stdin_buffer + num, stdin_offset);
+ stdin_offset = stdin_offset - num;
+ if (stdin_offset)
+ memmove (stdin_buffer, stdin_buffer + num, stdin_offset);
} while (!input_complete);
@@ -677,6 +680,8 @@ stdin_callback (int fd, int type, void *arg)
server_stop ();
server_unwatch (fd);
}
+
+ assert (stdin_offset >= 0);
}
static void
@@ -743,8 +748,8 @@ make_sockets (void)
static void
usage()
{
- fprintf (stderr, "usage: slapi-dnsnotify-helper -s [-d level]\n");
- fprintf (stderr, "usage: slapi-dnsnotify-helper [-d level] zone server ...\n");
+ fprintf (stderr, "usage: notify-dns-slaves -s [-w wait] [-d level]\n");
+ fprintf (stderr, "usage: notify-dns-slaves [-d level] zone server ...\n");
exit (2);
}
@@ -759,7 +764,7 @@ main(int argc, char *argv[])
{
case 'd':
debug_level = strtol (optarg, &str, 10);
- if (*str || debug_level > 4)
+ if (*str || debug_level < 0 || debug_level > 4)
fatalx (1, "invalid debug log level: %s", optarg);
debug_level += LOG_ERR;
break;
@@ -768,8 +773,10 @@ main(int argc, char *argv[])
break;
case 'w':
delay_interval = strtol (optarg, &str, 10);
- if (*str || delay_interval > 0)
+ if (*str || delay_interval < 0)
fatalx (1, "invalid delay interval: %s", optarg);
+ delay_interval *= 1000;
+ break;
case '?':
default:
usage ();