summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2015-12-05 13:19:33 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2015-12-05 13:19:33 +0000
commit0648ea46221b09f66f978f53ba414674e8eaa362 (patch)
treef0706728f9d4e85487b2c870c4399f8e812a8536
parent1478b73ab35c053d01a295a6665054dd97d685d8 (diff)
EAGAIN handling for imsg_read. OK henning@ benno@
-rw-r--r--usr.bin/file/file.c6
-rw-r--r--usr.bin/tmux/proc.c5
-rw-r--r--usr.sbin/ldapctl/ldapctl.c4
-rw-r--r--usr.sbin/npppctl/npppctl.c5
-rw-r--r--usr.sbin/npppd/npppd/control.c8
-rw-r--r--usr.sbin/npppd/npppd/privsep.c4
6 files changed, 18 insertions, 14 deletions
diff --git a/usr.bin/file/file.c b/usr.bin/file/file.c
index 771b69b35d7..1f5e8336f81 100644
--- a/usr.bin/file/file.c
+++ b/usr.bin/file/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.55 2015/11/13 08:32:10 nicm Exp $ */
+/* $OpenBSD: file.c,v 1.56 2015/12/05 13:18:09 claudio Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
@@ -289,7 +289,9 @@ read_message(struct imsgbuf *ibuf, struct imsg *imsg, pid_t from)
{
int n;
- if ((n = imsg_read(ibuf)) == -1)
+ while ((n = imsg_read(ibuf)) == -1 && errno == EAGAIN)
+ /* nothing */ ;
+ if (n == -1)
err(1, "imsg_read");
if (n == 0)
return (0);
diff --git a/usr.bin/tmux/proc.c b/usr.bin/tmux/proc.c
index c0b27755ef0..1f3ff96e631 100644
--- a/usr.bin/tmux/proc.c
+++ b/usr.bin/tmux/proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.c,v 1.6 2015/11/24 21:32:36 nicm Exp $ */
+/* $OpenBSD: proc.c,v 1.7 2015/12/05 13:18:24 claudio Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -61,7 +61,8 @@ proc_event_cb(__unused int fd, short events, void *arg)
struct imsg imsg;
if (!(peer->flags & PEER_BAD) && (events & EV_READ)) {
- if ((n = imsg_read(&peer->ibuf)) == -1 || n == 0) {
+ if (((n = imsg_read(&peer->ibuf)) == -1 && errno != EAGAIN) ||
+ n == 0) {
peer->dispatchcb(NULL, peer->arg);
return;
}
diff --git a/usr.sbin/ldapctl/ldapctl.c b/usr.sbin/ldapctl/ldapctl.c
index 2c3e3a2b01b..db429978340 100644
--- a/usr.sbin/ldapctl/ldapctl.c
+++ b/usr.sbin/ldapctl/ldapctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldapctl.c,v 1.6 2015/11/01 07:39:28 jmatthew Exp $ */
+/* $OpenBSD: ldapctl.c,v 1.7 2015/12/05 13:19:13 claudio Exp $ */
/*
* Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se>
@@ -342,7 +342,7 @@ main(int argc, char *argv[])
err(1, "write error");
while (!done) {
- if ((n = imsg_read(&ibuf)) == -1)
+ if ((n = imsg_read(&ibuf)) == -1 && errno != EAGAIN)
errx(1, "imsg_read error");
if (n == 0)
errx(1, "pipe closed");
diff --git a/usr.sbin/npppctl/npppctl.c b/usr.sbin/npppctl/npppctl.c
index 3ee8af9c8c1..ef6aaacf058 100644
--- a/usr.sbin/npppctl/npppctl.c
+++ b/usr.sbin/npppctl/npppctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: npppctl.c,v 1.5 2015/01/19 01:48:57 deraadt Exp $ */
+/* $OpenBSD: npppctl.c,v 1.6 2015/12/05 13:19:32 claudio Exp $ */
/*
* Copyright (c) 2012 Internet Initiative Japan Inc.
@@ -519,7 +519,8 @@ imsg_wait_command_completion(void)
return (-1);
if (n != 0)
break;
- if ((n = imsg_read(&ctl_ibuf)) == -1 || n == 0)
+ if (((n = imsg_read(&ctl_ibuf)) == -1 && errno != EAGAIN) ||
+ n == 0)
return (-1);
} while (1);
diff --git a/usr.sbin/npppd/npppd/control.c b/usr.sbin/npppd/npppd/control.c
index 54fb8081c71..03fb68a2723 100644
--- a/usr.sbin/npppd/npppd/control.c
+++ b/usr.sbin/npppd/npppd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.3 2015/01/19 01:48:59 deraadt Exp $ */
+/* $OpenBSD: control.c,v 1.4 2015/12/05 13:19:32 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -262,12 +262,12 @@ control_dispatch_imsg(int fd, short event, void *arg)
return;
}
if (event & EV_READ) {
- if ((n = imsg_read(&c->iev.ibuf)) == -1 || n == 0) {
+ if (((n = imsg_read(&c->iev.ibuf)) == -1 && errno != EAGAIN) ||
+ n == 0) {
control_close(fd, cs);
return;
}
- } else
- fatalx("unknown event");
+ }
for (;;) {
if ((n = imsg_get(&c->iev.ibuf, &imsg)) == -1) {
diff --git a/usr.sbin/npppd/npppd/privsep.c b/usr.sbin/npppd/npppd/privsep.c
index 9726366c43f..68b64ea8a9e 100644
--- a/usr.sbin/npppd/npppd/privsep.c
+++ b/usr.sbin/npppd/npppd/privsep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: privsep.c,v 1.18 2015/10/11 07:32:06 guenther Exp $ */
+/* $OpenBSD: privsep.c,v 1.19 2015/12/05 13:19:32 claudio Exp $ */
/*
* Copyright (c) 2010 Yasuoka Masahiko <yasuoka@openbsd.org>
@@ -956,7 +956,7 @@ imsg_read_and_get(struct imsgbuf *ibuf, struct imsg *imsg)
for (;;) {
if ((n = imsg_read(ibuf)) <= 0) {
- if (n == 0 && (errno == EAGAIN || errno == EINTR))
+ if (n == -1 && (errno == EAGAIN || errno == EINTR))
continue;
return (-1);
}