Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam 2024-11-21 16:01:11 +00:00
commit b82c7b40b0

19
proc.c
View File

@ -78,8 +78,7 @@ proc_event_cb(__unused int fd, short events, void *arg)
struct imsg imsg;
if (!(peer->flags & PEER_BAD) && (events & EV_READ)) {
if (((n = imsg_read(&peer->ibuf)) == -1 && errno != EAGAIN) ||
n == 0) {
if (imsgbuf_read(&peer->ibuf) != 1) {
peer->dispatchcb(NULL, peer->arg);
return;
}
@ -106,13 +105,13 @@ proc_event_cb(__unused int fd, short events, void *arg)
}
if (events & EV_WRITE) {
if (msgbuf_write(&peer->ibuf.w) <= 0 && errno != EAGAIN) {
if (imsgbuf_write(&peer->ibuf) == -1) {
peer->dispatchcb(NULL, peer->arg);
return;
}
}
if ((peer->flags & PEER_BAD) && peer->ibuf.w.queued == 0) {
if ((peer->flags & PEER_BAD) && imsgbuf_queuelen(&peer->ibuf) == 0) {
peer->dispatchcb(NULL, peer->arg);
return;
}
@ -153,7 +152,7 @@ proc_update_event(struct tmuxpeer *peer)
event_del(&peer->event);
events = EV_READ;
if (peer->ibuf.w.queued > 0)
if (imsgbuf_queuelen(&peer->ibuf) > 0)
events |= EV_WRITE;
event_set(&peer->event, peer->ibuf.fd, events, proc_event_cb, peer);
@ -225,7 +224,7 @@ proc_exit(struct tmuxproc *tp)
struct tmuxpeer *peer;
TAILQ_FOREACH(peer, &tp->peers, entry)
imsg_flush(&peer->ibuf);
imsgbuf_flush(&peer->ibuf);
tp->exit = 1;
}
@ -313,7 +312,9 @@ proc_add_peer(struct tmuxproc *tp, int fd,
peer->dispatchcb = dispatchcb;
peer->arg = arg;
imsg_init(&peer->ibuf, fd);
if (imsgbuf_init(&peer->ibuf, fd) == -1)
fatal("imsgbuf_init");
imsgbuf_allow_fdpass(&peer->ibuf);
event_set(&peer->event, fd, EV_READ, proc_event_cb, peer);
if (getpeereid(fd, &peer->uid, &gid) != 0)
@ -333,7 +334,7 @@ proc_remove_peer(struct tmuxpeer *peer)
log_debug("remove peer %p", peer);
event_del(&peer->event);
imsg_clear(&peer->ibuf);
imsgbuf_clear(&peer->ibuf);
close(peer->ibuf.fd);
free(peer);
@ -348,7 +349,7 @@ proc_kill_peer(struct tmuxpeer *peer)
void
proc_flush_peer(struct tmuxpeer *peer)
{
imsg_flush(&peer->ibuf);
imsgbuf_flush(&peer->ibuf);
}
void