diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2024-11-21 13:00:15 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2024-11-21 13:00:15 +0000 |
commit | 92aa854f4a35cf68a96d277f3f6960458206605a (patch) | |
tree | 413134e0e371348f72c57d865859a4f14c2586c5 /lib | |
parent | 2c9dbe42bd566f22f837b6032648f3ad10421494 (diff) |
Remove fd from struct msgbuf, instead pass the fd to imsg_write and
msgbuf_write
OK tb@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libutil/imsg-buffer.c | 11 | ||||
-rw-r--r-- | lib/libutil/imsg.c | 5 | ||||
-rw-r--r-- | lib/libutil/imsg.h | 7 |
3 files changed, 10 insertions, 13 deletions
diff --git a/lib/libutil/imsg-buffer.c b/lib/libutil/imsg-buffer.c index c39e3ac07c8..b6db734d587 100644 --- a/lib/libutil/imsg-buffer.c +++ b/lib/libutil/imsg-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imsg-buffer.c,v 1.25 2024/11/21 12:59:33 claudio Exp $ */ +/* $OpenBSD: imsg-buffer.c,v 1.26 2024/11/21 13:00:14 claudio Exp $ */ /* * Copyright (c) 2023 Claudio Jeker <claudio@openbsd.org> @@ -550,7 +550,6 @@ void msgbuf_init(struct msgbuf *msgbuf) { msgbuf->queued = 0; - msgbuf->fd = -1; TAILQ_INIT(&msgbuf->bufs); } @@ -570,7 +569,7 @@ msgbuf_clear(struct msgbuf *msgbuf) } int -ibuf_write(struct msgbuf *msgbuf) +ibuf_write(int fd, struct msgbuf *msgbuf) { struct iovec iov[IOV_MAX]; struct ibuf *buf; @@ -589,7 +588,7 @@ ibuf_write(struct msgbuf *msgbuf) return (0); /* nothing queued */ again: - if ((n = writev(msgbuf->fd, iov, i)) == -1) { + if ((n = writev(fd, iov, i)) == -1) { if (errno == EINTR) goto again; if (errno == EAGAIN || errno == ENOBUFS) @@ -603,7 +602,7 @@ again: } int -msgbuf_write(struct msgbuf *msgbuf) +msgbuf_write(int fd, struct msgbuf *msgbuf) { struct iovec iov[IOV_MAX]; struct ibuf *buf, *buf0 = NULL; @@ -648,7 +647,7 @@ msgbuf_write(struct msgbuf *msgbuf) } again: - if ((n = sendmsg(msgbuf->fd, &msg, 0)) == -1) { + if ((n = sendmsg(fd, &msg, 0)) == -1) { if (errno == EINTR) goto again; if (errno == EAGAIN || errno == ENOBUFS) diff --git a/lib/libutil/imsg.c b/lib/libutil/imsg.c index 063d4843a56..a1991eecc83 100644 --- a/lib/libutil/imsg.c +++ b/lib/libutil/imsg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imsg.c,v 1.33 2024/11/21 12:58:46 claudio Exp $ */ +/* $OpenBSD: imsg.c,v 1.34 2024/11/21 13:00:14 claudio Exp $ */ /* * Copyright (c) 2023 Claudio Jeker <claudio@openbsd.org> @@ -42,7 +42,6 @@ imsgbuf_init(struct imsgbuf *imsgbuf, int fd) msgbuf_init(&imsgbuf->w); memset(&imsgbuf->r, 0, sizeof(imsgbuf->r)); imsgbuf->fd = fd; - imsgbuf->w.fd = fd; imsgbuf->pid = getpid(); TAILQ_INIT(&imsgbuf->fds); } @@ -138,7 +137,7 @@ fail: int imsgbuf_write(struct imsgbuf *imsgbuf) { - return msgbuf_write(&imsgbuf->w); + return msgbuf_write(imsgbuf->fd, &imsgbuf->w); } int diff --git a/lib/libutil/imsg.h b/lib/libutil/imsg.h index ba8d3cc7d0a..e38689b7add 100644 --- a/lib/libutil/imsg.h +++ b/lib/libutil/imsg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: imsg.h,v 1.15 2024/11/21 12:58:46 claudio Exp $ */ +/* $OpenBSD: imsg.h,v 1.16 2024/11/21 13:00:14 claudio Exp $ */ /* * Copyright (c) 2023 Claudio Jeker <claudio@openbsd.org> @@ -41,7 +41,6 @@ struct ibuf { struct msgbuf { TAILQ_HEAD(, ibuf) bufs; uint32_t queued; - int fd; }; struct ibuf_read { @@ -123,11 +122,11 @@ void ibuf_free(struct ibuf *); int ibuf_fd_avail(struct ibuf *); int ibuf_fd_get(struct ibuf *); void ibuf_fd_set(struct ibuf *, int); -int ibuf_write(struct msgbuf *); void msgbuf_init(struct msgbuf *); void msgbuf_clear(struct msgbuf *); uint32_t msgbuf_queuelen(struct msgbuf *); -int msgbuf_write(struct msgbuf *); +int ibuf_write(int, struct msgbuf *); +int msgbuf_write(int, struct msgbuf *); /* imsg.c */ void imsgbuf_init(struct imsgbuf *, int); |