mirror of
https://github.com/tmux/tmux.git
synced 2024-12-04 19:58:48 +00:00
Merge branch 'obsd-master'
This commit is contained in:
commit
b82c7b40b0
19
proc.c
19
proc.c
@ -78,8 +78,7 @@ proc_event_cb(__unused int fd, short events, void *arg)
|
|||||||
struct imsg imsg;
|
struct imsg imsg;
|
||||||
|
|
||||||
if (!(peer->flags & PEER_BAD) && (events & EV_READ)) {
|
if (!(peer->flags & PEER_BAD) && (events & EV_READ)) {
|
||||||
if (((n = imsg_read(&peer->ibuf)) == -1 && errno != EAGAIN) ||
|
if (imsgbuf_read(&peer->ibuf) != 1) {
|
||||||
n == 0) {
|
|
||||||
peer->dispatchcb(NULL, peer->arg);
|
peer->dispatchcb(NULL, peer->arg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -106,13 +105,13 @@ proc_event_cb(__unused int fd, short events, void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (events & EV_WRITE) {
|
if (events & EV_WRITE) {
|
||||||
if (msgbuf_write(&peer->ibuf.w) <= 0 && errno != EAGAIN) {
|
if (imsgbuf_write(&peer->ibuf) == -1) {
|
||||||
peer->dispatchcb(NULL, peer->arg);
|
peer->dispatchcb(NULL, peer->arg);
|
||||||
return;
|
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);
|
peer->dispatchcb(NULL, peer->arg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -153,7 +152,7 @@ proc_update_event(struct tmuxpeer *peer)
|
|||||||
event_del(&peer->event);
|
event_del(&peer->event);
|
||||||
|
|
||||||
events = EV_READ;
|
events = EV_READ;
|
||||||
if (peer->ibuf.w.queued > 0)
|
if (imsgbuf_queuelen(&peer->ibuf) > 0)
|
||||||
events |= EV_WRITE;
|
events |= EV_WRITE;
|
||||||
event_set(&peer->event, peer->ibuf.fd, events, proc_event_cb, peer);
|
event_set(&peer->event, peer->ibuf.fd, events, proc_event_cb, peer);
|
||||||
|
|
||||||
@ -225,7 +224,7 @@ proc_exit(struct tmuxproc *tp)
|
|||||||
struct tmuxpeer *peer;
|
struct tmuxpeer *peer;
|
||||||
|
|
||||||
TAILQ_FOREACH(peer, &tp->peers, entry)
|
TAILQ_FOREACH(peer, &tp->peers, entry)
|
||||||
imsg_flush(&peer->ibuf);
|
imsgbuf_flush(&peer->ibuf);
|
||||||
tp->exit = 1;
|
tp->exit = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,7 +312,9 @@ proc_add_peer(struct tmuxproc *tp, int fd,
|
|||||||
peer->dispatchcb = dispatchcb;
|
peer->dispatchcb = dispatchcb;
|
||||||
peer->arg = arg;
|
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);
|
event_set(&peer->event, fd, EV_READ, proc_event_cb, peer);
|
||||||
|
|
||||||
if (getpeereid(fd, &peer->uid, &gid) != 0)
|
if (getpeereid(fd, &peer->uid, &gid) != 0)
|
||||||
@ -333,7 +334,7 @@ proc_remove_peer(struct tmuxpeer *peer)
|
|||||||
log_debug("remove peer %p", peer);
|
log_debug("remove peer %p", peer);
|
||||||
|
|
||||||
event_del(&peer->event);
|
event_del(&peer->event);
|
||||||
imsg_clear(&peer->ibuf);
|
imsgbuf_clear(&peer->ibuf);
|
||||||
|
|
||||||
close(peer->ibuf.fd);
|
close(peer->ibuf.fd);
|
||||||
free(peer);
|
free(peer);
|
||||||
@ -348,7 +349,7 @@ proc_kill_peer(struct tmuxpeer *peer)
|
|||||||
void
|
void
|
||||||
proc_flush_peer(struct tmuxpeer *peer)
|
proc_flush_peer(struct tmuxpeer *peer)
|
||||||
{
|
{
|
||||||
imsg_flush(&peer->ibuf);
|
imsgbuf_flush(&peer->ibuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user