summaryrefslogtreecommitdiff
path: root/usr.sbin/radiusd
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 /usr.sbin/radiusd
parent2e2a93ef22aa29ad33b76ca24ca1ffc708c7d123 (diff)
Convert imsg_write() callers to the new simplified return logic.
OK tb@
Diffstat (limited to 'usr.sbin/radiusd')
-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
3 files changed, 20 insertions, 33 deletions
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;