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:
Tiago Cunha
2009-11-08 23:09:36 +00:00
parent 0cd4f4e321
commit bee17719d8
4 changed files with 26 additions and 34 deletions

View File

@ -1,4 +1,4 @@
/* $Id: server-fn.c,v 1.94 2009-10-12 00:37:41 tcunha Exp $ */
/* $Id: server-fn.c,v 1.95 2009-11-08 23:09:36 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -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);
}