summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Zalamena <rzalamena@cvs.openbsd.org>2016-10-18 22:05:48 +0000
committerRafael Zalamena <rzalamena@cvs.openbsd.org>2016-10-18 22:05:48 +0000
commit651616045275a7900a84ae956ac7551fb237d9e5 (patch)
treea1722e3095b368232aa6bf4581fd7cb019555a15
parentd580b880b3730ad9f3e37a52aec4837078879a3d (diff)
Check for EAGAIN on imsg_flush() return otherwise we might be failing
to send message to the child process. Do like we learned in httpd(8). ok deraadt@
-rw-r--r--usr.sbin/ntpd/constraint.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/usr.sbin/ntpd/constraint.c b/usr.sbin/ntpd/constraint.c
index 0ec4e91cd90..4234a6a30f7 100644
--- a/usr.sbin/ntpd/constraint.c
+++ b/usr.sbin/ntpd/constraint.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: constraint.c,v 1.33 2016/10/18 21:57:19 rzalamena Exp $ */
+/* $OpenBSD: constraint.c,v 1.34 2016/10/18 22:05:47 rzalamena Exp $ */
/*
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
@@ -217,6 +217,7 @@ priv_constraint_msg(u_int32_t id, u_int8_t *data, size_t len, int argc,
struct ntp_addr *h;
struct constraint *cstr;
int pipes[2];
+ int rv;
if ((cstr = constraint_byid(id)) != NULL) {
log_warnx("IMSG_CONSTRAINT_QUERY repeated for id %d", id);
@@ -256,8 +257,11 @@ priv_constraint_msg(u_int32_t id, u_int8_t *data, size_t len, int argc,
if (imsg_compose(&cstr->ibuf, IMSG_CONSTRAINT_QUERY, id, 0, -1,
data, len) == -1)
fatal("%s: imsg_compose", __func__);
- if (imsg_flush(&cstr->ibuf) == -1)
- fatal("%s: imsg_flush", __func__);
+ do {
+ rv = imsg_flush(&cstr->ibuf);
+ } while (rv == -1 && errno == EAGAIN);
+ if (rv == -1)
+ fatal("imsg_flush");
/*
* Fork child handlers and make sure to do any sensitive work in the
@@ -325,7 +329,7 @@ priv_constraint_child(const char *pw_dir, uid_t pw_uid, gid_t pw_gid)
struct sigaction sa;
void *ctx;
struct iovec iov[2];
- int i;
+ int i, rv;
log_procinit("constraint");
@@ -420,7 +424,9 @@ priv_constraint_child(const char *pw_dir, uid_t pw_uid, gid_t pw_gid)
iov[1].iov_len = sizeof(xmttv);
imsg_composev(&cstr->ibuf,
IMSG_CONSTRAINT_RESULT, 0, 0, -1, iov, 2);
- imsg_flush(&cstr->ibuf);
+ do {
+ rv = imsg_flush(&cstr->ibuf);
+ } while (rv == -1 && errno == EAGAIN);
/* Tear down the TLS connection after sending the result */
httpsdate_free(ctx);