commit 585eb3254921938d12e233e6029f136bc0f8b987 from: claudio date: Thu Nov 21 13:17:01 2024 UTC Rename imsg_init, imsg_clear, imsg_read, imsg_write and imsg_flush to imsgbuf_init, imsgbuf_clear, imsgbuf_read, imsgbuf_write and imsgbuf_flush. This separates the imsgbuf API from the per-imsg API. OK tb@ commit - 41ddc9d163020f85bddcaf4c7261ab2818848c59 commit + 585eb3254921938d12e233e6029f136bc0f8b987 blob - ea57b93e31e7a0dd6bf40e99efcd0e335b4eea45 blob + 864ee775fd53ccf0c7646bbfd2a6ffa2899b515e --- ca.c +++ ca.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ca.c,v 1.43 2023/07/16 09:23:33 tb Exp $ */ +/* $OpenBSD: ca.c,v 1.44 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2014 Reyk Floeter @@ -337,8 +337,8 @@ rsae_send_imsg(int flen, const u_char *from, u_char *t */ if (imsg_composev(ibuf, cmd, 0, 0, -1, iov, cnt) == -1) log_warn("%s: imsg_composev", __func__); - if (imsg_flush(ibuf) == -1) - log_warn("%s: imsg_flush", __func__); + if (imsgbuf_flush(ibuf) == -1) + log_warn("%s: imsgbuf_flush", __func__); pfd[0].fd = ibuf->fd; pfd[0].events = POLLIN; @@ -357,8 +357,8 @@ rsae_send_imsg(int flen, const u_char *from, u_char *t default: break; } - if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) - fatalx("imsg_read"); + if ((n = imsgbuf_read(ibuf)) == -1 && errno != EAGAIN) + fatalx("imsgbuf_read"); if (n == 0) fatalx("pipe closed"); blob - f720329485010ddde62758a78df4b9733cc80af0 blob + aa3cd0f938f6ad2dd5363f5c033a3483cc39c0c9 --- control.c +++ control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.60 2024/11/21 13:16:07 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.61 2024/11/21 13:17:02 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -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) */ @@ -231,15 +231,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 - 3424f878da5fdb8775af61c3f81ee02b1e45b260 blob + fe3089220fa5ca0d0e09ec72163c85b633760c0f --- 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 @@ -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; @@ -428,7 +429,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: proc_flush_imsg", __func__); } } } @@ -454,7 +455,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; } @@ -601,8 +602,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); @@ -612,14 +613,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) { /* this pipe is dead, remove the handler */ event_del(&iev->ev); event_loopexit(NULL); return; } - fatal("%s: imsg_write", __func__); + fatal("%s: imsgbuf_write", __func__); } } @@ -685,7 +686,7 @@ void imsg_event_add(struct imsgev *iev) { if (iev->handler == NULL) { - imsg_flush(&iev->ibuf); + imsgbuf_flush(&iev->ibuf); return; } @@ -819,7 +820,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]); }