diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2024-11-21 13:16:08 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2024-11-21 13:16:08 +0000 |
commit | 9c8d00dd06d79ba9fccf07c45cd1bdae73e744c5 (patch) | |
tree | 9dbbc9d2f725d8ee1474850be3abaff593b88fe4 /usr.sbin/ldpd | |
parent | 2e2a93ef22aa29ad33b76ca24ca1ffc708c7d123 (diff) |
Convert imsg_write() callers to the new simplified return logic.
OK tb@
Diffstat (limited to 'usr.sbin/ldpd')
-rw-r--r-- | usr.sbin/ldpd/control.c | 4 | ||||
-rw-r--r-- | usr.sbin/ldpd/lde.c | 22 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpd.c | 22 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpe.c | 22 |
4 files changed, 41 insertions, 29 deletions
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 (;;) { |