]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
fix objects termination clashes on shutdown 258/head
authorOndrej Kozina <okozina@redhat.com>
Mon, 8 Aug 2016 12:24:03 +0000 (14:24 +0200)
committerOndrej Kozina <okozina@redhat.com>
Mon, 8 Aug 2016 12:24:03 +0000 (14:24 +0200)
server/Background.cc
server/Background.h
server/Client.cc
server/Client.h
server/snapperd.cc

index 21b580fadcf228059f9a0852aebb3d2b9e8d9373..32ad57c551389c8cd3644544a000cc59388989d7 100644 (file)
@@ -31,9 +31,6 @@
 #include "Background.h"
 
 
-Backgrounds backgrounds;
-
-
 Backgrounds::Backgrounds()
 {
 }
index 70b46661b4ae5dd70f80a38f4cb8da931ac7485a..a8dbef18438e9615ff20953204caa8834f20fd87 100644 (file)
@@ -75,7 +75,4 @@ private:
 };
 
 
-extern Backgrounds backgrounds;
-
-
 #endif
index d56a967a67db2bf32dcbcbc8bd9345a33972528a..c658c1679b33bbec517ada6ec441a1f24c60e990 100644 (file)
 
 boost::shared_mutex big_mutex;
 
-Clients clients;
 
-
-Client::Client(const string& name)
-    : name(name), zombie(false)
+Client::Client(const string& name, const Clients& clients)
+    : name(name), zombie(false), clients(clients)
 {
 }
 
@@ -1027,7 +1025,7 @@ Client::create_post_snapshot(DBus::Connection& conn, DBus::Message& msg)
     bool background_comparison = true;
     it->getConfigInfo().getValue("BACKGROUND_COMPARISON", background_comparison);
     if (background_comparison)
-       backgrounds.add_task(it, snap1, snap2);
+       clients.backgrounds().add_task(it, snap1, snap2);
 
     DBus::MessageMethodReturn reply(msg);
 
@@ -1431,7 +1429,7 @@ Client::debug(DBus::Connection& conn, DBus::Message& msg) const
     }
 
     hoho << "backgrounds:";
-    for (Backgrounds::const_iterator it = backgrounds.begin(); it != backgrounds.end(); ++it)
+    for (Backgrounds::const_iterator it = clients.backgrounds().begin(); it != clients.backgrounds().end(); ++it)
     {
        std::ostringstream s;
        s << "    name:'" << it->meta_snapper->configName() << "'";
@@ -1726,6 +1724,19 @@ Client::worker()
 }
 
 
+Clients::Clients(Backgrounds& backgrounds)
+    : bgs(backgrounds)
+{
+}
+
+
+Backgrounds&
+Clients::backgrounds() const
+{
+    return bgs;
+}
+
+
 Clients::iterator
 Clients::find(const string& name)
 {
@@ -1742,7 +1753,7 @@ Clients::add(const string& name)
 {
     assert(find(name) == entries.end());
 
-    entries.emplace_back(name);
+    entries.emplace_back(name, *this);
 
     return --entries.end();
 }
index cad857b674f2325461d8f1430367fb1f5e3c928d..dbeb7a57b0f4c37c55a36b39bfa15039e0116215 100644 (file)
@@ -51,6 +51,9 @@ using namespace snapper;
 
 extern boost::shared_mutex big_mutex;
 
+class Backgrounds;
+class Clients;
+
 
 struct NoComparison : Exception
 {
@@ -112,7 +115,7 @@ public:
 
     void dispatch(DBus::Connection& conn, DBus::Message& msg);
 
-    Client(const string& name);
+    Client(const string& name, const Clients& clients);
     ~Client();
 
     list<Comparison*>::iterator find_comparison(Snapper* snapper, unsigned int number1,
@@ -160,12 +163,15 @@ private:
 
     void worker();
 
+    const Clients& clients;
+
 };
 
 
 class Clients
 {
 public:
+    Clients(Backgrounds& backgrounds);
 
     typedef list<Client>::iterator iterator;
     typedef list<Client>::const_iterator const_iterator;
@@ -185,14 +191,15 @@ public:
 
     bool has_zombies() const;
 
+    Backgrounds& backgrounds() const;
+
 private:
 
     list<Client> entries;
 
-};
-
+    Backgrounds& bgs;
 
-extern Clients clients;
+};
 
 
 #endif
index 7e0c34030950f205c35a83e94d0636e0ebae39a2..8623015d1c251bba06c92fa3bf4b3169bbcbf19e 100644 (file)
@@ -57,11 +57,16 @@ public:
     void periodic();
     milliseconds periodic_timeout();
 
+private:
+
+    Backgrounds backgrounds;
+    Clients clients;
+
 };
 
 
 MyMainLoop::MyMainLoop(DBusBusType type)
-    : MainLoop(type)
+    : MainLoop(type), backgrounds(), clients(backgrounds)
 {
 }