From 9c8d00dd06d79ba9fccf07c45cd1bdae73e744c5 Mon Sep 17 00:00:00 2001 From: Claudio Jeker Date: Thu, 21 Nov 2024 13:16:08 +0000 Subject: Convert imsg_write() callers to the new simplified return logic. OK tb@ --- usr.sbin/ripd/control.c | 4 ++-- usr.sbin/ripd/rde.c | 22 +++++++++++++--------- usr.sbin/ripd/ripd.c | 22 +++++++++++++--------- usr.sbin/ripd/ripe.c | 22 +++++++++++++--------- 4 files changed, 41 insertions(+), 29 deletions(-) (limited to 'usr.sbin/ripd') 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 @@ -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 @@ -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 @@ -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 @@ -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 (;;) { -- cgit v1.2.3