[sheepdog] [PATCH v2 1/2] lib: prioritize events for epoll() and enhance event loop

Hitoshi Mitake h.mitake at gmail.com
Sat Dec 22 18:54:46 CET 2012


At Sat, 22 Dec 2012 01:41:20 +0800,
Liu Yuan wrote:
> 
> On 12/22/2012 01:23 AM, Hitoshi Mitake wrote:
> > +	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)
> 
> simply if (nr_prioritized_events) is okay, then we can remove prioritized.

Ah, prioritized is a redundant variable. I'll eliminate it.

> 
> > +			qsort(polled_events, nr, sizeof(struct epoll_event),
> > +				epoll_event_cmp);
> > +
> >  		for (i = 0; i < nr; i++) {
> >  			struct event_info *ei;
> > +			uint32_t e;
> > +			enum event_ret ret;
> > +
> > +			ei = (struct event_info *)polled_events[i].data.ptr;
> > +			e = polled_events[i].events;
> > +
> > +			ret = ei->handler(ei->fd, e, ei->data);
> > +			switch (ret) {
> > +			case EVENT_LOOP_NOP:
> > +				break;
> >  
> > -			ei = (struct event_info *)events[i].data.ptr;
> > -			ei->handler(ei->fd, events[i].events, ei->data);
> > +			case EVENT_LOOP_RETRIEVE:
> > +				goto retrieve;
> > +
> > +			case EVENT_LOOP_BREAK:
> > +				goto end;
> > +
> 
> No whitespace for case clause please.

Do you mean I should write break after goto? If it is a coding
style of sheepdog, of course I'll write so.

> 
> > +			default:
> > +				panic("invalid event_ret: %d\n", ret);
> > +				break;
> > +			}
> >  		}
> >  	}
> > +
> 

Thanks,
Hitoshi



More information about the sheepdog mailing list