summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2024-11-21 13:16:08 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2024-11-21 13:16:08 +0000
commit9c8d00dd06d79ba9fccf07c45cd1bdae73e744c5 (patch)
tree9dbbc9d2f725d8ee1474850be3abaff593b88fe4
parent2e2a93ef22aa29ad33b76ca24ca1ffc708c7d123 (diff)
Convert imsg_write() callers to the new simplified return logic.
OK tb@
-rw-r--r--usr.sbin/bgpd/bgpd.c4
-rw-r--r--usr.sbin/bgpd/control.c4
-rw-r--r--usr.sbin/dvmrpd/control.c4
-rw-r--r--usr.sbin/dvmrpd/dvmrpd.c22
-rw-r--r--usr.sbin/dvmrpd/dvmrpe.c22
-rw-r--r--usr.sbin/dvmrpd/rde.c12
-rw-r--r--usr.sbin/eigrpd/control.c4
-rw-r--r--usr.sbin/eigrpd/eigrpd.c22
-rw-r--r--usr.sbin/eigrpd/eigrpe.c22
-rw-r--r--usr.sbin/eigrpd/rde.c22
-rw-r--r--usr.sbin/httpd/control.c4
-rw-r--r--usr.sbin/httpd/proc.c17
-rw-r--r--usr.sbin/ldapd/imsgev.c4
-rw-r--r--usr.sbin/ldpd/control.c4
-rw-r--r--usr.sbin/ldpd/lde.c22
-rw-r--r--usr.sbin/ldpd/ldpd.c22
-rw-r--r--usr.sbin/ldpd/ldpe.c22
-rw-r--r--usr.sbin/lpd/proc.c17
-rw-r--r--usr.sbin/npppd/npppd/control.c4
-rw-r--r--usr.sbin/ntpd/control.c4
-rw-r--r--usr.sbin/ntpd/ntp.c8
-rw-r--r--usr.sbin/ntpd/ntp_dns.c5
-rw-r--r--usr.sbin/ntpd/ntpd.c4
-rw-r--r--usr.sbin/ospf6d/control.c4
-rw-r--r--usr.sbin/ospf6d/ospf6d.c22
-rw-r--r--usr.sbin/ospf6d/ospfe.c22
-rw-r--r--usr.sbin/ospf6d/rde.c22
-rw-r--r--usr.sbin/ospfd/control.c4
-rw-r--r--usr.sbin/ospfd/ospfd.c22
-rw-r--r--usr.sbin/ospfd/ospfe.c22
-rw-r--r--usr.sbin/ospfd/rde.c22
-rw-r--r--usr.sbin/rad/control.c4
-rw-r--r--usr.sbin/rad/engine.c22
-rw-r--r--usr.sbin/rad/frontend.c22
-rw-r--r--usr.sbin/rad/rad.c22
-rw-r--r--usr.sbin/radiusd/control.c4
-rw-r--r--usr.sbin/radiusd/radiusd.c23
-rw-r--r--usr.sbin/radiusd/radiusd_module.c26
-rw-r--r--usr.sbin/relayd/control.c4
-rw-r--r--usr.sbin/relayd/proc.c15
-rw-r--r--usr.sbin/ripd/control.c4
-rw-r--r--usr.sbin/ripd/rde.c22
-rw-r--r--usr.sbin/ripd/ripd.c22
-rw-r--r--usr.sbin/ripd/ripe.c22
-rw-r--r--usr.sbin/smtpd/mproc.c5
-rw-r--r--usr.sbin/snmpd/proc.c15
-rw-r--r--usr.sbin/vmd/control.c4
-rw-r--r--usr.sbin/vmd/proc.c15
-rw-r--r--usr.sbin/vmd/vioblk.c32
-rw-r--r--usr.sbin/vmd/vionet.c32
-rw-r--r--usr.sbin/vmd/virtio.c17
-rw-r--r--usr.sbin/vmd/vm.c9
-rw-r--r--usr.sbin/vmd/vmm.c13
-rw-r--r--usr.sbin/ypldap/ldapclient.c26
-rw-r--r--usr.sbin/ypldap/ypldap.c14
-rw-r--r--usr.sbin/ypldap/ypldap_dns.c14
56 files changed, 445 insertions, 378 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c
index 493d2249c57..9d92a18ca36 100644
--- a/usr.sbin/bgpd/bgpd.c
+++ b/usr.sbin/bgpd/bgpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.c,v 1.271 2024/11/21 13:10:26 claudio Exp $ */
+/* $OpenBSD: bgpd.c,v 1.272 2024/11/21 13:16:06 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -1273,7 +1273,7 @@ handle_pollfd(struct pollfd *pfd, struct imsgbuf *i)
return (0);
if (pfd->revents & POLLOUT)
- if (imsg_write(i) <= 0 && errno != EAGAIN) {
+ if (imsg_write(i) == -1) {
log_warn("imsg write error");
close(i->fd);
i->fd = -1;
diff --git a/usr.sbin/bgpd/control.c b/usr.sbin/bgpd/control.c
index 2fc6c04273a..5bd1464cd98 100644
--- a/usr.sbin/bgpd/control.c
+++ b/usr.sbin/bgpd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.122 2024/11/21 13:10:26 claudio Exp $ */
+/* $OpenBSD: control.c,v 1.123 2024/11/21 13:16:06 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -249,7 +249,7 @@ control_dispatch_msg(struct pollfd *pfd, struct peer_head *peers)
}
if (pfd->revents & POLLOUT) {
- if (imsg_write(&c->imsgbuf) <= 0 && errno != EAGAIN)
+ if (imsg_write(&c->imsgbuf) == -1)
return control_close(c);
if (c->throttled && c->imsgbuf.w.queued < CTL_MSG_LOW_MARK) {
if (imsg_ctl_rde_msg(IMSG_XON, 0, c->imsgbuf.pid) != -1)
diff --git a/usr.sbin/dvmrpd/control.c b/usr.sbin/dvmrpd/control.c
index bdb13fc639b..6adfd68cc6e 100644
--- a/usr.sbin/dvmrpd/control.c
+++ b/usr.sbin/dvmrpd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.26 2024/11/21 13:10:27 claudio Exp $ */
+/* $OpenBSD: control.c,v 1.27 2024/11/21 13:16:06 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -235,7 +235,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/usr.sbin/dvmrpd/dvmrpd.c b/usr.sbin/dvmrpd/dvmrpd.c
index 82c6ce53399..6c2ae720c5e 100644
--- a/usr.sbin/dvmrpd/dvmrpd.c
+++ b/usr.sbin/dvmrpd/dvmrpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dvmrpd.c,v 1.28 2024/11/21 13:10:27 claudio Exp $ */
+/* $OpenBSD: dvmrpd.c,v 1.29 2024/11/21 13:16:06 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -323,10 +323,12 @@ main_dispatch_dvmrpe(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 (;;) {
@@ -385,10 +387,12 @@ main_dispatch_rde(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/usr.sbin/dvmrpd/dvmrpe.c b/usr.sbin/dvmrpd/dvmrpe.c
index 8b0fdb80d88..bab04ab92e7 100644
--- a/usr.sbin/dvmrpd/dvmrpe.c
+++ b/usr.sbin/dvmrpd/dvmrpe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dvmrpe.c,v 1.25 2024/11/21 13:10:27 claudio Exp $ */
+/* $OpenBSD: dvmrpe.c,v 1.26 2024/11/21 13:16:06 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -247,10 +247,12 @@ dvmrpe_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 (;;) {
@@ -321,10 +323,12 @@ dvmrpe_dispatch_rde(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/usr.sbin/dvmrpd/rde.c b/usr.sbin/dvmrpd/rde.c
index a7a7dd3d248..25820487abc 100644
--- a/usr.sbin/dvmrpd/rde.c
+++ b/usr.sbin/dvmrpd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.34 2024/11/21 13:10:27 claudio Exp $ */
+/* $OpenBSD: rde.c,v 1.35 2024/11/21 13:16:06 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -212,10 +212,12 @@ rde_dispatch_imsg(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/usr.sbin/eigrpd/control.c b/usr.sbin/eigrpd/control.c
index d36af2ec020..4c732a29f22 100644
--- a/usr.sbin/eigrpd/control.c
+++ b/usr.sbin/eigrpd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.11 2024/11/21 13:10:28 claudio Exp $ */
+/* $OpenBSD: control.c,v 1.12 2024/11/21 13:16:06 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -227,7 +227,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/usr.sbin/eigrpd/eigrpd.c b/usr.sbin/eigrpd/eigrpd.c
index 1c3c0d9378e..c80b704fea2 100644
--- a/usr.sbin/eigrpd/eigrpd.c
+++ b/usr.sbin/eigrpd/eigrpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eigrpd.c,v 1.30 2024/11/21 13:10:28 claudio Exp $ */
+/* $OpenBSD: eigrpd.c,v 1.31 2024/11/21 13:16:06 claudio Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -379,10 +379,12 @@ main_dispatch_eigrpe(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 (;;) {
@@ -455,10 +457,12 @@ main_dispatch_rde(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/usr.sbin/eigrpd/eigrpe.c b/usr.sbin/eigrpd/eigrpe.c
index c38b7758cb7..30f385b6a17 100644
--- a/usr.sbin/eigrpd/eigrpe.c
+++ b/usr.sbin/eigrpd/eigrpe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eigrpe.c,v 1.42 2024/11/21 13:10:28 claudio Exp $ */
+/* $OpenBSD: eigrpe.c,v 1.43 2024/11/21 13:16:06 claudio Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -232,10 +232,12 @@ eigrpe_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 @@ eigrpe_dispatch_rde(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/usr.sbin/eigrpd/rde.c b/usr.sbin/eigrpd/rde.c
index f2c39db150e..5c8d8c53527 100644
--- a/usr.sbin/eigrpd/rde.c
+++ b/usr.sbin/eigrpd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.27 2024/11/21 13:10:28 claudio Exp $ */
+/* $OpenBSD: rde.c,v 1.28 2024/11/21 13:16:06 claudio Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -181,10 +181,12 @@ rde_dispatch_imsg(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 (;;) {
@@ -316,10 +318,12 @@ rde_dispatch_parent(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/usr.sbin/httpd/control.c b/usr.sbin/httpd/control.c
index 62ee3f23384..5c4ddf7a18b 100644
--- a/usr.sbin/httpd/control.c
+++ b/usr.sbin/httpd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.16 2024/11/21 13:10:36 claudio Exp $ */
+/* $OpenBSD: control.c,v 1.17 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -237,7 +237,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/usr.sbin/httpd/proc.c b/usr.sbin/httpd/proc.c
index 7bd184c7841..49fc73e7f63 100644
--- a/usr.sbin/httpd/proc.c
+++ b/usr.sbin/httpd/proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.c,v 1.47 2024/11/21 13:10:36 claudio Exp $ */
+/* $OpenBSD: proc.c,v 1.48 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2010 - 2016 Reyk Floeter <reyk@openbsd.org>
@@ -611,13 +611,14 @@ 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 */
+ /* remove the event handler */
+ event_del(&iev->ev);
+ event_loopexit(NULL);
+ return;
+ } else
+ fatal("%s: imsg_write", __func__);
}
}
diff --git a/usr.sbin/ldapd/imsgev.c b/usr.sbin/ldapd/imsgev.c
index 59f41e5142c..ed95415036b 100644
--- a/usr.sbin/ldapd/imsgev.c
+++ b/usr.sbin/ldapd/imsgev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imsgev.c,v 1.7 2024/11/21 13:10:38 claudio Exp $ */
+/* $OpenBSD: imsgev.c,v 1.8 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2009 Eric Faurot <eric@openbsd.org>
@@ -139,7 +139,7 @@ imsgev_dispatch(int fd, short ev, void *humppa)
* closed, or some error occured. Both case are not recoverable
* from the imsg perspective, so we treat it as a WRITE error.
*/
- if (imsg_write(ibuf) <= 0 && errno != EAGAIN) {
+ if (imsg_write(ibuf) == -1) {
imsgev_disconnect(iev, IMSGEV_EWRITE);
return;
}
diff --git a/usr.sbin/ldpd/control.c b/usr.sbin/ldpd/control.c
index 02574b79dee..9ad6eb58f55 100644
--- a/usr.sbin/ldpd/control.c
+++ b/usr.sbin/ldpd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.33 2024/11/21 13:10:39 claudio Exp $ */
+/* $OpenBSD: control.c,v 1.34 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -210,7 +210,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/usr.sbin/ldpd/lde.c b/usr.sbin/ldpd/lde.c
index 0c0bc813f72..97bfc2c3920 100644
--- a/usr.sbin/ldpd/lde.c
+++ b/usr.sbin/ldpd/lde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lde.c,v 1.79 2024/11/21 13:10:39 claudio Exp $ */
+/* $OpenBSD: lde.c,v 1.80 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
@@ -204,10 +204,12 @@ lde_dispatch_imsg(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 (;;) {
@@ -399,10 +401,12 @@ lde_dispatch_parent(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/usr.sbin/ldpd/ldpd.c b/usr.sbin/ldpd/ldpd.c
index 9604abc87b4..f51d4886934 100644
--- a/usr.sbin/ldpd/ldpd.c
+++ b/usr.sbin/ldpd/ldpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpd.c,v 1.70 2024/11/21 13:10:39 claudio Exp $ */
+/* $OpenBSD: ldpd.c,v 1.71 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
@@ -385,10 +385,12 @@ main_dispatch_ldpe(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)
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* connection closed */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
@@ -464,10 +466,12 @@ main_dispatch_lde(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)
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* connection closed */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
diff --git a/usr.sbin/ldpd/ldpe.c b/usr.sbin/ldpd/ldpe.c
index 1ebceba57c2..be154d0bb83 100644
--- a/usr.sbin/ldpd/ldpe.c
+++ b/usr.sbin/ldpd/ldpe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpe.c,v 1.83 2024/11/21 13:10:39 claudio Exp $ */
+/* $OpenBSD: ldpe.c,v 1.84 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
@@ -237,10 +237,12 @@ ldpe_dispatch_main(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("ldpe_dispatch_main: imsg_write");
- if (n == 0)
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* connection closed */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
@@ -501,10 +503,12 @@ ldpe_dispatch_lde(int fd, short event, void *bula)
shut = 1;
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("ldpe_dispatch_lde: imsg_write");
- if (n == 0)
- shut = 1;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* connection closed */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
diff --git a/usr.sbin/lpd/proc.c b/usr.sbin/lpd/proc.c
index 13ae6ff496b..39e8d7be54e 100644
--- a/usr.sbin/lpd/proc.c
+++ b/usr.sbin/lpd/proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.c,v 1.3 2024/11/21 13:10:40 claudio Exp $ */
+/* $OpenBSD: proc.c,v 1.4 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2017 Eric Faurot <eric@openbsd.org>
@@ -296,20 +296,11 @@ proc_dispatch(int fd, short event, void *arg)
}
if (event & EV_WRITE) {
- n = imsg_write(&p->imsgbuf);
- switch (n) {
- case -1:
- if (errno == EAGAIN)
- break;
- log_warn("%s: imsg_write", __func__);
- proc_callback(p, NULL);
- return;
- case 0:
- /* This pipe is dead. */
+ if (imsg_write(&p->imsgbuf) == -1) {
+ if (errno != EPIPE)
+ log_warn("%s: imsg_write", __func__);
proc_callback(p, NULL);
return;
- default:
- break;
}
}
diff --git a/usr.sbin/npppd/npppd/control.c b/usr.sbin/npppd/npppd/control.c
index c63c45b91cd..68651fd8b5f 100644
--- a/usr.sbin/npppd/npppd/control.c
+++ b/usr.sbin/npppd/npppd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.9 2024/11/21 13:10:42 claudio Exp $ */
+/* $OpenBSD: control.c,v 1.10 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -252,7 +252,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/usr.sbin/ntpd/control.c b/usr.sbin/ntpd/control.c
index c3bcd6ee787..634ab902d29 100644
--- a/usr.sbin/ntpd/control.c
+++ b/usr.sbin/ntpd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.22 2024/11/21 13:10:44 claudio Exp $ */
+/* $OpenBSD: control.c,v 1.23 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -207,7 +207,7 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt)
}
if (pfd->revents & POLLOUT)
- if (imsg_write(&c->ibuf) <= 0 && errno != EAGAIN) {
+ if (imsg_write(&c->ibuf) == -1) {
*ctl_cnt -= control_close(pfd->fd);
return (1);
}
diff --git a/usr.sbin/ntpd/ntp.c b/usr.sbin/ntpd/ntp.c
index 18897f70e25..cfbb7543d57 100644
--- a/usr.sbin/ntpd/ntp.c
+++ b/usr.sbin/ntpd/ntp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntp.c,v 1.175 2024/11/21 13:10:44 claudio Exp $ */
+/* $OpenBSD: ntp.c,v 1.176 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -365,8 +365,7 @@ ntp_main(struct ntpd_conf *nconf, struct passwd *pw, int argc, char **argv)
}
if (nfds > 0 && (pfd[PFD_PIPE_MAIN].revents & POLLOUT))
- if (imsg_write(ibuf_main) <= 0 &&
- errno != EAGAIN) {
+ if (imsg_write(ibuf_main) == -1) {
log_warn("pipe write error (to parent)");
ntp_quit = 1;
}
@@ -380,8 +379,7 @@ ntp_main(struct ntpd_conf *nconf, struct passwd *pw, int argc, char **argv)
}
if (nfds > 0 && (pfd[PFD_PIPE_DNS].revents & POLLOUT))
- if (imsg_write(ibuf_dns) <= 0 &&
- errno != EAGAIN) {
+ if (imsg_write(ibuf_dns) == -1) {
log_warn("pipe write error (to dns engine)");
ntp_quit = 1;
}
diff --git a/usr.sbin/ntpd/ntp_dns.c b/usr.sbin/ntpd/ntp_dns.c
index d1670970991..3f9813b644e 100644
--- a/usr.sbin/ntpd/ntp_dns.c
+++ b/usr.sbin/ntpd/ntp_dns.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntp_dns.c,v 1.30 2024/11/21 13:10:44 claudio Exp $ */
+/* $OpenBSD: ntp_dns.c,v 1.31 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2003-2008 Henning Brauer <henning@openbsd.org>
@@ -117,8 +117,7 @@ ntp_dns(struct ntpd_conf *nconf, struct passwd *pw)
}
if (nfds > 0 && (pfd[0].revents & POLLOUT))
- if (imsg_write(ibuf_dns) <= 0 &&
- errno != EAGAIN) {
+ if (imsg_write(ibuf_dns) == -1) {
log_warn("pipe write error (to ntp engine)");
quit_dns = 1;
}
diff --git a/usr.sbin/ntpd/ntpd.c b/usr.sbin/ntpd/ntpd.c
index 8e13a071d25..33a7fe049b3 100644
--- a/usr.sbin/ntpd/ntpd.c
+++ b/usr.sbin/ntpd/ntpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntpd.c,v 1.135 2024/11/21 13:10:44 claudio Exp $ */
+/* $OpenBSD: ntpd.c,v 1.136 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -333,7 +333,7 @@ main(int argc, char *argv[])
}
if (nfds > 0 && (pfd[PFD_PIPE].revents & POLLOUT))
- if (imsg_write(ibuf) <= 0 && errno != EAGAIN) {
+ if (imsg_write(ibuf) == -1) {
log_warn("pipe write error (to child)");
quit = 1;
}
diff --git a/usr.sbin/ospf6d/control.c b/usr.sbin/ospf6d/control.c
index 3b17767236a..49810f2bffc 100644
--- a/usr.sbin/ospf6d/control.c
+++ b/usr.sbin/ospf6d/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.33 2024/11/21 13:10:45 claudio Exp $ */
+/* $OpenBSD: control.c,v 1.34 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -259,7 +259,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/usr.sbin/ospf6d/ospf6d.c b/usr.sbin/ospf6d/ospf6d.c
index 818a09b5b4c..5dbe20abf80 100644
--- a/usr.sbin/ospf6d/ospf6d.c
+++ b/usr.sbin/ospf6d/ospf6d.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospf6d.c,v 1.55 2024/11/21 13:10:45 claudio Exp $ */
+/* $OpenBSD: ospf6d.c,v 1.56 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -346,10 +346,12 @@ main_dispatch_ospfe(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 (;;) {
@@ -422,10 +424,12 @@ main_dispatch_rde(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/usr.sbin/ospf6d/ospfe.c b/usr.sbin/ospf6d/ospfe.c
index f0b8cd6b383..2c1f92a06c4 100644
--- a/usr.sbin/ospf6d/ospfe.c
+++ b/usr.sbin/ospf6d/ospfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfe.c,v 1.73 2024/11/21 13:10:45 claudio Exp $ */
+/* $OpenBSD: ospfe.c,v 1.74 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -264,10 +264,12 @@ ospfe_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 (;;) {
@@ -455,10 +457,12 @@ ospfe_dispatch_rde(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/usr.sbin/ospf6d/rde.c b/usr.sbin/ospf6d/rde.c
index 2d8d6b82568..badb021e1a3 100644
--- a/usr.sbin/ospf6d/rde.c
+++ b/usr.sbin/ospf6d/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.92 2024/11/21 13:10:45 claudio Exp $ */
+/* $OpenBSD: rde.c,v 1.93 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -282,10 +282,12 @@ rde_dispatch_imsg(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");
+ }
}
clock_gettime(CLOCK_MONOTONIC, &tp);
@@ -656,10 +658,12 @@ rde_dispatch_parent(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/usr.sbin/ospfd/control.c b/usr.sbin/ospfd/control.c
index 75b195cf020..75f639fca4c 100644
--- a/usr.sbin/ospfd/control.c
+++ b/usr.sbin/ospfd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.49 2024/11/21 13:10:46 claudio Exp $ */
+/* $OpenBSD: control.c,v 1.50 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -259,7 +259,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/usr.sbin/ospfd/ospfd.c b/usr.sbin/ospfd/ospfd.c
index fa7aa398b1e..e2d9567f1eb 100644
--- a/usr.sbin/ospfd/ospfd.c
+++ b/usr.sbin/ospfd/ospfd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfd.c,v 1.118 2024/11/21 13:10:46 claudio Exp $ */
+/* $OpenBSD: ospfd.c,v 1.119 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -364,10 +364,12 @@ main_dispatch_ospfe(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 (;;) {
@@ -450,10 +452,12 @@ main_dispatch_rde(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/usr.sbin/ospfd/ospfe.c b/usr.sbin/ospfd/ospfe.c
index 2de4b330769..6ee806c4000 100644
--- a/usr.sbin/ospfd/ospfe.c
+++ b/usr.sbin/ospfd/ospfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfe.c,v 1.115 2024/11/21 13:10:46 claudio Exp $ */
+/* $OpenBSD: ospfe.c,v 1.116 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -278,10 +278,12 @@ ospfe_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 (;;) {
@@ -500,10 +502,12 @@ ospfe_dispatch_rde(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/usr.sbin/ospfd/rde.c b/usr.sbin/ospfd/rde.c
index 01900e99e96..dc995cbd730 100644
--- a/usr.sbin/ospfd/rde.c
+++ b/usr.sbin/ospfd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.113 2024/11/21 13:10:46 claudio Exp $ */
+/* $OpenBSD: rde.c,v 1.114 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -272,10 +272,12 @@ rde_dispatch_imsg(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");
+ }
}
clock_gettime(CLOCK_MONOTONIC, &tp);
@@ -655,10 +657,12 @@ rde_dispatch_parent(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/usr.sbin/rad/control.c b/usr.sbin/rad/control.c
index d2727528cf9..cfa7f1433c2 100644
--- a/usr.sbin/rad/control.c
+++ b/usr.sbin/rad/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.9 2024/11/21 13:10:47 claudio Exp $ */
+/* $OpenBSD: control.c,v 1.10 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -237,7 +237,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/usr.sbin/rad/engine.c b/usr.sbin/rad/engine.c
index 6847401aaea..f2549e78b1d 100644
--- a/usr.sbin/rad/engine.c
+++ b/usr.sbin/rad/engine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: engine.c,v 1.23 2024/11/21 13:10:47 claudio Exp $ */
+/* $OpenBSD: engine.c,v 1.24 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -200,10 +200,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 (;;) {
@@ -282,10 +284,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/usr.sbin/rad/frontend.c b/usr.sbin/rad/frontend.c
index 4ccbcde819f..8384b8d09b2 100644
--- a/usr.sbin/rad/frontend.c
+++ b/usr.sbin/rad/frontend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: frontend.c,v 1.50 2024/11/21 13:10:47 claudio Exp $ */
+/* $OpenBSD: frontend.c,v 1.51 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -325,10 +325,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 (;;) {
@@ -538,10 +540,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/usr.sbin/rad/rad.c b/usr.sbin/rad/rad.c
index acce6cf714e..b5f5bdc7d18 100644
--- a/usr.sbin/rad/rad.c
+++ b/usr.sbin/rad/rad.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rad.c,v 1.32 2024/11/21 13:10:47 claudio Exp $ */
+/* $OpenBSD: rad.c,v 1.33 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -387,10 +387,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 (;;) {
@@ -455,10 +457,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/usr.sbin/radiusd/control.c b/usr.sbin/radiusd/control.c
index 7f3a6da6b74..422c5a21508 100644
--- a/usr.sbin/radiusd/control.c
+++ b/usr.sbin/radiusd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.2 2024/11/21 13:10:48 claudio Exp $ */
+/* $OpenBSD: control.c,v 1.3 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -259,7 +259,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/usr.sbin/radiusd/radiusd.c b/usr.sbin/radiusd/radiusd.c
index 9fee0b41c61..db8795d890b 100644
--- a/usr.sbin/radiusd/radiusd.c
+++ b/usr.sbin/radiusd/radiusd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: radiusd.c,v 1.56 2024/11/21 13:10:48 claudio Exp $ */
+/* $OpenBSD: radiusd.c,v 1.57 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2013, 2023 Internet Initiative Japan Inc.
@@ -1319,27 +1319,22 @@ static void
radiusd_module_on_imsg_io(int fd, short evmask, void *ctx)
{
struct radiusd_module *module = ctx;
- int ret;
- if (evmask & EV_WRITE)
+ if (evmask & EV_WRITE) {
module->writeready = true;
+ if (imsg_write(&module->ibuf) == -1) {
+ log_warn("Failed to write to module `%s': imsg_write()",
+ module->name);
+ goto on_error;
+ }
+ module->writeready = false;
+ }
if (evmask & EV_READ) {
if (radiusd_module_imsg_read(module) == -1)
goto on_error;
}
- while (module->writeready && module->ibuf.w.queued) {
- ret = imsg_write(&module->ibuf);
- if (ret > 0)
- continue;
- module->writeready = false;
- if (ret == 0 && errno == EAGAIN)
- break;
- log_warn("Failed to write to module `%s': imsg_write()",
- module->name);
- goto on_error;
- }
radiusd_module_reset_ev_handler(module);
return;
diff --git a/usr.sbin/radiusd/radiusd_module.c b/usr.sbin/radiusd/radiusd_module.c
index e9bc7068d5e..b64d6b3e865 100644
--- a/usr.sbin/radiusd/radiusd_module.c
+++ b/usr.sbin/radiusd/radiusd_module.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: radiusd_module.c,v 1.21 2024/11/21 13:10:48 claudio Exp $ */
+/* $OpenBSD: radiusd_module.c,v 1.22 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net>
@@ -631,28 +631,20 @@ module_on_event(int fd, short evmask, void *ctx)
int ret;
base->ev_onhandler = true;
- if (evmask & EV_WRITE)
+ if (evmask & EV_WRITE) {
base->writeready = true;
+ if (imsg_write(&base->ibuf) == -1) {
+ syslog(LOG_ERR, "%s: imsg_write: %m", __func__);
+ module_stop(base);
+ return;
+ }
+ base->writeready = false;
+ }
if (evmask & EV_READ) {
ret = module_recv_imsg(base);
if (ret < 0)
return;
}
- while (base->writeready && base->ibuf.w.queued) {
- ret = imsg_write(&base->ibuf);
- if (ret > 0)
- continue;
- base->writeready = false;
- if (ret == -1 && errno == EAGAIN)
- break;
- if (ret == 0)
- syslog(LOG_ERR, "%s: connection is closed", __func__);
- else
- syslog(LOG_ERR, "%s: imsg_write: %d %m", __func__,
- ret);
- module_stop(base);
- return;
- }
base->ev_onhandler = false;
module_reset_event(base);
return;
diff --git a/usr.sbin/relayd/control.c b/usr.sbin/relayd/control.c
index cbfad0c2c9d..f7203294850 100644
--- a/usr.sbin/relayd/control.c
+++ b/usr.sbin/relayd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.59 2024/11/21 13:10:49 claudio Exp $ */
+/* $OpenBSD: control.c,v 1.60 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -239,7 +239,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/usr.sbin/relayd/proc.c b/usr.sbin/relayd/proc.c
index a458cd0a01d..3424f878da5 100644
--- a/usr.sbin/relayd/proc.c
+++ b/usr.sbin/relayd/proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.c,v 1.47 2024/11/21 13:10:49 claudio Exp $ */
+/* $OpenBSD: proc.c,v 1.48 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2010 - 2016 Reyk Floeter <reyk@openbsd.org>
@@ -612,13 +612,14 @@ proc_dispatch(int fd, short event, void *arg)
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) {
+ /* this pipe is dead, remove the handler */
+ event_del(&iev->ev);
+ event_loopexit(NULL);
+ return;
+ }
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;
}
}
diff --git a/usr.sbin/ripd/control.c b/usr.sbin/ripd/control.c
index fe4aa039afa..3cea757485e 100644
--- a/usr.sbin/ripd/control.c
+++ b/usr.sbin/ripd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.29 2024/11/21 13:10:50 claudio Exp $ */
+/* $OpenBSD: control.c,v 1.30 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -226,7 +226,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/usr.sbin/ripd/rde.c b/usr.sbin/ripd/rde.c
index 7cbb704c942..c27debabbd3 100644
--- a/usr.sbin/ripd/rde.c
+++ b/usr.sbin/ripd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.26 2024/11/21 13:10:50 claudio Exp $ */
+/* $OpenBSD: rde.c,v 1.27 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
@@ -203,10 +203,12 @@ rde_dispatch_imsg(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 (;;) {
@@ -304,10 +306,12 @@ rde_dispatch_parent(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/usr.sbin/ripd/ripd.c b/usr.sbin/ripd/ripd.c
index 96cca81c873..83f4a713a9b 100644
--- a/usr.sbin/ripd/ripd.c
+++ b/usr.sbin/ripd/ripd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ripd.c,v 1.38 2024/11/21 13:10:50 claudio Exp $ */
+/* $OpenBSD: ripd.c,v 1.39 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
@@ -320,10 +320,12 @@ main_dispatch_ripe(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 (;;) {
@@ -398,10 +400,12 @@ main_dispatch_rde(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/usr.sbin/ripd/ripe.c b/usr.sbin/ripd/ripe.c
index 2e04e87d691..3008edd90d5 100644
--- a/usr.sbin/ripd/ripe.c
+++ b/usr.sbin/ripd/ripe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ripe.c,v 1.32 2024/11/21 13:10:50 claudio Exp $ */
+/* $OpenBSD: ripe.c,v 1.33 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
@@ -237,10 +237,12 @@ ripe_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 (;;) {
@@ -316,10 +318,12 @@ ripe_dispatch_rde(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/usr.sbin/smtpd/mproc.c b/usr.sbin/smtpd/mproc.c
index 9b970ce1f81..3f61f7b1aae 100644
--- a/usr.sbin/smtpd/mproc.c
+++ b/usr.sbin/smtpd/mproc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mproc.c,v 1.41 2024/11/21 13:10:51 claudio Exp $ */
+/* $OpenBSD: mproc.c,v 1.42 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@faurot.net>
@@ -164,8 +164,7 @@ mproc_dispatch(int fd, short event, void *arg)
}
if (event & EV_WRITE) {
- n = imsg_write(&p->imsgbuf);
- if (n == 0 || (n == -1 && errno != EAGAIN)) {
+ if (imsg_write(&p->imsgbuf) == -1) {
/* this pipe is dead, so remove the event handler */
log_debug("debug: %s -> %s: pipe closed",
proc_name(smtpd_process), p->name);
diff --git a/usr.sbin/snmpd/proc.c b/usr.sbin/snmpd/proc.c
index 0e0a7f425ce..5557555319d 100644
--- a/usr.sbin/snmpd/proc.c
+++ b/usr.sbin/snmpd/proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.c,v 1.34 2024/11/21 13:10:54 claudio Exp $ */
+/* $OpenBSD: proc.c,v 1.35 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2010 - 2016 Reyk Floeter <reyk@openbsd.org>
@@ -587,13 +587,14 @@ proc_dispatch(int fd, short event, void *arg)
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) {
+ /* this pipe is dead, remove the handler */
+ event_del(&iev->ev);
+ event_loopexit(NULL);
+ return;
+ }
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;
}
}
diff --git a/usr.sbin/vmd/control.c b/usr.sbin/vmd/control.c
index a4022863344..709c5f69c15 100644
--- a/usr.sbin/vmd/control.c
+++ b/usr.sbin/vmd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.44 2024/11/21 13:10:56 claudio Exp $ */
+/* $OpenBSD: control.c,v 1.45 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2010-2015 Reyk Floeter <reyk@openbsd.org>
@@ -388,7 +388,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/usr.sbin/vmd/proc.c b/usr.sbin/vmd/proc.c
index bff988f1ae9..6bb5a905310 100644
--- a/usr.sbin/vmd/proc.c
+++ b/usr.sbin/vmd/proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.c,v 1.28 2024/11/21 13:10:56 claudio Exp $ */
+/* $OpenBSD: proc.c,v 1.29 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2010 - 2016 Reyk Floeter <reyk@openbsd.org>
@@ -603,13 +603,14 @@ proc_dispatch(int fd, short event, void *arg)
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) {
+ /* this pipe is dead, remove the handler */
+ event_del(&iev->ev);
+ event_loopexit(NULL);
+ return;
+ }
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;
}
}
diff --git a/usr.sbin/vmd/vioblk.c b/usr.sbin/vmd/vioblk.c
index 1bd1ba335f4..952fdd840e6 100644
--- a/usr.sbin/vmd/vioblk.c
+++ b/usr.sbin/vmd/vioblk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vioblk.c,v 1.16 2024/11/21 13:10:56 claudio Exp $ */
+/* $OpenBSD: vioblk.c,v 1.17 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2023 Dave Voutila <dv@openbsd.org>
@@ -444,14 +444,15 @@ dev_dispatch_vm(int fd, short event, void *arg)
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) {
+ /* this pipe is dead, remove the handler */
+ log_debug("%s: pipe dead (EV_WRITE)", __func__);
+ event_del(&iev->ev);
+ event_loopexit(NULL);
+ return;
+ }
fatal("%s: imsg_write", __func__);
- if (n == 0) {
- /* this pipe is dead, so remove the event handler */
- log_debug("%s: pipe dead (EV_WRITE)", __func__);
- event_del(&iev->ev);
- event_loopbreak();
- return;
}
}
@@ -511,14 +512,15 @@ handle_sync_io(int fd, short event, void *arg)
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) {
+ /* this pipe is dead, remove the handler */
+ log_debug("%s: pipe dead (EV_WRITE)", __func__);
+ event_del(&iev->ev);
+ event_loopexit(NULL);
+ return;
+ }
fatal("%s: imsg_write", __func__);
- if (n == 0) {
- /* this pipe is dead, so remove the event handler */
- log_debug("%s: vioblk pipe dead (EV_WRITE)", __func__);
- event_del(&iev->ev);
- event_loopexit(NULL);
- return;
}
}
diff --git a/usr.sbin/vmd/vionet.c b/usr.sbin/vmd/vionet.c
index c9be9b473c5..76a12c60e06 100644
--- a/usr.sbin/vmd/vionet.c
+++ b/usr.sbin/vmd/vionet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vionet.c,v 1.18 2024/11/21 13:10:56 claudio Exp $ */
+/* $OpenBSD: vionet.c,v 1.19 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2023 Dave Voutila <dv@openbsd.org>
@@ -915,14 +915,15 @@ dev_dispatch_vm(int fd, short event, void *arg)
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) {
+ /* this pipe is dead, remove the handler */
+ log_debug("%s: pipe dead (EV_WRITE)", __func__);
+ event_del(&iev->ev);
+ event_loopexit(NULL);
+ return;
+ }
fatal("%s: imsg_write", __func__);
- if (n == 0) {
- /* this pipe is dead, so remove the event handler */
- log_debug("%s: pipe dead (EV_WRITE)", __func__);
- event_del(&iev->ev);
- event_base_loopexit(ev_base_main, NULL);
- return;
}
}
@@ -987,14 +988,15 @@ handle_sync_io(int fd, short event, void *arg)
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) {
+ /* this pipe is dead, remove the handler */
+ log_debug("%s: pipe dead (EV_WRITE)", __func__);
+ event_del(&iev->ev);
+ event_loopexit(NULL);
+ return;
+ }
fatal("%s: imsg_write", __func__);
- if (n == 0) {
- /* this pipe is dead, so remove the event handler */
- log_debug("%s: pipe dead (EV_WRITE)", __func__);
- event_del(&iev->ev);
- event_base_loopexit(ev_base_main, NULL);
- return;
}
}
diff --git a/usr.sbin/vmd/virtio.c b/usr.sbin/vmd/virtio.c
index 4cab50c19d7..f4a3d4c2ac0 100644
--- a/usr.sbin/vmd/virtio.c
+++ b/usr.sbin/vmd/virtio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: virtio.c,v 1.118 2024/11/21 13:10:56 claudio Exp $ */
+/* $OpenBSD: virtio.c,v 1.119 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
@@ -1536,14 +1536,15 @@ virtio_dispatch_dev(int fd, short event, void *arg)
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) {
+ /* this pipe is dead, remove the handler */
+ log_debug("%s: pipe dead (EV_WRITE)", __func__);
+ event_del(&iev->ev);
+ event_loopexit(NULL);
+ return;
+ }
fatal("%s: imsg_write", __func__);
- if (n == 0) {
- /* this pipe is dead, so remove the event handler */
- log_debug("%s: pipe dead (EV_WRITE)", __func__);
- event_del(&iev->ev);
- event_loopexit(NULL);
- return;
}
}
diff --git a/usr.sbin/vmd/vm.c b/usr.sbin/vmd/vm.c
index 77f188870fa..2a38ca4e105 100644
--- a/usr.sbin/vmd/vm.c
+++ b/usr.sbin/vmd/vm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm.c,v 1.107 2024/11/21 13:10:56 claudio Exp $ */
+/* $OpenBSD: vm.c,v 1.108 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
@@ -354,10 +354,11 @@ vm_dispatch_vmm(int fd, short event, void *arg)
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE)
+ _exit(0);
fatal("%s: imsg_write fd %d", __func__, ibuf->fd);
- if (n == 0)
- _exit(0);
+ }
}
for (;;) {
diff --git a/usr.sbin/vmd/vmm.c b/usr.sbin/vmd/vmm.c
index 448e83fee96..d32b7a8367b 100644
--- a/usr.sbin/vmd/vmm.c
+++ b/usr.sbin/vmd/vmm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmm.c,v 1.126 2024/11/21 13:10:56 claudio Exp $ */
+/* $OpenBSD: vmm.c,v 1.127 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
@@ -505,12 +505,13 @@ vmm_dispatch_vm(int fd, short event, void *arg)
}
if (event & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) {
+ /* This pipe is dead, remove the handler */
+ event_del(&iev->ev);
+ return;
+ }
fatal("%s: imsg_write fd %d", __func__, ibuf->fd);
- if (n == 0) {
- /* This pipe is dead, so remove the event handler */
- event_del(&iev->ev);
- return;
}
}
diff --git a/usr.sbin/ypldap/ldapclient.c b/usr.sbin/ypldap/ldapclient.c
index 0b4ac02f84a..dc8c1b172d9 100644
--- a/usr.sbin/ypldap/ldapclient.c
+++ b/usr.sbin/ypldap/ldapclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldapclient.c,v 1.51 2024/11/21 13:10:57 claudio Exp $ */
+/* $OpenBSD: ldapclient.c,v 1.52 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2008 Alexander Schrijver <aschrijver@openbsd.org>
@@ -147,11 +147,12 @@ client_dispatch_dns(int fd, short events, void *p)
shut = 1;
}
if (events & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0)
- shut = 1;
- goto done;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* connection closed */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
@@ -217,7 +218,6 @@ client_dispatch_dns(int fd, short events, void *p)
imsg_compose_event(env->sc_iev, IMSG_END_UPDATE, 0, 0, -1,
NULL, 0);
-done:
if (!shut)
imsg_event_add(iev);
else {
@@ -247,11 +247,12 @@ client_dispatch_parent(int fd, short events, void *p)
shut = 1;
}
if (events & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0)
- shut = 1;
- goto done;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* connection closed */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
@@ -303,7 +304,6 @@ client_dispatch_parent(int fd, short events, void *p)
imsg_free(&imsg);
}
-done:
if (!shut)
imsg_event_add(iev);
else {
diff --git a/usr.sbin/ypldap/ypldap.c b/usr.sbin/ypldap/ypldap.c
index cfe305651cd..6ff15ae9b44 100644
--- a/usr.sbin/ypldap/ypldap.c
+++ b/usr.sbin/ypldap/ypldap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ypldap.c,v 1.26 2024/11/21 13:10:57 claudio Exp $ */
+/* $OpenBSD: ypldap.c,v 1.27 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -367,11 +367,12 @@ main_dispatch_client(int fd, short events, void *p)
shut = 1;
}
if (events & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0)
- shut = 1;
- goto done;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* connection closed */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
@@ -451,7 +452,6 @@ main_dispatch_client(int fd, short events, void *p)
imsg_free(&imsg);
}
-done:
if (!shut)
imsg_event_add(iev);
else {
diff --git a/usr.sbin/ypldap/ypldap_dns.c b/usr.sbin/ypldap/ypldap_dns.c
index be97958e6f3..0238b5e0296 100644
--- a/usr.sbin/ypldap/ypldap_dns.c
+++ b/usr.sbin/ypldap/ypldap_dns.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ypldap_dns.c,v 1.17 2024/11/21 13:10:57 claudio Exp $ */
+/* $OpenBSD: ypldap_dns.c,v 1.18 2024/11/21 13:16:07 claudio Exp $ */
/*
* Copyright (c) 2003-2008 Henning Brauer <henning@openbsd.org>
@@ -152,11 +152,12 @@ dns_dispatch_imsg(int fd, short events, void *p)
shut = 1;
}
if (events & EV_WRITE) {
- if ((n = imsg_write(ibuf)) == -1 && errno != EAGAIN)
- fatal("imsg_write");
- if (n == 0)
- shut = 1;
- goto done;
+ if (imsg_write(ibuf) == -1) {
+ if (errno == EPIPE) /* connection closed */
+ shut = 1;
+ else
+ fatal("imsg_write");
+ }
}
for (;;) {
@@ -198,7 +199,6 @@ dns_dispatch_imsg(int fd, short events, void *p)
imsg_free(&imsg);
}
-done:
if (!shut)
imsg_event_add(iev);
else {