summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2024-11-21 13:15:02 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2024-11-21 13:15:02 +0000
commit2e2a93ef22aa29ad33b76ca24ca1ffc708c7d123 (patch)
tree8779c78c09216195f4302a667284a7f975b824df /sbin
parenta2e0da3303f0ac5a62a641dc9be9696b4e4ef096 (diff)
Convert imsg_write() callers to the new simplified return logic.
OK tb@
Diffstat (limited to 'sbin')
-rw-r--r--sbin/dhcp6leased/control.c4
-rw-r--r--sbin/dhcp6leased/dhcp6leased.c22
-rw-r--r--sbin/dhcp6leased/engine.c22
-rw-r--r--sbin/dhcp6leased/frontend.c22
-rw-r--r--sbin/dhcpleased/control.c4
-rw-r--r--sbin/dhcpleased/dhcpleased.c22
-rw-r--r--sbin/dhcpleased/engine.c22
-rw-r--r--sbin/dhcpleased/frontend.c22
-rw-r--r--sbin/iked/control.c4
-rw-r--r--sbin/iked/proc.c16
-rw-r--r--sbin/slaacd/control.c4
-rw-r--r--sbin/slaacd/engine.c22
-rw-r--r--sbin/slaacd/frontend.c22
-rw-r--r--sbin/slaacd/slaacd.c22
-rw-r--r--sbin/unwind/control.c4
-rw-r--r--sbin/unwind/frontend.c22
-rw-r--r--sbin/unwind/resolver.c22
-rw-r--r--sbin/unwind/unwind.c22
18 files changed, 174 insertions, 126 deletions
diff --git a/sbin/dhcp6leased/control.c b/sbin/dhcp6leased/control.c
index 6c7b56db069..20dbd9118ba 100644
--- a/sbin/dhcp6leased/control.c
+++ b/sbin/dhcp6leased/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.4 2024/11/21 13:10:18 claudio Exp $ */
+/* $OpenBSD: control.c,v 1.5 2024/11/21 13:14:44 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -238,7 +238,7 @@ control_dispatch_imsg(int fd, short event, void *bula)
}
}
if (event & EV_WRITE) {
- if (imsg_write(&c->iev.ibuf) <= 0 && errno != EAGAIN) {
+ if (imsg_write(&c->iev.ibuf) == -1) {
control_close(fd);
return;
}
diff --git a/sbin/dhcp6leased/dhcp6leased.c b/sbin/dhcp6leased/dhcp6leased.c
index fc9600ae0a7..4bf33691729 100644
--- a/sbin/dhcp6leased/dhcp6leased.c
+++ b/sbin/dhcp6leased/dhcp6leased.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhcp6leased.c,v 1.13 2024/11/21 13:10:18 claudio Exp $ */
+/* $OpenBSD: dhcp6leased.c,v 1.14 2024/11/21 13:14:44 claudio Exp $ */
/*
* Copyright (c) 2017, 2021, 2024 Florian Obser <florian@openbsd.org>
@@ -432,10 +432,12 @@ main_dispatch_frontend(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0) /* Connection closed. */
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* Connection closed. */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
@@ -508,10 +510,12 @@ main_dispatch_engine(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0) /* Connection closed. */
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* Connection closed. */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
diff --git a/sbin/dhcp6leased/engine.c b/sbin/dhcp6leased/engine.c
index 961f47e8f0d..e18e5da366a 100644
--- a/sbin/dhcp6leased/engine.c
+++ b/sbin/dhcp6leased/engine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: engine.c,v 1.25 2024/11/21 13:10:18 claudio Exp $ */
+/* $OpenBSD: engine.c,v 1.26 2024/11/21 13:14:44 claudio Exp $ */
/*
* Copyright (c) 2017, 2021, 2024 Florian Obser <florian@openbsd.org>
@@ -282,10 +282,12 @@ engine_dispatch_frontend(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0) /* Connection closed. */
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* Connection closed. */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
@@ -389,10 +391,12 @@ engine_dispatch_main(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0) /* Connection closed. */
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* Connection closed. */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
diff --git a/sbin/dhcp6leased/frontend.c b/sbin/dhcp6leased/frontend.c
index 7819bf8e49b..42630ec1056 100644
--- a/sbin/dhcp6leased/frontend.c
+++ b/sbin/dhcp6leased/frontend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: frontend.c,v 1.15 2024/11/21 13:10:18 claudio Exp $ */
+/* $OpenBSD: frontend.c,v 1.16 2024/11/21 13:14:44 claudio Exp $ */
/*
* Copyright (c) 2017, 2021, 2024 Florian Obser <florian@openbsd.org>
@@ -249,10 +249,12 @@ frontend_dispatch_main(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0) /* Connection closed. */
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* Connection closed. */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
@@ -453,10 +455,12 @@ frontend_dispatch_engine(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0) /* Connection closed. */
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* Connection closed. */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
diff --git a/sbin/dhcpleased/control.c b/sbin/dhcpleased/control.c
index bc6dc7bf261..ac2f4d41699 100644
--- a/sbin/dhcpleased/control.c
+++ b/sbin/dhcpleased/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.7 2024/11/21 13:10:21 claudio Exp $ */
+/* $OpenBSD: control.c,v 1.8 2024/11/21 13:14:44 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -240,7 +240,7 @@ control_dispatch_imsg(int fd, short event, void *bula)
}
}
if (event & EV_WRITE) {
- if (imsg_write(&c->iev.ibuf) <= 0 && errno != EAGAIN) {
+ if (imsg_write(&c->iev.ibuf) == -1) {
control_close(fd);
return;
}
diff --git a/sbin/dhcpleased/dhcpleased.c b/sbin/dhcpleased/dhcpleased.c
index 26bd9daa15b..83a910e1074 100644
--- a/sbin/dhcpleased/dhcpleased.c
+++ b/sbin/dhcpleased/dhcpleased.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhcpleased.c,v 1.33 2024/11/21 13:10:21 claudio Exp $ */
+/* $OpenBSD: dhcpleased.c,v 1.34 2024/11/21 13:14:44 claudio Exp $ */
/*
* Copyright (c) 2017, 2021 Florian Obser <florian@openbsd.org>
@@ -450,10 +450,12 @@ main_dispatch_frontend(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0) /* Connection closed. */
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* Connection closed. */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
@@ -530,10 +532,12 @@ main_dispatch_engine(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0) /* Connection closed. */
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* Connection closed. */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
diff --git a/sbin/dhcpleased/engine.c b/sbin/dhcpleased/engine.c
index 5f6744e0b64..44567694176 100644
--- a/sbin/dhcpleased/engine.c
+++ b/sbin/dhcpleased/engine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: engine.c,v 1.50 2024/11/21 13:10:21 claudio Exp $ */
+/* $OpenBSD: engine.c,v 1.51 2024/11/21 13:14:44 claudio Exp $ */
/*
* Copyright (c) 2017, 2021 Florian Obser <florian@openbsd.org>
@@ -295,10 +295,12 @@ engine_dispatch_frontend(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0) /* Connection closed. */
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* Connection closed. */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
@@ -410,10 +412,12 @@ engine_dispatch_main(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0) /* Connection closed. */
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* Connection closed. */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
diff --git a/sbin/dhcpleased/frontend.c b/sbin/dhcpleased/frontend.c
index d446aad9987..a9df813375c 100644
--- a/sbin/dhcpleased/frontend.c
+++ b/sbin/dhcpleased/frontend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: frontend.c,v 1.40 2024/11/21 13:10:21 claudio Exp $ */
+/* $OpenBSD: frontend.c,v 1.41 2024/11/21 13:14:44 claudio Exp $ */
/*
* Copyright (c) 2017, 2021 Florian Obser <florian@openbsd.org>
@@ -248,10 +248,12 @@ frontend_dispatch_main(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0) /* Connection closed. */
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* Connection closed. */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
@@ -489,10 +491,12 @@ frontend_dispatch_engine(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0) /* Connection closed. */
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* Connection closed. */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
diff --git a/sbin/iked/control.c b/sbin/iked/control.c
index 518d4c69be3..854a1aab9d5 100644
--- a/sbin/iked/control.c
+++ b/sbin/iked/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.40 2024/11/21 13:10:22 claudio Exp $ */
+/* $OpenBSD: control.c,v 1.41 2024/11/21 13:14:44 claudio Exp $ */
/*
* Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org>
@@ -268,7 +268,7 @@ control_dispatch_imsg(int fd, short event, void *arg)
}
}
if (event & EV_WRITE) {
- if (imsg_write(&c->iev.ibuf) <= 0 && errno != EAGAIN) {
+ if (imsg_write(&c->iev.ibuf) == -1) {
control_close(fd, cs);
return;
}
diff --git a/sbin/iked/proc.c b/sbin/iked/proc.c
index 3799601a716..e3f9774de40 100644
--- a/sbin/iked/proc.c
+++ b/sbin/iked/proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.c,v 1.46 2024/11/21 13:10:22 claudio Exp $ */
+/* $OpenBSD: proc.c,v 1.47 2024/11/21 13:14:44 claudio Exp $ */
/*
* Copyright (c) 2010 - 2016 Reyk Floeter <reyk@openbsd.org>
@@ -627,13 +627,13 @@ proc_dispatch(int fd, short event, void *arg)
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("%s: imsg_write", __func__);
- if (n == 0) {
- /* this pipe is dead, so remove the event handler */
- event_del(&iev->ev);
- event_loopexit(NULL);
- return;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) { /* Connection closed. */
+ event_del(&iev->ev);
+ event_loopexit(NULL);
+ return;
+ } else
+ fatal("imsg_write");
}
}
diff --git a/sbin/slaacd/control.c b/sbin/slaacd/control.c
index 1f2b7556b0f..15cd39a5810 100644
--- a/sbin/slaacd/control.c
+++ b/sbin/slaacd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.12 2024/11/21 13:10:23 claudio Exp $ */
+/* $OpenBSD: control.c,v 1.13 2024/11/21 13:14:44 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -241,7 +241,7 @@ control_dispatch_imsg(int fd, short event, void *bula)
}
}
if (event & EV_WRITE) {
- if (imsg_write(&c->iev.ibuf) <= 0 && errno != EAGAIN) {
+ if (imsg_write(&c->iev.ibuf) == -1) {
control_close(fd);
return;
}
diff --git a/sbin/slaacd/engine.c b/sbin/slaacd/engine.c
index a715e7e1d6d..933743ab6e2 100644
--- a/sbin/slaacd/engine.c
+++ b/sbin/slaacd/engine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: engine.c,v 1.94 2024/11/21 13:10:23 claudio Exp $ */
+/* $OpenBSD: engine.c,v 1.95 2024/11/21 13:14:44 claudio Exp $ */
/*
* Copyright (c) 2017 Florian Obser <florian@openbsd.org>
@@ -471,10 +471,12 @@ engine_dispatch_frontend(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0) /* Connection closed. */
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* Connection closed. */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
@@ -637,10 +639,12 @@ engine_dispatch_main(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0) /* Connection closed. */
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* Connection closed. */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
diff --git a/sbin/slaacd/frontend.c b/sbin/slaacd/frontend.c
index a993ede7744..de551a42a4e 100644
--- a/sbin/slaacd/frontend.c
+++ b/sbin/slaacd/frontend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: frontend.c,v 1.69 2024/11/21 13:10:23 claudio Exp $ */
+/* $OpenBSD: frontend.c,v 1.70 2024/11/21 13:14:44 claudio Exp $ */
/*
* Copyright (c) 2017 Florian Obser <florian@openbsd.org>
@@ -292,10 +292,12 @@ frontend_dispatch_main(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0) /* Connection closed. */
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* Connection closed. */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
@@ -402,10 +404,12 @@ frontend_dispatch_engine(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0) /* Connection closed. */
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* Connection closed. */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
diff --git a/sbin/slaacd/slaacd.c b/sbin/slaacd/slaacd.c
index 9cf8d77d2a2..b53371de7cb 100644
--- a/sbin/slaacd/slaacd.c
+++ b/sbin/slaacd/slaacd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: slaacd.c,v 1.73 2024/11/21 13:10:23 claudio Exp $ */
+/* $OpenBSD: slaacd.c,v 1.74 2024/11/21 13:14:44 claudio Exp $ */
/*
* Copyright (c) 2017 Florian Obser <florian@openbsd.org>
@@ -397,10 +397,12 @@ main_dispatch_frontend(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0) /* Connection closed. */
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* Connection closed. */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
@@ -476,10 +478,12 @@ main_dispatch_engine(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0) /* Connection closed. */
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* Connection closed. */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
diff --git a/sbin/unwind/control.c b/sbin/unwind/control.c
index 7f77f601b4c..abea0bae0b1 100644
--- a/sbin/unwind/control.c
+++ b/sbin/unwind/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.18 2024/11/21 13:10:24 claudio Exp $ */
+/* $OpenBSD: control.c,v 1.19 2024/11/21 13:14:45 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -240,7 +240,7 @@ control_dispatch_imsg(int fd, short event, void *bula)
}
}
if (event & EV_WRITE) {
- if (imsg_write(&c->iev.ibuf) <= 0 && errno != EAGAIN) {
+ if (imsg_write(&c->iev.ibuf) == -1) {
control_close(fd);
return;
}
diff --git a/sbin/unwind/frontend.c b/sbin/unwind/frontend.c
index 0d164132c26..bf731bf637e 100644
--- a/sbin/unwind/frontend.c
+++ b/sbin/unwind/frontend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: frontend.c,v 1.84 2024/11/21 13:10:24 claudio Exp $ */
+/* $OpenBSD: frontend.c,v 1.85 2024/11/21 13:14:45 claudio Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -317,10 +317,12 @@ frontend_dispatch_main(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0) /* Connection closed. */
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* Connection closed. */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
@@ -496,10 +498,12 @@ frontend_dispatch_resolver(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0) /* Connection closed. */
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* Connection closed. */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
diff --git a/sbin/unwind/resolver.c b/sbin/unwind/resolver.c
index f4b8005c3b3..e510fb98f2c 100644
--- a/sbin/unwind/resolver.c
+++ b/sbin/unwind/resolver.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: resolver.c,v 1.168 2024/11/21 13:10:24 claudio Exp $ */
+/* $OpenBSD: resolver.c,v 1.169 2024/11/21 13:14:45 claudio Exp $ */
/*
@@ -501,10 +501,12 @@ resolver_dispatch_frontend(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0) /* Connection closed. */
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* Connection closed. */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
@@ -637,10 +639,12 @@ resolver_dispatch_main(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0) /* Connection closed. */
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* Connection closed. */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
diff --git a/sbin/unwind/unwind.c b/sbin/unwind/unwind.c
index 5478c10fe27..b2217bb7faf 100644
--- a/sbin/unwind/unwind.c
+++ b/sbin/unwind/unwind.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: unwind.c,v 1.69 2024/11/21 13:10:24 claudio Exp $ */
+/* $OpenBSD: unwind.c,v 1.70 2024/11/21 13:14:45 claudio Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -404,10 +404,12 @@ main_dispatch_frontend(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0) /* Connection closed. */
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* Connection closed. */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
@@ -467,10 +469,12 @@ main_dispatch_resolver(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0) /* Connection closed. */
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* Connection closed. */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {