From 9ea179a97d957e41be9eccc03236e254220c3ad2 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 2 Apr 2014 12:25:40 +0100 Subject: [PATCH] mc-debug-server: if we have several reasons to stop, don't crash Previously, when the session and (fake) system bus closed (simultaneously, because they are in fact the same dbus-daemon), we would call mcd_mission_abort() for the first one. That results in a call to tp_clear_object (&mcd), and then the second call to mcd_mission_abort (mcd) would crash with a critical warning, because MCD_IS_MISSION (NULL) is false. --- tests/twisted/mc-debug-server.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tests/twisted/mc-debug-server.c b/tests/twisted/mc-debug-server.c index 644dd40..33da426 100644 --- a/tests/twisted/mc-debug-server.c +++ b/tests/twisted/mc-debug-server.c @@ -57,7 +57,12 @@ bus_closed (GDBusConnection *connection, g_quark_to_string (error->domain), error->code, error->message); g_dbus_connection_set_exit_on_close (connection, FALSE); - mcd_mission_abort ((McdMission *) mcd); + + if (mcd != NULL) + { + g_message ("Aborting because D-Bus connection has closed"); + mcd_mission_abort ((McdMission *) mcd); + } } static gboolean @@ -79,9 +84,17 @@ on_abort (gpointer unused G_GNUC_UNUSED) static gboolean delayed_abort (gpointer data G_GNUC_UNUSED) { - g_message ("Aborting by popular request"); - mcd_mission_abort ((McdMission *) mcd); - return FALSE; + if (mcd != NULL) + { + g_message ("Aborting as requested via D-Bus"); + mcd_mission_abort ((McdMission *) mcd); + } + else + { + g_message ("mcd has already gone away"); + } + + return FALSE; } static gboolean -- 1.9.1