#include "config.h"
static AvahiEntryGroup *group = NULL;
-static char *name = NULL;
+static char *name = NULL, *name2 = NULL;
static AvahiSimplePoll *avahi_asp = NULL;
static const AvahiPoll *avahi_poll = NULL;
static int avahi_do_restart = 0;
/* A service name collision with a remote service
* happened. Let's pick a new name */
n = avahi_alternative_service_name(name);
- avahi_free(name);
+ if (name != name2) avahi_free(name);
name = n;
tvherror(LS_AVAHI, "Service name collision, renaming service to '%s'", name);
/* A service name collision with a local service happened. Let's
* pick a new name */
n = avahi_alternative_service_name(name);
- avahi_free(name);
+ if (name != name2) avahi_free(name);
name = n;
tvherror(LS_AVAHI, "Service name collision, renaming service to '%s'", name);
avahi_thread(void *aux)
{
AvahiClient *ac;
- char *name2;
do {
if (avahi_poll)
name = NULL;
avahi_free(name2);
+ name2 = NULL;
} while (tvheadend_is_running() && avahi_do_restart);
#if ENABLE_TRACE
static void *tvh_thread_watch_thread(void *aux)
{
- int64_t now;
+ int64_t now, limit;
tvh_mutex_t *mutex, dmutex;
+ const char *s;
+ s = getenv("TVHEADEND_THREAD_WATCH_LIMIT");
+ limit = s ? atol(s) : 5;
+ limit = MINMAX(limit, 5, 120);
while (!atomic_get(&tvhwatch_done)) {
pthread_mutex_lock(&thrwatch_mutex);
now = getfastmonoclock();
mutex = TAILQ_LAST(&thrwatch_mutexes, tvh_mutex_queue);
- if (mutex && mutex->tstamp + sec2mono(5) < now) {
+ if (mutex && mutex->tstamp + sec2mono(limit) < now) {
pthread_mutex_unlock(&thrwatch_mutex);
tvh_thread_mutex_failed(mutex, "deadlock", __FILE__, __LINE__);
}