From a3ecc333c421dc699a6d803464667b27431f1798 Mon Sep 17 00:00:00 2001 From: claudio <> Date: Sat, 5 Dec 2015 13:06:52 +0000 Subject: [PATCH] Do not loop on EAGAIN in imsg_read(). Better to return the error to the caller and let him do another poll loop. This fixes spinning relayd processes seen on busy TLS relays. OK benno@ henning@ --- src/lib/libutil/imsg.c | 10 ++++------ src/lib/libutil/imsg_init.3 | 6 +++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/lib/libutil/imsg.c b/src/lib/libutil/imsg.c index 8a50aa51..fbd44130 100644 --- a/src/lib/libutil/imsg.c +++ b/src/lib/libutil/imsg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imsg.c,v 1.11 2015/11/27 01:57:59 mmcc Exp $ */ +/* $OpenBSD: imsg.c,v 1.12 2015/12/05 13:06:52 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -80,11 +80,9 @@ again: } if ((n = recvmsg(ibuf->fd, &msg, 0)) == -1) { - if (errno == EMSGSIZE) - goto fail; - if (errno != EINTR && errno != EAGAIN) - goto fail; - goto again; + if (errno == EINTR) + goto again; + goto fail; } ibuf->r.wpos += n; diff --git a/src/lib/libutil/imsg_init.3 b/src/lib/libutil/imsg_init.3 index 297b5790..e15d1e3d 100644 --- a/src/lib/libutil/imsg_init.3 +++ b/src/lib/libutil/imsg_init.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: imsg_init.3,v 1.13 2015/07/11 16:23:59 deraadt Exp $ +.\" $OpenBSD: imsg_init.3,v 1.14 2015/12/05 13:06:52 claudio Exp $ .\" .\" Copyright (c) 2010 Nicholas Marriott .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: July 11 2015 $ +.Dd $Mdocdate: December 5 2015 $ .Dt IMSG_INIT 3 .Os .Sh NAME @@ -515,7 +515,7 @@ dispatch_imsg(struct imsgbuf *ibuf) ssize_t n, datalen; int idata; - if ((n = imsg_read(ibuf)) == -1 || n == 0) { + if (((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) || n == 0) { /* handle socket error */ }