[avahi] Problems with avahi segfaulting when cleaning up resources

Jim Hodapp james.hodapp at gmail.com
Fri Oct 24 10:45:44 PDT 2008


I am using Avahi version 0.6.14 and am trying to use it on an embedded  
ARM11 processor. I am using the example avahi-core for publishing a  
service, but modified it to use a threaded-poll instead of the simple  
poll. So when trying to unpublish any services published with avahi  
and freeing any resources that it used, Avahi seems to randomly  
complete sometimes, sometimes abort (due to asserts not evaluating to  
true) and sometimes segfault. I am not sure why this is happening,  
perhaps I am not freeing things correctly.

Here is my unpublish function:

int unpublish_services()
{
	int ret = 0;

	avahi_threaded_poll_lock(threaded_poll);

	avahi_threaded_poll_stop(threaded_poll);

	avahi_threaded_poll_unlock(threaded_poll);

	avahi_free(name);

	if (server)
		avahi_server_free(server);
	else
		ret = -1;

	if (threaded_poll)
		avahi_threaded_poll_free(threaded_poll);
	else
		ret = -1

	return ret;
}

threaded_poll, name, and server are all defined at the top of this  
same .c file as follows:

static AvahiThreadedPoll *threaded_poll = NULL;
static AvahiServer *server = NULL;
static char *name = NULL;

server and threaded_poll are both allocated and defined in a function  
in the same file like:

server = avahi_server_new(avahi_threaded_poll_get(threaded_poll),  
&config, server_callback, NULL, &error);


Any insight is greatly appreciated.

Thanks,

Jim


More information about the avahi mailing list