X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-compat-howl%2Fcompat.c;h=1663af021924104d033cb4e7ba618068a7acf657;hb=0c54764cf19428a0c52724a75ddf3368e3899209;hp=120f81baaa6dcd0af97db7b9789e6b0297725132;hpb=9da0241b9c1bf751605ba11fa6d4c75e34fe5f2b;p=catta diff --git a/avahi-compat-howl/compat.c b/avahi-compat-howl/compat.c index 120f81b..1663af0 100644 --- a/avahi-compat-howl/compat.c +++ b/avahi-compat-howl/compat.c @@ -33,7 +33,10 @@ #include #include #include + #include +#include +#include #include "howl.h" #include "warn.h" @@ -88,7 +91,7 @@ struct _sw_discovery { pthread_t thread; int thread_running; - pthread_mutex_t mutex; + pthread_mutex_t mutex, salt_mutex; AVAHI_LLIST_HEAD(service_data, services); }; @@ -370,6 +373,7 @@ sw_result sw_discovery_init(sw_discovery * self) { ASSERT_SUCCESS(pthread_mutexattr_init(&mutex_attr)); pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE); ASSERT_SUCCESS(pthread_mutex_init(&(*self)->mutex, &mutex_attr)); + ASSERT_SUCCESS(pthread_mutex_init(&(*self)->salt_mutex, &mutex_attr)); if (!((*self)->simple_poll = avahi_simple_poll_new())) goto fail; @@ -451,6 +455,7 @@ static void discovery_unref(sw_discovery self) { close(self->main_fd); ASSERT_SUCCESS(pthread_mutex_destroy(&self->mutex)); + ASSERT_SUCCESS(pthread_mutex_destroy(&self->salt_mutex)); while (self->services) service_data_free(self, self->services); @@ -610,7 +615,7 @@ sw_result sw_salt_lock(sw_salt self) { AVAHI_WARN_LINKAGE; assert(self); - ASSERT_SUCCESS(pthread_mutex_lock(&((sw_discovery) self)->mutex)); + ASSERT_SUCCESS(pthread_mutex_lock(&((sw_discovery) self)->salt_mutex)); return SW_OKAY; } @@ -620,7 +625,7 @@ sw_result sw_salt_unlock(sw_salt self) { AVAHI_WARN_LINKAGE; - ASSERT_SUCCESS(pthread_mutex_unlock(&((sw_discovery) self)->mutex)); + ASSERT_SUCCESS(pthread_mutex_unlock(&((sw_discovery) self)->salt_mutex)); return SW_OKAY; }