← Back to team overview

drizzle-discuss team mailing list archive

Re: libdrizzle: integration with another event loop


Hi Evan,

On Tue, Nov 17, 2009 at 04:55:59PM -0500, Evan Jones wrote:
> On Nov 17, 2009, at 16:06 , Eric Day wrote:
> >Yes, you should be calling drizzle_con_revents() when the libevent
> >callbacks notify that a fd is ready for read/write. You are providing
> >a replacement for drizzle_con_wait().
> This is very interesting, because it seems to work for me (for the
> moment) without doing this. I'll look into this more carefully.

This will probably work for some things since an attempt is made even
if the revents are not set. Parts of the API, like concurrent queries,
will only work if revents are set though, so you definitely want to.

> >In your event_watch_fn, you should be setting the appropriate
> >POLLIN/POLLOUT equivalents in libevent for the fd. When a fd is active
> >and one of the libevent callbacks is fired, you should be clearing the
> >ready events (otherwise you'll get a busy spin, especially on POLLOUT)
> >and call drizzle_con_revents() to let the library know what is ready.
> What do you mean by "clear" the event? To me, that means "stop
> waiting for the event." My experience, and looking at the gearman
> example, it seems that I need to *continue* waiting for events. As
> you note, this is tricky with write events, unless libdrizzle
> immediately says "no longer interested."

One you call set_revents() on a connection, you should stop waiting
for that particular set of events. libdrizzle will call the event
callback function again if it should be set.

> Similarly, I'm confused how to deregister when a connection is
> closed. Is it safe to assume the answer is "you need to deregister
> when you close/free the connection"?

De-register? Just remove the event from libevent and drizzle_con_free()
the connection object, this should clean everything up.


Follow ups