← Back to team overview

drizzle-discuss team mailing list archive

Re: libdrizzle: integration with another event loop


Hi Evan,

On Thu, Nov 19, 2009 at 02:47:36PM -0500, Evan Jones wrote:
> Okay, I changed my code to do this and it works just fine. Part of
> my confusion is that this is *not* what the gearmand example that
> you sent does. Looking at the code:
> http://bazaar.launchpad.net/~gearman-developers/gearmand/trunk/annotate/head:/libgearman-server/gearmand_con.c
> the libevent callback _con_ready (line 224) does nothing with the
> libevent events. The events are set in gearmand_con_watch (line 199)
> with the EV_PERSIST option, so they will keep firing until
> explicitly removed. Is this a difference between the libdrizzle and
> gearmand event implementations?

Ahh, yes. For some reason I was thinking of the old way I was handling
things, this has obviously been updated. In order to prevent thrashing
of set/unset of events, I make sure that the event set callback is
called everytime a FD is done being processed. If the active flags have
not changed, no call is required. If one is changed (ie, stop waiting
for POLLOUT), then the change can happen. Sorry for the confusion,
go along with the gearmand src example, as that is correct. :)

> I guess my concern is just that there are lots of places in the
> libdrizzle code where if an error occurs, the fd is closed without
> my "event manager" code being aware. I don't *think* this will cause
> any problems though.

Ahh, ok. The API calls should always return with some type of error so
you can handle before entering back into the event loop. If you find
a close() callback would be useful we can add, but I want to make
sure it's needed. I didn't need one with the gearmand event loop so
I think it can be avoided.


Follow ups