mirror of
https://github.com/tmux/tmux.git
synced 2025-01-20 20:02:43 +00:00
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:
parent
6a6a42aa3a
commit
b3c4956efe
@ -61,6 +61,7 @@ server_client_create(int fd)
|
|||||||
c = xcalloc(1, sizeof *c);
|
c = xcalloc(1, sizeof *c);
|
||||||
c->references = 0;
|
c->references = 0;
|
||||||
imsg_init(&c->ibuf, fd);
|
imsg_init(&c->ibuf, fd);
|
||||||
|
server_update_event(c);
|
||||||
|
|
||||||
if (gettimeofday(&c->creation_time, NULL) != 0)
|
if (gettimeofday(&c->creation_time, NULL) != 0)
|
||||||
fatal("gettimeofday failed");
|
fatal("gettimeofday failed");
|
||||||
@ -150,30 +151,6 @@ server_client_lost(struct client *c)
|
|||||||
recalculate_sizes();
|
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. */
|
/* Process a single client event. */
|
||||||
void
|
void
|
||||||
server_client_callback(int fd, short events, void *data)
|
server_client_callback(int fd, short events, void *data)
|
||||||
@ -196,7 +173,8 @@ server_client_callback(int fd, short events, void *data)
|
|||||||
if (events & EV_READ && server_client_msg_dispatch(c) != 0)
|
if (events & EV_READ && server_client_msg_dispatch(c) != 0)
|
||||||
goto client_lost;
|
goto client_lost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
server_update_event(c);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
client_lost:
|
client_lost:
|
||||||
|
16
server-fn.c
16
server-fn.c
@ -59,6 +59,7 @@ server_write_client(
|
|||||||
return;
|
return;
|
||||||
log_debug("writing %d to client %d", type, c->ibuf.fd);
|
log_debug("writing %d to client %d", type, c->ibuf.fd);
|
||||||
imsg_compose(ibuf, type, PROTOCOL_VERSION, -1, -1, (void *) buf, len);
|
imsg_compose(ibuf, type, PROTOCOL_VERSION, -1, -1, (void *) buf, len);
|
||||||
|
server_update_event(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -371,3 +372,18 @@ server_clear_identify(struct client *c)
|
|||||||
server_redraw_client(c);
|
server_redraw_client(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
server_update_event(struct client *c)
|
||||||
|
{
|
||||||
|
short events;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
6
server.c
6
server.c
@ -160,11 +160,11 @@ server_start(char *path)
|
|||||||
log_debug("socket path %s", socket_path);
|
log_debug("socket path %s", socket_path);
|
||||||
setproctitle("server (%s)", rpathbuf);
|
setproctitle("server (%s)", rpathbuf);
|
||||||
|
|
||||||
|
event_init();
|
||||||
|
|
||||||
server_fd = server_create_socket();
|
server_fd = server_create_socket();
|
||||||
server_client_create(pair[1]);
|
server_client_create(pair[1]);
|
||||||
|
|
||||||
event_init();
|
|
||||||
|
|
||||||
if (access(SYSTEM_CFG, R_OK) == 0) {
|
if (access(SYSTEM_CFG, R_OK) == 0) {
|
||||||
if (load_cfg(SYSTEM_CFG, NULL, &cause) != 0)
|
if (load_cfg(SYSTEM_CFG, NULL, &cause) != 0)
|
||||||
goto error;
|
goto error;
|
||||||
@ -215,8 +215,6 @@ server_loop(void)
|
|||||||
while (!server_should_shutdown()) {
|
while (!server_should_shutdown()) {
|
||||||
server_update_socket();
|
server_update_socket();
|
||||||
|
|
||||||
server_client_prepare();
|
|
||||||
|
|
||||||
event_loopexit(&tv);
|
event_loopexit(&tv);
|
||||||
event_loop(EVLOOP_ONCE);
|
event_loop(EVLOOP_ONCE);
|
||||||
|
|
||||||
|
2
tmux.h
2
tmux.h
@ -1564,7 +1564,6 @@ void server_signal_clear(void);
|
|||||||
/* server-client.c */
|
/* server-client.c */
|
||||||
void server_client_create(int);
|
void server_client_create(int);
|
||||||
void server_client_lost(struct client *);
|
void server_client_lost(struct client *);
|
||||||
void server_client_prepare(void);
|
|
||||||
void server_client_callback(int, short, void *);
|
void server_client_callback(int, short, void *);
|
||||||
void server_client_loop(void);
|
void server_client_loop(void);
|
||||||
|
|
||||||
@ -1598,6 +1597,7 @@ void server_destroy_session_group(struct session *);
|
|||||||
void server_destroy_session(struct session *);
|
void server_destroy_session(struct session *);
|
||||||
void server_set_identify(struct client *);
|
void server_set_identify(struct client *);
|
||||||
void server_clear_identify(struct client *);
|
void server_clear_identify(struct client *);
|
||||||
|
void server_update_event(struct client *);
|
||||||
|
|
||||||
/* status.c */
|
/* status.c */
|
||||||
int status_redraw(struct client *);
|
int status_redraw(struct client *);
|
||||||
|
Loading…
Reference in New Issue
Block a user