[avahi] corrupted double-linked list
lennart at poettering.net
Fri May 8 13:34:38 PDT 2009
On Fri, 08.05.09 09:11, Gaspard Bucher (gaspard at teti.ch) 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...
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:
/* First lock things */
/* The call Avahi client functions */
foo = avahi_client_xxx(bar);
waldo = avahi_service_browser_yyy(humpf);
/* When you are done, unlock things again */
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 Poettering Red Hat, Inc.
lennart [at] poettering [dot] net
http://0pointer.net/lennart/ GnuPG 0x1A015CC4
More information about the avahi