← 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 08:06:42AM -0500, Evan Jones wrote:
> Am I supposed to call drizzle_con_revents()? The documentation
> suggests that I should. However, I'm following examples/client.c
> which just calls the API calls that returned IO_WAIT again. That
> seems to be working for me at the moment.

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().

> When I get a call to my event_watch_fn, I'm assuming the event
> watches should be "persistent." That is, I should continue to watch
> the fd for those events, until I get another call to my
> event_watch_fn with the bit set to zero?

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.

I use a very similar event model in Gearman, and the server for
that has an example of libevent integration. The are a few small
differences, but it shows a working example. See the _con_ready
function in:

http://bazaar.launchpad.net/~gearman-developers/gearmand/trunk/annotate/head%3A/libgearman-server/gearmand_con.c

> probably don't want to apply any of these directly, but I think
> these are are legitimate fixes (with a little clean up, maybe):
> 
> https://code.launchpad.net/~evanj/libdrizzle/external-event-loop
> 
> 123 - fix a make check-valgrind warning
> 124 - fix examples to match documentation
> 125 - expand the documentation for event_watch_fn
> 126 - tests for event_watch_fn and missing calls to set_events (i think)
> 127; 128 - context should be void* not const void* for use in C++
> 129 - make check-valgrind fix should have been included in r123

Great, thanks! I'll take a look at these and merge what is appropriate.

-Eric



Follow ups

References