mirror of
https://github.com/tmux/tmux.git
synced 2024-12-04 19:58:48 +00:00
Convert sbin and usr.bin to check for imsgbuf_init failure and add
imsgbuf_allow_fdpass where needed. OK tb@
This commit is contained in:
parent
3f4fd45d5c
commit
70299c6646
19
proc.c
19
proc.c
@ -77,8 +77,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;
|
||||
}
|
||||
@ -105,13 +104,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;
|
||||
}
|
||||
@ -152,7 +151,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);
|
||||
|
||||
@ -218,7 +217,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;
|
||||
}
|
||||
|
||||
@ -306,7 +305,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)
|
||||
@ -326,7 +327,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);
|
||||
@ -341,7 +342,7 @@ proc_kill_peer(struct tmuxpeer *peer)
|
||||
void
|
||||
proc_flush_peer(struct tmuxpeer *peer)
|
||||
{
|
||||
imsg_flush(&peer->ibuf);
|
||||
imsgbuf_flush(&peer->ibuf);
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user