mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 05:21:10 +00:00
Sync OpenBSD patchset 503:
Don't reenlist the client imsg event every loop, instead have a small function to it and call it after the event triggers or after a imsg is added.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
/* $Id: server-client.c,v 1.14 2009-11-08 22:58:37 tcunha Exp $ */
|
||||
/* $Id: server-client.c,v 1.15 2009-11-08 23:09:36 tcunha Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -60,6 +60,7 @@ server_client_create(int fd)
|
||||
c = xcalloc(1, sizeof *c);
|
||||
c->references = 0;
|
||||
imsg_init(&c->ibuf, fd);
|
||||
server_update_event(c);
|
||||
|
||||
if (gettimeofday(&c->creation_time, NULL) != 0)
|
||||
fatal("gettimeofday failed");
|
||||
@ -149,30 +150,6 @@ server_client_lost(struct client *c)
|
||||
recalculate_sizes();
|
||||
}
|
||||
|
||||
/* Register clients for poll. */
|
||||
void
|
||||
server_client_prepare(void)
|
||||
{
|
||||
struct client *c;
|
||||
u_int i;
|
||||
int events;
|
||||
|
||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||
if ((c = ARRAY_ITEM(&clients, i)) == NULL)
|
||||
continue;
|
||||
|
||||
events = 0;
|
||||
if (!(c->flags & CLIENT_BAD))
|
||||
events |= EV_READ;
|
||||
if (c->ibuf.w.queued > 0)
|
||||
events |= EV_WRITE;
|
||||
event_del(&c->event);
|
||||
event_set(&c->event,
|
||||
c->ibuf.fd, events, server_client_callback, c);
|
||||
event_add(&c->event, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/* Process a single client event. */
|
||||
void
|
||||
server_client_callback(int fd, short events, void *data)
|
||||
@ -195,7 +172,8 @@ server_client_callback(int fd, short events, void *data)
|
||||
if (events & EV_READ && server_client_msg_dispatch(c) != 0)
|
||||
goto client_lost;
|
||||
}
|
||||
|
||||
|
||||
server_update_event(c);
|
||||
return;
|
||||
|
||||
client_lost:
|
||||
|
Reference in New Issue
Block a user