[sheepdog] [PATCH v2 1/2] lib: prioritize events for epoll() and enhance event loop
Liu Yuan
namei.unix at gmail.com
Fri Dec 21 18:45:11 CET 2012
On 12/22/2012 01:23 AM, Hitoshi Mitake wrote:
> + * we have to retrieve the number of prioritized events here, because
> + * nr_prioritized_events is increased in event handlers
> + */
> + prioritized = nr_prioritized_events;
>
> - nr = epoll_wait(efd, events, ARRAY_SIZE(events), TICK * 1000);
> + nr = epoll_wait(efd, polled_events, nr_events, TICK * 1000);
> if (nr < 0) {
> if (errno == EINTR)
> return;
> eprintf("epoll_wait failed: %m\n");
> exit(1);
> } else if (nr) {
> + if (prioritized)
> + qsort(polled_events, nr, sizeof(struct epoll_event),
> + epoll_event_cmp);
It seems that we need to call qsort every time since we
nr_prioritized_events is always > 0 for now. I guess we need a better
method to test need_sort case to optimize for most cases that don't
need_sort.
Thanks,
Yuan
More information about the sheepdog
mailing list