X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-sharp%2FServiceTypeBrowser.cs;h=ab6a8668183d852a84ab0aa7997c084d09f350b5;hb=bf7f48d6f58f28681b81915ddc4723950b947346;hp=e436da9a834555e341b5a1546cd5b26db22692c5;hpb=a9566d5dcac080d7fa91546823277c57a5d09a5f;p=catta diff --git a/avahi-sharp/ServiceTypeBrowser.cs b/avahi-sharp/ServiceTypeBrowser.cs index e436da9..ab6a866 100644 --- a/avahi-sharp/ServiceTypeBrowser.cs +++ b/avahi-sharp/ServiceTypeBrowser.cs @@ -117,20 +117,27 @@ namespace Avahi private void Start () { - if (handle != IntPtr.Zero || (addListeners.Count == 0 && removeListeners.Count == 0)) + if (client.Handle == IntPtr.Zero || handle != IntPtr.Zero || + (addListeners.Count == 0 && removeListeners.Count == 0)) return; - IntPtr domainPtr = Utility.StringToPtr (domain); - handle = avahi_service_type_browser_new (client.Handle, iface, (int) proto, domainPtr, - cb, IntPtr.Zero); - Utility.Free (domainPtr); + lock (client) { + IntPtr domainPtr = Utility.StringToPtr (domain); + handle = avahi_service_type_browser_new (client.Handle, iface, (int) proto, domainPtr, + cb, IntPtr.Zero); + Utility.Free (domainPtr); + } } private void Stop (bool force) { - if (handle != IntPtr.Zero && (force || (addListeners.Count == 0 && removeListeners.Count == 0))) { - avahi_service_type_browser_free (handle); - handle = IntPtr.Zero; + if (client.Handle != IntPtr.Zero && handle != IntPtr.Zero && + (force || (addListeners.Count == 0 && removeListeners.Count == 0))) { + + lock (client) { + avahi_service_type_browser_free (handle); + handle = IntPtr.Zero; + } } }