From d9530a0e53698e31b02c815be6df6005b4a160c7 Mon Sep 17 00:00:00 2001 From: reyk Date: Thu, 11 Jun 2015 19:25:53 +0000 Subject: [PATCH] The correct semantic is to check msgbuf_write() for <= 0, not just < 0. Fix one occurence in imsg_flush() and clarify it the man page. Discussed with at least blambert@ jsg@ yasuoka@. OK gilles@ --- lib/libutil/imsg.c | 4 ++-- lib/libutil/imsg_init.3 | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/libutil/imsg.c b/lib/libutil/imsg.c index 4720cd5f6c3..0c1c782ec67 100644 --- a/lib/libutil/imsg.c +++ b/lib/libutil/imsg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imsg.c,v 1.6 2014/06/30 00:26:22 deraadt Exp $ */ +/* $OpenBSD: imsg.c,v 1.7 2015/06/11 19:25:53 reyk Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -286,7 +286,7 @@ int imsg_flush(struct imsgbuf *ibuf) { while (ibuf->w.queued) - if (msgbuf_write(&ibuf->w) < 0) + if (msgbuf_write(&ibuf->w) <= 0) return (-1); return (0); } diff --git a/lib/libutil/imsg_init.3 b/lib/libutil/imsg_init.3 index 6c859b2ef52..45886c1ca5a 100644 --- a/lib/libutil/imsg_init.3 +++ b/lib/libutil/imsg_init.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: imsg_init.3,v 1.11 2013/12/26 17:32:33 eric Exp $ +.\" $OpenBSD: imsg_init.3,v 1.12 2015/06/11 19:25:53 reyk Exp $ .\" .\" Copyright (c) 2010 Nicholas Marriott .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: December 26 2013 $ +.Dd $Mdocdate: June 11 2015 $ .Dt IMSG_INIT 3 .Os .Sh NAME @@ -393,8 +393,8 @@ routine transmits as many pending buffers as possible from .Fn msgbuf using .Xr writev 2 . -It returns 1 if it succeeds, \-1 on error and 0 when an EOF condition on the -socket is detected. +It returns 1 if it succeeds, \-1 on error and 0 when no buffers were +pending or an EOF condition on the socket is detected. Temporary resource shortages are returned with errno .Er EAGAIN and require the application to retry again in the future. @@ -424,8 +424,8 @@ routine calls .Xr sendmsg 2 to transmit buffers queued in .Fa msgbuf . -It returns 1 if it succeeds, \-1 on error, and 0 when an EOF condition on the -socket is detected. +It returns 1 if it succeeds, \-1 on error, and 0 when the queue was empty +or an EOF condition on the socket is detected. Temporary resource shortages are returned with errno .Er EAGAIN and require the application to retry again in the future. @@ -498,7 +498,7 @@ library is used to monitor the socket file descriptor. When the socket is ready for writing, queued messages are transmitted with .Fn msgbuf_write : .Bd -literal -offset indent - if (msgbuf_write(&ibuf-\*(Gtw) \*(Lt 0 && errno != EAGAIN) { + if (msgbuf_write(&ibuf-\*(Gtw) \*(Lt= 0 && errno != EAGAIN) { /* handle write failure */ } .Ed -- 2.20.1