summaryrefslogtreecommitdiff
path: root/sbin/unwind
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/unwind
parenta2e0da3303f0ac5a62a641dc9be9696b4e4ef096 (diff)
Convert imsg_write() callers to the new simplified return logic.
OK tb@
Diffstat (limited to 'sbin/unwind')
-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
4 files changed, 41 insertions, 29 deletions
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 (;;) {