Commit Diff


commit - 7ab7287f2568cf0384497707d95581957ec29e56
commit + 59aee4e5b492bad8dcaaaad9dd710b9619a07a50
blob - 5c4ddf7a18b062babdc0a2473f7c73053daf77cc
blob + 9ed1af5902217dc08b2a36d90d9b2dad17fa6758
--- control.c
+++ control.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: control.c,v 1.17 2024/11/21 13:16:07 claudio Exp $	*/
+/*	$OpenBSD: control.c,v 1.18 2024/11/21 13:17:02 claudio Exp $	*/
 
 /*
  * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -164,7 +164,7 @@ control_accept(int listenfd, short event, void *arg)
 		return;
 	}
 
-	imsg_init(&c->iev.ibuf, connfd);
+	imsgbuf_init(&c->iev.ibuf, connfd);
 	c->iev.handler = control_dispatch_imsg;
 	c->iev.events = EV_READ;
 	c->iev.data = cs;	/* proc.c cheats (reuses the handler) */
@@ -229,15 +229,15 @@ control_dispatch_imsg(int fd, short event, void *arg)
 	}
 
 	if (event & EV_READ) {
-		if (((n = imsg_read(&c->iev.ibuf)) == -1 && errno != EAGAIN) ||
-		    n == 0) {
+		if (((n = imsgbuf_read(&c->iev.ibuf)) == -1 &&
+		    errno != EAGAIN) || n == 0) {
 			control_close(fd, cs);
 			return;
 		}
 	}
 
 	if (event & EV_WRITE) {
-		if (imsg_write(&c->iev.ibuf) == -1) {
+		if (imsgbuf_write(&c->iev.ibuf) == -1) {
 			control_close(fd, cs);
 			return;
 		}
blob - 49fc73e7f63830434cab260f509615c20f7d659e
blob + 3e2d4ce0e8c5ca9e5db79869e7ab6e307c13d0c6
--- proc.c
+++ proc.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: proc.c,v 1.48 2024/11/21 13:16:07 claudio Exp $	*/
+/*	$OpenBSD: proc.c,v 1.49 2024/11/21 13:17:02 claudio Exp $	*/
 
 /*
  * Copyright (c) 2010 - 2016 Reyk Floeter <reyk@openbsd.org>
@@ -155,7 +155,8 @@ proc_connect(struct privsep *ps)
 
 		for (inst = 0; inst < ps->ps_instances[dst]; inst++) {
 			iev = &ps->ps_ievs[dst][inst];
-			imsg_init(&iev->ibuf, ps->ps_pp->pp_pipes[dst][inst]);
+			imsgbuf_init(&iev->ibuf,
+			    ps->ps_pp->pp_pipes[dst][inst]);
 			event_set(&iev->ev, iev->ibuf.fd, iev->events,
 			    iev->handler, iev->data);
 			event_add(&iev->ev, NULL);
@@ -264,7 +265,7 @@ proc_accept(struct privsep *ps, int fd, enum privsep_p
 		pp->pp_pipes[dst][n] = fd;
 
 	iev = &ps->ps_ievs[dst][n];
-	imsg_init(&iev->ibuf, fd);
+	imsgbuf_init(&iev->ibuf, fd);
 	event_set(&iev->ev, iev->ibuf.fd, iev->events, iev->handler, iev->data);
 	event_add(&iev->ev, NULL);
 }
@@ -294,7 +295,7 @@ proc_setup(struct privsep *ps, struct privsep_proc *pr
 		    sizeof(struct imsgev))) == NULL)
 			fatal("%s: calloc", __func__);
 
-		/* With this set up, we are ready to call imsg_init(). */
+		/* With this set up, we are ready to call imsgbuf_init(). */
 		for (i = 0; i < ps->ps_instances[id]; i++) {
 			ps->ps_ievs[id][i].handler = proc_dispatch;
 			ps->ps_ievs[id][i].events = EV_READ;
@@ -427,7 +428,7 @@ proc_open(struct privsep *ps, int src, int dst)
 			 */
 			if (proc_flush_imsg(ps, src, i) == -1 ||
 			    proc_flush_imsg(ps, dst, j) == -1)
-				fatal("%s: imsg_flush", __func__);
+				fatal("%s: imsgbuf_flush", __func__);
 		}
 	}
 }
@@ -453,7 +454,7 @@ proc_close(struct privsep *ps)
 
 			/* Cancel the fd, close and invalidate the fd */
 			event_del(&(ps->ps_ievs[dst][n].ev));
-			imsg_clear(&(ps->ps_ievs[dst][n].ibuf));
+			imsgbuf_clear(&(ps->ps_ievs[dst][n].ibuf));
 			close(pp->pp_pipes[dst][n]);
 			pp->pp_pipes[dst][n] = -1;
 		}
@@ -600,8 +601,8 @@ proc_dispatch(int fd, short event, void *arg)
 	ibuf = &iev->ibuf;
 
 	if (event & EV_READ) {
-		if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN)
-			fatal("%s: imsg_read", __func__);
+		if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN)
+			fatal("%s: imsgbuf_read", __func__);
 		if (n == 0) {
 			/* this pipe is dead, so remove the event handler */
 			event_del(&iev->ev);
@@ -611,14 +612,14 @@ proc_dispatch(int fd, short event, void *arg)
 	}
 
 	if (event & EV_WRITE) {
-		if (imsg_write(ibuf) == -1) {
+		if (imsgbuf_write(ibuf) == -1) {
 			if (errno == EPIPE) {	/* connection closed */
 				/* remove the event handler */
 				event_del(&iev->ev);
 				event_loopexit(NULL);
 				return;
 			} else
-				fatal("%s: imsg_write", __func__);
+				fatal("%s: imsgbuf_write", __func__);
 		}
 	}
 
@@ -684,7 +685,7 @@ void
 imsg_event_add(struct imsgev *iev)
 {
 	if (iev->handler == NULL) {
-		imsg_flush(&iev->ibuf);
+		imsgbuf_flush(&iev->ibuf);
 		return;
 	}
 
@@ -818,7 +819,7 @@ proc_flush_imsg(struct privsep *ps, enum privsep_proci
 	for (; n < m; n++) {
 		if ((ibuf = proc_ibuf(ps, id, n)) == NULL)
 			return (-1);
-		if ((ret = imsg_flush(ibuf)) == -1)
+		if ((ret = imsgbuf_flush(ibuf)) == -1)
 			break;
 		imsg_event_add(&ps->ps_ievs[id][n]);
 	}