summaryrefslogtreecommitdiff
path: root/lib/libutil/imsg-buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libutil/imsg-buffer.c')
-rw-r--r--lib/libutil/imsg-buffer.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/lib/libutil/imsg-buffer.c b/lib/libutil/imsg-buffer.c
index 0a824c63bd8..537e52d6f99 100644
--- a/lib/libutil/imsg-buffer.c
+++ b/lib/libutil/imsg-buffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imsg-buffer.c,v 1.22 2024/11/21 12:44:06 claudio Exp $ */
+/* $OpenBSD: imsg-buffer.c,v 1.23 2024/11/21 12:49:58 claudio Exp $ */
/*
* Copyright (c) 2023 Claudio Jeker <claudio@openbsd.org>
@@ -569,24 +569,21 @@ ibuf_write(struct msgbuf *msgbuf)
iov[i].iov_len = ibuf_size(buf);
i++;
}
+ if (i == 0)
+ return (0); /* nothing queued */
again:
if ((n = writev(msgbuf->fd, iov, i)) == -1) {
if (errno == EINTR)
goto again;
- if (errno == ENOBUFS)
- errno = EAGAIN;
+ if (errno == EAGAIN || errno == ENOBUFS)
+ /* lets retry later again */
+ return (0);
return (-1);
}
- if (n == 0) { /* connection closed */
- errno = 0;
- return (0);
- }
-
msgbuf_drain(msgbuf, n);
-
- return (1);
+ return (0);
}
void
@@ -653,6 +650,9 @@ msgbuf_write(struct msgbuf *msgbuf)
buf0 = buf;
}
+ if (i == 0)
+ return (0); /* nothing queued */
+
msg.msg_iov = iov;
msg.msg_iovlen = i;
@@ -670,16 +670,12 @@ again:
if ((n = sendmsg(msgbuf->fd, &msg, 0)) == -1) {
if (errno == EINTR)
goto again;
- if (errno == ENOBUFS)
- errno = EAGAIN;
+ if (errno == EAGAIN || errno == ENOBUFS)
+ /* lets retry later again */
+ return (0);
return (-1);
}
- if (n == 0) { /* connection closed */
- errno = 0;
- return (0);
- }
-
/*
* assumption: fd got sent if sendmsg sent anything
* this works because fds are passed one at a time
@@ -691,7 +687,7 @@ again:
msgbuf_drain(msgbuf, n);
- return (1);
+ return (0);
}
uint32_t