On Fri, 08.05.09 09:11, Gaspard Bucher ([email protected]) wrote: > I cannot seem to get avahi to work in my application. During runtime I get > > *** glibc detected *** ... corrupted double-linked list > > This seems to be related to avahi in very strange ways. Has anyone > experienced such problems when using avahi ? > > Any help would be greatly appreciated. I really feel stupid here... > > code: > http://github.com/rubyk/rubyk/tree/master/oscit/src/linux
Uh. I don't really grok that code. Bu uh, you seem not to lock the threaded main loop ever. Which gives me the idea that this issue is simply a race issue, because of incomplete locking. Please note that Avahi is not thread-safe by itself. It offers you a few tools to use it in a threaded environment however. But you have to do all locking explicitly yourself, Avahi won't do it for you implicitly. Basically the idea is that after you started the threaded event loop if you need to touch the avahi context in anyway from anothe thread you have to lock the event loop first (i.e. temporarily interrupt its execution) and then unlock after your access. i.e. something like this: <snip> /* First lock things */ avahi_threaded_poll_lock(ml); /* The call Avahi client functions */ foo = avahi_client_xxx(bar); waldo = avahi_service_browser_yyy(humpf); /* When you are done, unlock things again */ avahi_threaded_poll_unlock(ml); </snip> This locking logic works very similar to Java monitors if you know those. Or it's even a bit like the MT support in the GLib event loop. Hope this helps, Lennart -- Lennart Poettering Red Hat, Inc. lennart [at] poettering [dot] net http://0pointer.net/lennart/ GnuPG 0x1A015CC4 _______________________________________________ avahi mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/avahi
