[RFC] [WIP] tevent/glib integration

Noel Power nopower at suse.com
Fri Jan 22 16:14:16 UTC 2016

On 22/01/16 15:56, Ralph Boehme wrote:
> 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. ;)
well I know my one is
> 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:
> <https://git.samba.org/?p=slow/samba.git;a=log;h=refs/heads/tevent-glib-glue>
> 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.
so, I haven't looked at the code so I don't know if this is relevant but
I tried splitting unlocking/locking the glib_context over the
{prepare,query.check.dispatch} phases and it didn't play well with the
performance vrs acquiring the context at the start and releasing it
after the dispatch. Maybe we are talking about different things or maybe
I made some mistake when I tried this, just putting out there just in case
>  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, 
I am currently distracted by other stuff :(  so not really
> 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. :)
hopefully I will get a chance to digest what you posted above soon


More information about the samba-technical mailing list