neil / rpms / udisks2

Forked from rpms/udisks2 a year ago
Clone
eb981d
From 4e26232e5a207b3a5269a5f6d735f1a32b31a4e8 Mon Sep 17 00:00:00 2001
eb981d
From: Andrea Azzarone <azzaronea@gmail.com>
eb981d
Date: Fri, 30 Mar 2018 09:15:30 +0000
eb981d
Subject: [PATCH] main.c: Properly remove sigint source
eb981d
eb981d
Revert d9f7b05 and properly fix the critical warning.
eb981d
---
eb981d
 src/main.c | 18 ++++++------------
eb981d
 1 file changed, 6 insertions(+), 12 deletions(-)
eb981d
eb981d
diff --git a/src/main.c b/src/main.c
eb981d
index 88f3dafac..0444e0179 100644
eb981d
--- a/src/main.c
eb981d
+++ b/src/main.c
eb981d
@@ -93,7 +93,7 @@ on_sigint (gpointer user_data)
eb981d
 {
eb981d
   udisks_info ("Caught SIGINT. Initiating shutdown");
eb981d
   g_main_loop_quit (loop);
eb981d
-  return FALSE;
eb981d
+  return G_SOURCE_CONTINUE; /* We will manually remove the source using g_source_remove */
eb981d
 }
eb981d
 
eb981d
 int
eb981d
@@ -104,12 +104,13 @@ main (int    argc,
eb981d
   GOptionContext *opt_context;
eb981d
   gint ret;
eb981d
   guint name_owner_id;
eb981d
-  GSource *sigint_source = NULL;
eb981d
+  guint sigint_id;
eb981d
 
eb981d
   ret = 1;
eb981d
   loop = NULL;
eb981d
   opt_context = NULL;
eb981d
   name_owner_id = 0;
eb981d
+  sigint_id = 0;
eb981d
 
eb981d
   /* avoid gvfs (http://bugzilla.gnome.org/show_bug.cgi?id=526454) */
eb981d
   if (!g_setenv ("GIO_USE_VFS", "local", TRUE))
eb981d
@@ -148,13 +149,11 @@ main (int    argc,
eb981d
 
eb981d
   if (!opt_no_sigint)
eb981d
     {
eb981d
-      guint sigint_id = g_unix_signal_add_full (G_PRIORITY_DEFAULT,
eb981d
+      sigint_id = g_unix_signal_add_full (G_PRIORITY_DEFAULT,
eb981d
                                           SIGINT,
eb981d
                                           on_sigint,
eb981d
                                           NULL,  /* user_data */
eb981d
                                           NULL); /* GDestroyNotify */
eb981d
-      if (sigint_id)
eb981d
-        sigint_source = g_main_context_find_source_by_id (NULL, sigint_id);
eb981d
     }
eb981d
 
eb981d
   name_owner_id = g_bus_own_name (G_BUS_TYPE_SYSTEM,
eb981d
@@ -175,13 +174,8 @@ main (int    argc,
eb981d
   ret = 0;
eb981d
 
eb981d
  out:
eb981d
-  if (sigint_source)
eb981d
-    {
eb981d
-      if(! g_source_is_destroyed(sigint_source))
eb981d
-        {
eb981d
-          g_source_destroy (sigint_source);
eb981d
-        }
eb981d
-    }
eb981d
+  if (sigint_id > 0)
eb981d
+    g_source_remove (sigint_id);
eb981d
   if (the_daemon != NULL)
eb981d
     g_object_unref (the_daemon);
eb981d
   if (name_owner_id != 0)