summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2007-02-03 17:51:47 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2007-02-03 17:51:47 +0000
commit437fe324a219673710d47cdb31ca0744194fbc93 (patch)
tree62837a9619de354177b7e04090efde2aa9b6ce86 /usr.sbin
parent89c8d05c0de155711cd89aa4706f35922a1e91d9 (diff)
wait for hoststated to become available in monitor mode.
ok pyr@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/hoststatectl/hoststatectl.c13
-rw-r--r--usr.sbin/relayctl/relayctl.c13
2 files changed, 22 insertions, 4 deletions
diff --git a/usr.sbin/hoststatectl/hoststatectl.c b/usr.sbin/hoststatectl/hoststatectl.c
index b37f84ad7a2..301488a9dc9 100644
--- a/usr.sbin/hoststatectl/hoststatectl.c
+++ b/usr.sbin/hoststatectl/hoststatectl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hoststatectl.c,v 1.12 2007/02/01 21:57:18 reyk Exp $ */
+/* $OpenBSD: hoststatectl.c,v 1.13 2007/02/03 17:51:46 reyk Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org>
@@ -30,6 +30,7 @@
#include <net/if_types.h>
#include <err.h>
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -113,8 +114,16 @@ main(int argc, char *argv[])
bzero(&sun, sizeof(sun));
sun.sun_family = AF_UNIX;
strlcpy(sun.sun_path, HOSTSTATED_SOCKET, sizeof(sun.sun_path));
- if (connect(ctl_sock, (struct sockaddr *)&sun, sizeof(sun)) == -1)
+ reconnect:
+ if (connect(ctl_sock, (struct sockaddr *)&sun, sizeof(sun)) == -1) {
+ /* Keep retrying if running in monitor mode */
+ if (res->action == MONITOR &&
+ (errno == ENOENT || errno == ECONNREFUSED)) {
+ usleep(100);
+ goto reconnect;
+ }
err(1, "connect: %s", HOSTSTATED_SOCKET);
+ }
if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL)
err(1, NULL);
diff --git a/usr.sbin/relayctl/relayctl.c b/usr.sbin/relayctl/relayctl.c
index 32e1ffad95c..39746e0d34a 100644
--- a/usr.sbin/relayctl/relayctl.c
+++ b/usr.sbin/relayctl/relayctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relayctl.c,v 1.12 2007/02/01 21:57:18 reyk Exp $ */
+/* $OpenBSD: relayctl.c,v 1.13 2007/02/03 17:51:46 reyk Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org>
@@ -30,6 +30,7 @@
#include <net/if_types.h>
#include <err.h>
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -113,8 +114,16 @@ main(int argc, char *argv[])
bzero(&sun, sizeof(sun));
sun.sun_family = AF_UNIX;
strlcpy(sun.sun_path, HOSTSTATED_SOCKET, sizeof(sun.sun_path));
- if (connect(ctl_sock, (struct sockaddr *)&sun, sizeof(sun)) == -1)
+ reconnect:
+ if (connect(ctl_sock, (struct sockaddr *)&sun, sizeof(sun)) == -1) {
+ /* Keep retrying if running in monitor mode */
+ if (res->action == MONITOR &&
+ (errno == ENOENT || errno == ECONNREFUSED)) {
+ usleep(100);
+ goto reconnect;
+ }
err(1, "connect: %s", HOSTSTATED_SOCKET);
+ }
if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL)
err(1, NULL);