From b7644de13657ad877fd3401e70e01e7af0832b6e Mon Sep 17 00:00:00 2001 From: benno <> Date: Wed, 13 Nov 2013 20:44:39 +0000 Subject: [PATCH] from sthen: handle msgbuf_write() returning EAGAIN ok krw --- src/usr.sbin/ntpd/control.c | 4 ++-- src/usr.sbin/ntpd/ntp.c | 8 +++++--- src/usr.sbin/ntpd/ntp_dns.c | 5 +++-- src/usr.sbin/ntpd/ntpd.c | 6 +++--- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/usr.sbin/ntpd/control.c b/src/usr.sbin/ntpd/control.c index 121e5a47..88dc7913 100644 --- a/src/usr.sbin/ntpd/control.c +++ b/src/usr.sbin/ntpd/control.c @@ -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 @@ -184,7 +184,7 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt) } 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); return (1); } diff --git a/src/usr.sbin/ntpd/ntp.c b/src/usr.sbin/ntpd/ntp.c index a91dabb2..efe7ddcf 100644 --- a/src/usr.sbin/ntpd/ntp.c +++ b/src/usr.sbin/ntpd/ntp.c @@ -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 @@ -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 (msgbuf_write(&ibuf_main->w) < 0) { + if (msgbuf_write(&ibuf_main->w) <= 0 && + errno != EAGAIN) { log_warn("pipe write error (to parent)"); 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 (msgbuf_write(&ibuf_dns->w) < 0) { + if (msgbuf_write(&ibuf_dns->w) <= 0 && + errno != EAGAIN) { log_warn("pipe write error (to dns engine)"); ntp_quit = 1; } diff --git a/src/usr.sbin/ntpd/ntp_dns.c b/src/usr.sbin/ntpd/ntp_dns.c index 59d22a8b..44148fe2 100644 --- a/src/usr.sbin/ntpd/ntp_dns.c +++ b/src/usr.sbin/ntpd/ntp_dns.c @@ -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 @@ -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 (msgbuf_write(&ibuf_dns->w) < 0) { + if (msgbuf_write(&ibuf_dns->w) <= 0 && + errno != EAGAIN) { log_warn("pipe write error (to ntp engine)"); quit_dns = 1; } diff --git a/src/usr.sbin/ntpd/ntpd.c b/src/usr.sbin/ntpd/ntpd.c index f2c76050..53433c55 100644 --- a/src/usr.sbin/ntpd/ntpd.c +++ b/src/usr.sbin/ntpd/ntpd.c @@ -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 @@ -217,7 +217,7 @@ main(int argc, char *argv[]) } 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)"); quit = 1; } @@ -597,7 +597,7 @@ ctl_main(int argc, char *argv[]) } 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"); done = 0;