X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-sharp%2FHostNameResolver.cs;h=d522cea66425594164784853b41254b979d55f6d;hb=264700bf97de2e4430494cb41201950162fba020;hp=a8cf0f17052d117cdf83313e6ea0c7dc9a90ebee;hpb=4d283fbd912fbeab578447ea18c0d8f47aa5cea6;p=catta diff --git a/avahi-sharp/HostNameResolver.cs b/avahi-sharp/HostNameResolver.cs index a8cf0f1..d522cea 100644 --- a/avahi-sharp/HostNameResolver.cs +++ b/avahi-sharp/HostNameResolver.cs @@ -118,20 +118,29 @@ namespace Avahi private void Start () { - if (handle != IntPtr.Zero || (foundListeners.Count == 0 && timeoutListeners.Count == 0)) + if (client.Handle == IntPtr.Zero || handle != IntPtr.Zero || + (foundListeners.Count == 0 && timeoutListeners.Count == 0)) return; IntPtr hostPtr = Utility.StringToPtr (hostname); - handle = avahi_host_name_resolver_new (client.Handle, iface, proto, hostPtr, aproto, - cb, IntPtr.Zero); + + lock (client) { + handle = avahi_host_name_resolver_new (client.Handle, iface, proto, hostPtr, aproto, + cb, IntPtr.Zero); + } + Utility.Free (hostPtr); } private void Stop (bool force) { - if (handle != IntPtr.Zero && (force || (foundListeners.Count == 0 && timeoutListeners.Count == 0))) { - avahi_host_name_resolver_free (handle); - handle = IntPtr.Zero; + if (client.Handle != IntPtr.Zero && handle != IntPtr.Zero && + (force || (foundListeners.Count == 0 && timeoutListeners.Count == 0))) { + + lock (client) { + avahi_host_name_resolver_free (handle); + handle = IntPtr.Zero; + } } }