summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Willcox <snopr@snorp.net>2006-05-07 18:51:06 +0000
committerJames Willcox <snopr@snorp.net>2006-05-07 18:51:06 +0000
commitbd121fc9b9f6bdcd7074e4fb15b195ce0e491b5c (patch)
tree5d7151176bae5757ff9d4e5b358a2a8d5a8aabd8
parent8c60b7106768778bae894e90d6981cf05ec68ca4 (diff)
add a missing lock, and make the event processing thread non-background.
fixes some crashes with Dispose() git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1215 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
-rw-r--r--avahi-sharp/AvahiTest.cs1
-rw-r--r--avahi-sharp/Client.cs11
2 files changed, 7 insertions, 5 deletions
diff --git a/avahi-sharp/AvahiTest.cs b/avahi-sharp/AvahiTest.cs
index fcec737..ba4d59b 100644
--- a/avahi-sharp/AvahiTest.cs
+++ b/avahi-sharp/AvahiTest.cs
@@ -42,6 +42,7 @@ public class AvahiTest {
BrowseServiceTypes ("local");
Console.WriteLine ("Press enter to quit");
Console.ReadLine ();
+ client.Dispose ();
}
private static void OnEntryGroupChanged (object o, EntryGroupStateArgs args)
diff --git a/avahi-sharp/Client.cs b/avahi-sharp/Client.cs
index 6d39469..40ca411 100644
--- a/avahi-sharp/Client.cs
+++ b/avahi-sharp/Client.cs
@@ -271,7 +271,6 @@ namespace Avahi
throw new ClientException (error);
thread = new Thread (PollLoop);
- thread.IsBackground = true;
thread.Start ();
}
@@ -286,10 +285,12 @@ namespace Avahi
public void Dispose ()
{
if (handle != IntPtr.Zero) {
- avahi_client_free (handle);
- avahi_simple_poll_quit (spoll);
- avahi_simple_poll_free (spoll);
- handle = IntPtr.Zero;
+ lock (this) {
+ avahi_client_free (handle);
+ avahi_simple_poll_quit (spoll);
+ avahi_simple_poll_free (spoll);
+ handle = IntPtr.Zero;
+ }
}
}