Browse Source

EAGAIN handling for imsg_read. OK henning@ benno@

OPENBSD_5_9
claudio 9 years ago
parent
commit
d6e39ab1f4
5 changed files with 12 additions and 11 deletions
  1. +3
    -2
      src/usr.sbin/ntpd/constraint.c
  2. +2
    -2
      src/usr.sbin/ntpd/control.c
  3. +2
    -2
      src/usr.sbin/ntpd/ntp.c
  4. +2
    -2
      src/usr.sbin/ntpd/ntp_dns.c
  5. +3
    -3
      src/usr.sbin/ntpd/ntpd.c

+ 3
- 2
src/usr.sbin/ntpd/constraint.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: constraint.c,v 1.22 2015/11/24 01:03:25 deraadt Exp $ */
/* $OpenBSD: constraint.c,v 1.23 2015/12/05 13:12:16 claudio Exp $ */
/* /*
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org> * Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
@ -27,6 +27,7 @@
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <fcntl.h> #include <fcntl.h>
@ -526,7 +527,7 @@ priv_constraint_dispatch(struct pollfd *pfd)
if (!(pfd->revents & POLLIN)) if (!(pfd->revents & POLLIN))
return (0); return (0);
if ((n = imsg_read(&cstr->ibuf)) == -1 || n == 0) {
if (((n = imsg_read(&cstr->ibuf)) == -1 && errno != EAGAIN) || n == 0) {
priv_constraint_close(pfd->fd, 1); priv_constraint_close(pfd->fd, 1);
return (1); return (1);
} }


+ 2
- 2
src/usr.sbin/ntpd/control.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: control.c,v 1.8 2015/11/20 18:53:42 tedu Exp $ */
/* $OpenBSD: control.c,v 1.9 2015/12/05 13:12:16 claudio Exp $ */
/* /*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -195,7 +195,7 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt)
if (!(pfd->revents & POLLIN)) if (!(pfd->revents & POLLIN))
return (0); return (0);
if ((n = imsg_read(&c->ibuf)) == -1 || n == 0) {
if (((n = imsg_read(&c->ibuf)) == -1 && errno != EAGAIN) || n == 0) {
*ctl_cnt -= control_close(pfd->fd); *ctl_cnt -= control_close(pfd->fd);
return (1); return (1);
} }


+ 2
- 2
src/usr.sbin/ntpd/ntp.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: ntp.c,v 1.139 2015/10/30 16:41:53 reyk Exp $ */
/* $OpenBSD: ntp.c,v 1.140 2015/12/05 13:12:16 claudio Exp $ */
/* /*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -428,7 +428,7 @@ ntp_dispatch_imsg(void)
struct imsg imsg; struct imsg imsg;
int n; int n;
if ((n = imsg_read(ibuf_main)) == -1)
if ((n = imsg_read(ibuf_main)) == -1 && errno != EAGAIN)
return (-1); return (-1);
if (n == 0) { /* connection closed */ if (n == 0) { /* connection closed */


+ 2
- 2
src/usr.sbin/ntpd/ntp_dns.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: ntp_dns.c,v 1.14 2015/10/25 10:52:48 deraadt Exp $ */
/* $OpenBSD: ntp_dns.c,v 1.15 2015/12/05 13:12:16 claudio Exp $ */
/* /*
* Copyright (c) 2003-2008 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003-2008 Henning Brauer <henning@openbsd.org>
@ -145,7 +145,7 @@ dns_dispatch_imsg(void)
struct ibuf *buf; struct ibuf *buf;
const char *str; const char *str;
if ((n = imsg_read(ibuf_dns)) == -1)
if ((n = imsg_read(ibuf_dns)) == -1 && errno != EAGAIN)
return (-1); return (-1);
if (n == 0) { /* connection closed */ if (n == 0) { /* connection closed */


+ 3
- 3
src/usr.sbin/ntpd/ntpd.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: ntpd.c,v 1.99 2015/11/24 01:03:25 deraadt Exp $ */
/* $OpenBSD: ntpd.c,v 1.100 2015/12/05 13:12:16 claudio Exp $ */
/* /*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -357,7 +357,7 @@ dispatch_imsg(struct ntpd_conf *lconf, const char *pw_dir,
int n; int n;
double d; double d;
if ((n = imsg_read(ibuf)) == -1)
if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN)
return (-1); return (-1);
if (n == 0) { /* connection closed */ if (n == 0) { /* connection closed */
@ -662,7 +662,7 @@ ctl_main(int argc, char *argv[])
done = 0; done = 0;
while (!done) { while (!done) {
if ((n = imsg_read(ibuf_ctl)) == -1)
if ((n = imsg_read(ibuf_ctl)) == -1 && errno != EAGAIN)
err(1, "ibuf_ctl: imsg_read error"); err(1, "ibuf_ctl: imsg_read error");
if (n == 0) if (n == 0)
errx(1, "ntpctl: pipe closed"); errx(1, "ntpctl: pipe closed");


Loading…
Cancel
Save