Browse Source

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@
OPENBSD_5_8
reyk 9 years ago
parent
commit
13bb9544ea
2 changed files with 9 additions and 9 deletions
  1. +2
    -2
      src/lib/libutil/imsg.c
  2. +7
    -7
      src/lib/libutil/imsg_init.3

+ 2
- 2
src/lib/libutil/imsg.c View File

@ -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 <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -286,7 +286,7 @@ int
imsg_flush(struct imsgbuf *ibuf) imsg_flush(struct imsgbuf *ibuf)
{ {
while (ibuf->w.queued) while (ibuf->w.queued)
if (msgbuf_write(&ibuf->w) < 0)
if (msgbuf_write(&ibuf->w) <= 0)
return (-1); return (-1);
return (0); return (0);
} }


+ 7
- 7
src/lib/libutil/imsg_init.3 View File

@ -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 <nicm@openbsd.org> .\" Copyright (c) 2010 Nicholas Marriott <nicm@openbsd.org>
.\" .\"
@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" 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 .Dt IMSG_INIT 3
.Os .Os
.Sh NAME .Sh NAME
@ -393,8 +393,8 @@ routine transmits as many pending buffers as possible from
.Fn msgbuf .Fn msgbuf
using using
.Xr writev 2 . .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 Temporary resource shortages are returned with errno
.Er EAGAIN .Er EAGAIN
and require the application to retry again in the future. and require the application to retry again in the future.
@ -424,8 +424,8 @@ routine calls
.Xr sendmsg 2 .Xr sendmsg 2
to transmit buffers queued in to transmit buffers queued in
.Fa msgbuf . .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 Temporary resource shortages are returned with errno
.Er EAGAIN .Er EAGAIN
and require the application to retry again in the future. 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 When the socket is ready for writing, queued messages are transmitted with
.Fn msgbuf_write : .Fn msgbuf_write :
.Bd -literal -offset indent .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 */ /* handle write failure */
} }
.Ed .Ed


Loading…
Cancel
Save