Browse Source

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@
OPENBSD_5_9
claudio 9 years ago
parent
commit
a3ecc333c4
2 changed files with 7 additions and 9 deletions
  1. +4
    -6
      src/lib/libutil/imsg.c
  2. +3
    -3
      src/lib/libutil/imsg_init.3

+ 4
- 6
src/lib/libutil/imsg.c View File

@ -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> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -80,11 +80,9 @@ again:
} }
if ((n = recvmsg(ibuf->fd, &msg, 0)) == -1) { 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; ibuf->r.wpos += n;


+ 3
- 3
src/lib/libutil/imsg_init.3 View File

@ -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> .\" Copyright (c) 2010 Nicholas Marriott <nicm@openbsd.org>
.\" .\"
@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" 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 .Dt IMSG_INIT 3
.Os .Os
.Sh NAME .Sh NAME
@ -515,7 +515,7 @@ dispatch_imsg(struct imsgbuf *ibuf)
ssize_t n, datalen; ssize_t n, datalen;
int idata; int idata;
if ((n = imsg_read(ibuf)) == -1 || n == 0) {
if (((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) || n == 0) {
/* handle socket error */ /* handle socket error */
} }


Loading…
Cancel
Save