[libvirt PATCH 3/5] nwfilterDriverRemoveDBusMatches: Prevent unsubscribing from null id

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Allow nwfilterDriverRemoveDBusMatches to be called without
nwfilterDriverInstallDBusMatches being called previously.

This enables a later patch to use nwfilterDriverRemoveDBusMatches
as a cleanup function safely.

Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx>
---
 src/nwfilter/nwfilter_driver.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index 1f7d40e1b0..f89b5b8757 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -77,12 +77,19 @@ static unsigned int reloadID;
 static void
 nwfilterDriverRemoveDBusMatches(void)
 {
-    GDBusConnection *sysbus;
+    GDBusConnection *sysbus = virGDBusGetSystemBus();
 
-    sysbus = virGDBusGetSystemBus();
-    if (sysbus) {
+    if (!sysbus)
+        return;
+
+    if (restartID != 0) {
         g_dbus_connection_signal_unsubscribe(sysbus, restartID);
+        restartID = 0;
+    }
+
+    if (reloadID != 0) {
         g_dbus_connection_signal_unsubscribe(sysbus, reloadID);
+        reloadID = 0;
     }
 }
 
-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux