mirror of
https://github.com/tmux/tmux.git
synced 2025-09-01 20:57:00 +00:00
imsg no longer associates file descriptors with the imsg they were sent with,
work around this for the moment (it is not clear if this is intentional).
This commit is contained in:
27
proc.c
27
proc.c
@ -55,6 +55,7 @@ struct tmuxpeer {
|
||||
struct tmuxproc *parent;
|
||||
|
||||
struct imsgbuf ibuf;
|
||||
int lastfd;
|
||||
struct event event;
|
||||
uid_t uid;
|
||||
|
||||
@ -71,7 +72,7 @@ static int peer_check_version(struct tmuxpeer *, struct imsg *);
|
||||
static void proc_update_event(struct tmuxpeer *);
|
||||
|
||||
static void
|
||||
proc_event_cb(__unused int fd, short events, void *arg)
|
||||
proc_event_cb(int fd, short events, void *arg)
|
||||
{
|
||||
struct tmuxpeer *peer = arg;
|
||||
ssize_t n;
|
||||
@ -89,12 +90,16 @@ proc_event_cb(__unused int fd, short events, void *arg)
|
||||
}
|
||||
if (n == 0)
|
||||
break;
|
||||
log_debug("peer %p message %d", peer, imsg.hdr.type);
|
||||
fd = imsg_get_fd(&imsg);
|
||||
log_debug("peer %p message %d fd %d", peer,
|
||||
imsg.hdr.type, fd);
|
||||
if (fd != -1) {
|
||||
if (peer->lastfd != -1)
|
||||
close(peer->lastfd);
|
||||
peer->lastfd = fd;
|
||||
}
|
||||
|
||||
if (peer_check_version(peer, &imsg) != 0) {
|
||||
fd = imsg_get_fd(&imsg);
|
||||
if (fd != -1)
|
||||
close(fd);
|
||||
imsg_free(&imsg);
|
||||
break;
|
||||
}
|
||||
@ -308,6 +313,7 @@ proc_add_peer(struct tmuxproc *tp, int fd,
|
||||
|
||||
peer = xcalloc(1, sizeof *peer);
|
||||
peer->parent = tp;
|
||||
peer->lastfd = -1;
|
||||
|
||||
peer->dispatchcb = dispatchcb;
|
||||
peer->arg = arg;
|
||||
@ -336,6 +342,8 @@ proc_remove_peer(struct tmuxpeer *peer)
|
||||
event_del(&peer->event);
|
||||
imsgbuf_clear(&peer->ibuf);
|
||||
|
||||
if (peer->lastfd != -1)
|
||||
close(peer->lastfd);
|
||||
close(peer->ibuf.fd);
|
||||
free(peer);
|
||||
}
|
||||
@ -387,3 +395,12 @@ proc_get_peer_uid(struct tmuxpeer *peer)
|
||||
{
|
||||
return (peer->uid);
|
||||
}
|
||||
|
||||
int
|
||||
proc_get_last_fd(struct tmuxpeer *peer)
|
||||
{
|
||||
int fd = peer->lastfd;
|
||||
|
||||
peer->lastfd = -1;
|
||||
return (fd);
|
||||
}
|
||||
|
Reference in New Issue
Block a user