diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2024-11-21 13:22:22 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2024-11-21 13:22:22 +0000 |
commit | 04680bddaa98c8fdfb03ae7b64f655df13c2fc94 (patch) | |
tree | 176e3a7731ace2024dc13f24870554b24cf856e7 /usr.sbin/bgpd | |
parent | 1a0eb6e692853cb677467310a038e5fe280f3699 (diff) |
bgpd and smtpd include their own imsgbuf_read_nofd() implementation.
Adjust that one as well apart from that the conversion to the new
imsgbuf_read read behaviour is trivial.
OK tb@
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r-- | usr.sbin/bgpd/bgpd.c | 4 | ||||
-rw-r--r-- | usr.sbin/bgpd/control.c | 17 |
2 files changed, 12 insertions, 9 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c index 8e34809d92d..6e5836a10e5 100644 --- a/usr.sbin/bgpd/bgpd.c +++ b/usr.sbin/bgpd/bgpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.c,v 1.275 2024/11/21 13:18:38 claudio Exp $ */ +/* $OpenBSD: bgpd.c,v 1.276 2024/11/21 13:22:21 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -1281,7 +1281,7 @@ handle_pollfd(struct pollfd *pfd, struct imsgbuf *i) } if (pfd->revents & POLLIN) { - if ((n = imsgbuf_read(i)) == -1 && errno != EAGAIN) { + if ((n = imsgbuf_read(i)) == -1) { log_warn("imsg read error"); close(i->fd); i->fd = -1; diff --git a/usr.sbin/bgpd/control.c b/usr.sbin/bgpd/control.c index 3f5540ddabe..ea9b1f8730f 100644 --- a/usr.sbin/bgpd/control.c +++ b/usr.sbin/bgpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.126 2024/11/21 13:18:38 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.127 2024/11/21 13:22:21 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -37,7 +37,7 @@ struct ctl_conn *control_connbyfd(int); struct ctl_conn *control_connbypid(pid_t); int control_close(struct ctl_conn *); void control_result(struct ctl_conn *, u_int); -ssize_t imsgbuf_read_nofd(struct imsgbuf *); +int imsgbuf_read_nofd(struct imsgbuf *); int control_check(char *path) @@ -261,8 +261,7 @@ control_dispatch_msg(struct pollfd *pfd, struct peer_head *peers) if (!(pfd->revents & POLLIN)) return (0); - if (((n = imsgbuf_read_nofd(&c->imsgbuf)) == -1 && errno != EAGAIN) || - n == 0) + if (imsgbuf_read_nofd(&c->imsgbuf) != 1) return control_close(c); for (;;) { @@ -596,7 +595,7 @@ control_result(struct ctl_conn *c, u_int code) } /* This should go into libutil, from smtpd/mproc.c */ -ssize_t +int imsgbuf_read_nofd(struct imsgbuf *imsgbuf) { ssize_t n; @@ -607,10 +606,14 @@ imsgbuf_read_nofd(struct imsgbuf *imsgbuf) len = sizeof(imsgbuf->r.buf) - imsgbuf->r.wpos; while ((n = recv(imsgbuf->fd, buf, len, 0)) == -1) { + if (errno == EAGAIN) + return (1); if (errno != EINTR) - return (n); + return (-1); } + if (n == 0) + return (0); imsgbuf->r.wpos += n; - return (n); + return (1); } |