Browse Source

from sthen: handle msgbuf_write() returning EAGAIN

ok krw
OPENBSD_5_5
benno 11 years ago
parent
commit
b7644de136
4 changed files with 13 additions and 10 deletions
  1. +2
    -2
      src/usr.sbin/ntpd/control.c
  2. +5
    -3
      src/usr.sbin/ntpd/ntp.c
  3. +3
    -2
      src/usr.sbin/ntpd/ntp_dns.c
  4. +3
    -3
      src/usr.sbin/ntpd/ntpd.c

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

@ -1,4 +1,4 @@
/* $OpenBSD: control.c,v 1.1 2013/10/04 14:28:16 phessler Exp $ */
/* $OpenBSD: control.c,v 1.2 2013/11/13 20:44:39 benno Exp $ */
/* /*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -184,7 +184,7 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt)
} }
if (pfd->revents & POLLOUT) if (pfd->revents & POLLOUT)
if (msgbuf_write(&c->ibuf.w) < 0) {
if (msgbuf_write(&c->ibuf.w) <= 0 && errno != EAGAIN) {
*ctl_cnt -= control_close(pfd->fd); *ctl_cnt -= control_close(pfd->fd);
return (1); return (1);
} }


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

@ -1,4 +1,4 @@
/* $OpenBSD: ntp.c,v 1.119 2013/10/04 14:28:16 phessler Exp $ */
/* $OpenBSD: ntp.c,v 1.120 2013/11/13 20:44:39 benno Exp $ */
/* /*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -335,7 +335,8 @@ ntp_main(int pipe_prnt[2], int fd_ctl, struct ntpd_conf *nconf,
} }
if (nfds > 0 && (pfd[PFD_PIPE_MAIN].revents & POLLOUT)) if (nfds > 0 && (pfd[PFD_PIPE_MAIN].revents & POLLOUT))
if (msgbuf_write(&ibuf_main->w) < 0) {
if (msgbuf_write(&ibuf_main->w) <= 0 &&
errno != EAGAIN) {
log_warn("pipe write error (to parent)"); log_warn("pipe write error (to parent)");
ntp_quit = 1; ntp_quit = 1;
} }
@ -347,7 +348,8 @@ ntp_main(int pipe_prnt[2], int fd_ctl, struct ntpd_conf *nconf,
} }
if (nfds > 0 && (pfd[PFD_PIPE_DNS].revents & POLLOUT)) if (nfds > 0 && (pfd[PFD_PIPE_DNS].revents & POLLOUT))
if (msgbuf_write(&ibuf_dns->w) < 0) {
if (msgbuf_write(&ibuf_dns->w) <= 0 &&
errno != EAGAIN) {
log_warn("pipe write error (to dns engine)"); log_warn("pipe write error (to dns engine)");
ntp_quit = 1; ntp_quit = 1;
} }


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

@ -1,4 +1,4 @@
/* $OpenBSD: ntp_dns.c,v 1.3 2010/05/26 13:56:08 nicm Exp $ */
/* $OpenBSD: ntp_dns.c,v 1.4 2013/11/13 20:44:39 benno Exp $ */
/* /*
* Copyright (c) 2003-2008 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003-2008 Henning Brauer <henning@openbsd.org>
@ -97,7 +97,8 @@ ntp_dns(int pipe_ntp[2], struct ntpd_conf *nconf, struct passwd *pw)
} }
if (nfds > 0 && (pfd[0].revents & POLLOUT)) if (nfds > 0 && (pfd[0].revents & POLLOUT))
if (msgbuf_write(&ibuf_dns->w) < 0) {
if (msgbuf_write(&ibuf_dns->w) <= 0 &&
errno != EAGAIN) {
log_warn("pipe write error (to ntp engine)"); log_warn("pipe write error (to ntp engine)");
quit_dns = 1; quit_dns = 1;
} }


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

@ -1,4 +1,4 @@
/* $OpenBSD: ntpd.c,v 1.74 2013/10/16 21:23:59 jmc Exp $ */
/* $OpenBSD: ntpd.c,v 1.75 2013/11/13 20:44:39 benno Exp $ */
/* /*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -217,7 +217,7 @@ main(int argc, char *argv[])
} }
if (nfds > 0 && (pfd[PFD_PIPE].revents & POLLOUT)) if (nfds > 0 && (pfd[PFD_PIPE].revents & POLLOUT))
if (msgbuf_write(&ibuf->w) < 0) {
if (msgbuf_write(&ibuf->w) <= 0 && errno != EAGAIN) {
log_warn("pipe write error (to child)"); log_warn("pipe write error (to child)");
quit = 1; quit = 1;
} }
@ -597,7 +597,7 @@ ctl_main(int argc, char *argv[])
} }
while (ibuf_ctl->w.queued) while (ibuf_ctl->w.queued)
if (msgbuf_write(&ibuf_ctl->w) < 0)
if (msgbuf_write(&ibuf_ctl->w) <= 0 && errno != EAGAIN)
err(1, "ibuf_ctl: msgbuf_write error"); err(1, "ibuf_ctl: msgbuf_write error");
done = 0; done = 0;


Loading…
Cancel
Save