summaryrefslogtreecommitdiffstats
path: root/lib/libutil
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2015-12-05 13:06:52 +0000
committerclaudio <claudio@openbsd.org>2015-12-05 13:06:52 +0000
commitc647c61c14f341e0bca2c15e08887ff1b5185443 (patch)
treeffe8983a1267be8d5fb1e7053a2645af23069c1a /lib/libutil
parentPledge ospfd SE ("stdio inet mcast") and RDE ("stdio") move some code (diff)
downloadwireguard-openbsd-c647c61c14f341e0bca2c15e08887ff1b5185443.tar.xz
wireguard-openbsd-c647c61c14f341e0bca2c15e08887ff1b5185443.zip
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@
Diffstat (limited to 'lib/libutil')
-rw-r--r--lib/libutil/imsg.c10
-rw-r--r--lib/libutil/imsg_init.36
2 files changed, 7 insertions, 9 deletions
diff --git a/lib/libutil/imsg.c b/lib/libutil/imsg.c
index 8a50aa5142b..fbd44130da5 100644
--- a/lib/libutil/imsg.c
+++ b/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 <henning@openbsd.org>
@@ -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/lib/libutil/imsg_init.3 b/lib/libutil/imsg_init.3
index 297b5790f92..e15d1e3d2cd 100644
--- a/lib/libutil/imsg_init.3
+++ b/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 <nicm@openbsd.org>
.\"
@@ -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 */
}