]> git.meshlink.io Git - catta/commitdiff
* make the event loop background again
authorJames Willcox <snopr@snorp.net>
Mon, 8 May 2006 02:27:25 +0000 (02:27 +0000)
committerJames Willcox <snopr@snorp.net>
Mon, 8 May 2006 02:27:25 +0000 (02:27 +0000)
* ensure the event loop is finished before freeing the poll object
* set Client.Handle to null immediately after freeing it

git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1216 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe

avahi-sharp/Client.cs

index 40ca4119adc917d560913578c34d251aaab2223a..02763d40d67be6357ef00355a39b22e1d13dcfe1 100644 (file)
@@ -271,6 +271,7 @@ namespace Avahi
                 throw new ClientException (error);
 
             thread = new Thread (PollLoop);
+            thread.IsBackground = true;
             thread.Start ();
         }
 
@@ -287,9 +288,12 @@ namespace Avahi
             if (handle != IntPtr.Zero) {
                 lock (this) {
                     avahi_client_free (handle);
+                    handle = IntPtr.Zero;
+
                     avahi_simple_poll_quit (spoll);
+                    Monitor.Wait (this);
+                    
                     avahi_simple_poll_free (spoll);
-                    handle = IntPtr.Zero;
                 }
             }
         }
@@ -371,6 +375,7 @@ namespace Avahi
             try {
                 lock (this) {
                     avahi_simple_poll_loop (spoll);
+                    Monitor.Pulse (this);
                 }
             } catch (Exception e) {
                 Console.Error.WriteLine ("Error in avahi-sharp event loop: " + e);