From e4f2df4a6eedaf8038123f25b636580e4dfa04f3 Mon Sep 17 00:00:00 2001 From: Alexandre Rostovtsev Date: Mon, 14 Feb 2011 22:22:20 -0500 Subject: [PATCH] Fix frequent beagled crashes under mono-2.8 (#641270) Beagled frequently crashes under mono-2.8 due to uncaught exceptions in UnixConnectionHandler.WatchCallback() (see Gnome bug #641270 and http://bugs.gentoo.org/show_bug.cgi?id=353533). These crashes have two origins. First, probably due to threading changes in mono, when WatchCallback() is called, client can be null, so we need to check for it. Second, presumably due to the exception policy changes in mono-2.8, client.GetStream().EndRead() legitimately - and fairly frequently - throws an IOException with Message "Not connected" and with a null InnerException (instead of a SocketException, as was the case under previous versions of mono); so we need to catch it. Signed-off-by: Alexandre Rostovtsev --- beagle/beagled/Server.cs | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/beagle/beagled/Server.cs b/beagle/beagled/Server.cs index 0892dd9..f2ad70f 100644 --- a/beagle/beagled/Server.cs +++ b/beagle/beagled/Server.cs @@ -462,9 +462,10 @@ namespace Beagle.Daemon { int bytes_read = 0; try { - bytes_read = this.client.GetStream ().EndRead (ar); + if (this.client != null) + bytes_read = this.client.GetStream ().EndRead (ar); } catch (IOException e) { - if (! (e.InnerException is SocketException)) + if (! (e.InnerException is SocketException) && e.Message != "Not connected") throw e; } catch (ObjectDisposedException) { } -- 1.7.4.1