- /* Than, do your stuff */
- avahi_threaded_poll_quit(ctx->threaded_poll);
-
- /* Finally, unblock the event loop */
- avahi_threaded_poll_unlock(ctx->threaded_poll);
- ctx->thread_running = 0;
+ if (ctx) {
+ LOG(log_error, logtype_afpd, "av_zeroconf_unregister: avahi_threaded_poll_stop");
+ if (ctx->threaded_poll)
+ avahi_threaded_poll_stop(ctx->threaded_poll);
+ LOG(log_error, logtype_afpd, "av_zeroconf_unregister: avahi_client_free");
+ if (ctx->client)
+ avahi_client_free(ctx->client);
+ LOG(log_error, logtype_afpd, "av_zeroconf_unregister: avahi_threaded_poll_free");
+ if (ctx->threaded_poll)
+ avahi_threaded_poll_free(ctx->threaded_poll);
+ free(ctx);
+ ctx = NULL;