summaryrefslogtreecommitdiffstats
path: root/avahi-sharp/ServiceTypeBrowser.cs
diff options
context:
space:
mode:
Diffstat (limited to 'avahi-sharp/ServiceTypeBrowser.cs')
-rw-r--r--avahi-sharp/ServiceTypeBrowser.cs23
1 files changed, 15 insertions, 8 deletions
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;
+ }
}
}