[RFC] [WIP] tevent/glib integration

Ralph Boehme rb at sernet.de
Fri Jan 22 15:56:52 UTC 2016

Hi Noel,

On Mon, Jan 11, 2016 at 12:56:12PM +0000, Noel Power wrote:
> ... long snip ...

ok, so we both agree that both solutions are ugly. ;)

Metze had a better idea in a private conversation: use epoll to create
an epoll instance and add the returned fd to tevent via
tevent_add_fd(). Later add all glib fds to the new epoll instance via
epoll_ctl(). epoll_wait() will then return all glib fds with events
pending. This can all be done on top of tevent.

In case epoll is not available, in the glue code as a fallback use a
tevent_fd per glib fd and in the handler call poll() a second time on
the glib fds. That way we get the raw revents and can handle all
pending events in one swoop.

This would work without any modifications to the tevent code.

I have a wip branch here:

This just adds the fallback method without any optimisations,
particulariy epoll is left out.

The good:
- completely on top of tevent

The bad:
- calls poll() twice (once in tevent, once in the glue code)

The ugly:
- doesn't work yet :)

This version keeps the context locked most of the time, just briely
unlocking it and specific points to give other threads a chance to use
the context. This is what glib does as well, I've been through the
glib code with metze and we believe this approach is sane.

Wasn't sure whether you where awaiting a reply, so I'm presenting this
now even though there's still a bug somewhere so the test utility
doesn't work yet, at least I hope it's just a bug and not a design
issue. :)

This patch puts the patch into tevent itself, we could also put it
into source3/lib/.


SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen

More information about the samba-technical mailing list