summaryrefslogtreecommitdiffstats
path: root/avahi-sharp/ServiceResolver.cs
diff options
context:
space:
mode:
authorJames Willcox <snopr@snorp.net>2005-09-14 02:32:27 +0000
committerJames Willcox <snopr@snorp.net>2005-09-14 02:32:27 +0000
commit264700bf97de2e4430494cb41201950162fba020 (patch)
treeb7131e3afc84e0459e17860a43208b21b6286362 /avahi-sharp/ServiceResolver.cs
parent4a10eaeee609b84972ef2b2d0a0fab8a3664891a (diff)
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
Diffstat (limited to 'avahi-sharp/ServiceResolver.cs')
-rw-r--r--avahi-sharp/ServiceResolver.cs22
1 files changed, 15 insertions, 7 deletions
diff --git a/avahi-sharp/ServiceResolver.cs b/avahi-sharp/ServiceResolver.cs
index 558ba53..8e8464b 100644
--- a/avahi-sharp/ServiceResolver.cs
+++ b/avahi-sharp/ServiceResolver.cs
@@ -135,14 +135,19 @@ 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 namePtr = Utility.StringToPtr (name);
IntPtr typePtr = Utility.StringToPtr (type);
IntPtr domainPtr = Utility.StringToPtr (domain);
- handle = avahi_service_resolver_new (client.Handle, iface, proto, namePtr, typePtr, domainPtr,
- aproto, cb, IntPtr.Zero);
+
+ lock (client) {
+ handle = avahi_service_resolver_new (client.Handle, iface, proto, namePtr, typePtr, domainPtr,
+ aproto, cb, IntPtr.Zero);
+ }
+
Utility.Free (namePtr);
Utility.Free (typePtr);
Utility.Free (domainPtr);
@@ -150,9 +155,13 @@ namespace Avahi
private void Stop (bool force)
{
- if (handle != IntPtr.Zero && (force || (foundListeners.Count == 0 && timeoutListeners.Count == 0))) {
- avahi_service_resolver_free (handle);
- handle = IntPtr.Zero;
+ if (client.Handle != IntPtr.Zero && handle != IntPtr.Zero &&
+ (force || (foundListeners.Count == 0 && timeoutListeners.Count == 0))) {
+
+ lock (client) {
+ avahi_service_resolver_free (handle);
+ handle = IntPtr.Zero;
+ }
}
}
@@ -161,7 +170,6 @@ namespace Avahi
IntPtr domain, IntPtr host, IntPtr address,
UInt16 port, IntPtr txt, IntPtr userdata)
{
-
ServiceInfo info;
info.NetworkInterface = iface;
info.Protocol = proto;