From 88d80935d6c5930fe0657da8383487a23c4705ab Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Tue, 9 Oct 2012 16:30:09 +0200 Subject: core: second request to terminate does a hard exit() --- src/main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index ec82ccce..5a8081e9 100644 --- a/src/main.c +++ b/src/main.c @@ -119,6 +119,7 @@ name_lost_cb (GDBusConnection *connection, int main (int argc, char *argv[]) { + GMainLoop *inner; GError *err = NULL; guint name_id; @@ -156,6 +157,11 @@ main (int argc, char *argv[]) loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (loop); + /* Clear the global variable, so that subsequent requests to + * exit succeed. */ + inner = loop; + loop = NULL; + if (manager) { GTimer *timer; @@ -167,7 +173,7 @@ main (int argc, char *argv[]) timer = g_timer_new (); while (mm_manager_num_modems (manager) && g_timer_elapsed (timer, NULL) < (gdouble)MAX_SHUTDOWN_TIME_SECS) { - GMainContext *ctx = g_main_loop_get_context (loop); + GMainContext *ctx = g_main_loop_get_context (inner); g_main_context_iteration (ctx, FALSE); g_usleep (50); @@ -182,6 +188,8 @@ main (int argc, char *argv[]) g_timer_destroy (timer); } + g_main_loop_unref (inner); + g_bus_unown_name (name_id); mm_info ("ModemManager is shut down"); -- cgit v1.2.3-70-g09d2