[PATCH] Fix run_events() to run all ready events instead of the first one in the list

Jeremy Allison jra at samba.org
Wed Mar 4 16:42:57 GMT 2009


On Wed, Mar 04, 2009 at 06:49:11PM +0800, boyang wrote:
> Volker Lendecke wrote:
> >
> > No, this does not work. Event handlers can change the state
> > of the other event handlers, in particular they can delete
> > other event handlers. We had this, it leads to crashes.
> >   
> @vl:
>       signal events and timer events will affect fd events, and fd
> events can delete itself from the list in the handler. Does it make
> sense to run all ready events of one kind instead of just one? Ie, if
> there is signal events, we run them and return; else run timer events
> and return....
>      I have done some initial test, and it works fine for me.

The thing is we don't actually *need* to run multiple events
inside the event loop.

As we have reliable queuing of events, then all running one
event at a time means we will call the event loop again, once
for each event we have pending.

Yes, theoretically we could improve efficiency by running
more than one even inside the loop, but I don't think the
added complexity is worth the (very small) efficiency gain
that we would get.

Volker is right here, we have tried this (most notably
myself :-) and it does lead to crashes.

So to be honest I'm inclined not to add this patch, even
if it's correct. It isn't about the correctness, but
about the long term maintainability. And that's *hard* :-).

Thanks for the work though, much appreciated.

Jeremy.


More information about the samba-technical mailing list