[avahi] Problems with avahi segfaulting when cleaning up resources

Lennart Poettering lennart at poettering.net
Sun Oct 26 07:41:55 PDT 2008


On Fri, 24.10.08 13:45, Jim Hodapp (james.hodapp at gmail.com) wrote:

> 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);

_stop() is should be called unlocked. It locks internally anyway and the
mutex is not recursive.

> 
> 	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;
> }

Otherwise the logic looks about right to me. i.e. first, stop the
poll, then free the server, then free the poll.

Lennart

-- 
Lennart Poettering                        Red Hat, Inc.
lennart [at] poettering [dot] net         ICQ# 11060553
http://0pointer.net/lennart/           GnuPG 0x1A015CC4


More information about the avahi mailing list