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:
Nicholas Marriott
2009-11-04 23:12:43 +00:00
parent 6a6a42aa3a
commit b3c4956efe
4 changed files with 22 additions and 30 deletions

View File

@ -59,6 +59,7 @@ server_write_client(
return;
log_debug("writing %d to client %d", type, c->ibuf.fd);
imsg_compose(ibuf, type, PROTOCOL_VERSION, -1, -1, (void *) buf, len);
server_update_event(c);
}
void
@ -371,3 +372,18 @@ server_clear_identify(struct 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);
}