From 264700bf97de2e4430494cb41201950162fba020 Mon Sep 17 00:00:00 2001 From: James Willcox Date: Wed, 14 Sep 2005 02:32:27 +0000 Subject: lose the dep on avahi-glib, and run the avahi loop in a thread git-svn-id: file:///home/lennart/svn/public/avahi/trunk@580 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- avahi-sharp/HostNameResolver.cs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'avahi-sharp/HostNameResolver.cs') 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; + } } } -- cgit