summaryrefslogtreecommitdiffstats
path: root/src/Daemon
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-08-24 18:08:21 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-08-24 18:08:21 +0200
commitffb9d48d975cab3683bbbf9f94e0eacefcf4ce5b (patch)
tree1f6f1f8b0e74377c0c15e435bd4a3a027a87804b /src/Daemon
parent18d048afff2d14a9c2b7bf0b64e973eda5b40954 (diff)
downloadabrt-ffb9d48d975cab3683bbbf9f94e0eacefcf4ce5b.tar.gz
abrt-ffb9d48d975cab3683bbbf9f94e0eacefcf4ce5b.tar.xz
abrt-ffb9d48d975cab3683bbbf9f94e0eacefcf4ce5b.zip
separate DBus::Glib::BusDispatcher creating from CommLayerServerDBus creation
it's technically wrong to do it that way. It was not biting us because we were creating just one object, but it was also ugly. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'src/Daemon')
-rw-r--r--src/Daemon/CommLayerServerDBus.cpp13
-rw-r--r--src/Daemon/CommLayerServerDBus.h6
-rw-r--r--src/Daemon/Daemon.cpp11
3 files changed, 21 insertions, 9 deletions
diff --git a/src/Daemon/CommLayerServerDBus.cpp b/src/Daemon/CommLayerServerDBus.cpp
index 7fa4fb65..f0a9149b 100644
--- a/src/Daemon/CommLayerServerDBus.cpp
+++ b/src/Daemon/CommLayerServerDBus.cpp
@@ -1,12 +1,18 @@
+#include "abrtlib.h"
#include "CommLayerServerDBus.h"
#include <iostream>
#include "ABRTException.h"
+void attach_dbus_dispatcher_to_glib_main_context()
+{
+ DBus::Glib::BusDispatcher* dispatcher;
+ dispatcher = new DBus::Glib::BusDispatcher();
+ dispatcher->attach(NULL);
+ DBus::default_dispatcher = dispatcher;
+}
+
DBus::Connection *CCommLayerServerDBus::init_dbus(CCommLayerServerDBus *self)
{
- self->m_pDispatcher = new DBus::Glib::BusDispatcher();
- self->m_pDispatcher->attach(NULL);
- DBus::default_dispatcher = self->m_pDispatcher;
self->m_pConn = new DBus::Connection(DBus::Connection::SystemBus());
return self->m_pConn;
}
@@ -31,7 +37,6 @@ CCommLayerServerDBus::CCommLayerServerDBus()
CCommLayerServerDBus::~CCommLayerServerDBus()
{
- delete m_pDispatcher;
}
vector_crash_infos_t CCommLayerServerDBus::GetCrashInfos(const std::string &pSender)
diff --git a/src/Daemon/CommLayerServerDBus.h b/src/Daemon/CommLayerServerDBus.h
index fe95d5ca..ad245061 100644
--- a/src/Daemon/CommLayerServerDBus.h
+++ b/src/Daemon/CommLayerServerDBus.h
@@ -13,7 +13,6 @@ class CCommLayerServerDBus
{
private:
DBus::Connection *m_pConn;
- DBus::Glib::BusDispatcher *m_pDispatcher;
static DBus::Connection *init_dbus(CCommLayerServerDBus *self);
public:
CCommLayerServerDBus();
@@ -44,3 +43,8 @@ class CCommLayerServerDBus
virtual void Warning(const std::string& pDest, const std::string& pMessage);
};
+/*
+ * This must be done before instances of CCommLayerServerDBus are created
+ * (otherwise "new DBus::Connection(DBus::Connection::SystemBus())" fails)
+ */
+void attach_dbus_dispatcher_to_glib_main_context();
diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp
index 47a963cf..81484d16 100644
--- a/src/Daemon/Daemon.cpp
+++ b/src/Daemon/Daemon.cpp
@@ -522,7 +522,6 @@ static gboolean handle_event_cb(GIOChannel *gio, GIOCondition condition, gpointe
int main(int argc, char** argv)
{
- GIOChannel* pGio;
int daemonize = 0;
signal(SIGTERM, handle_fatal_signal);
@@ -565,6 +564,7 @@ int main(int argc, char** argv)
xdup(0);
}
+ GIOChannel* pGio = NULL;
CCrashWatcher watcher;
/* Initialization */
@@ -592,6 +592,7 @@ int main(int argc, char** argv)
FindNewDumps(DEBUG_DUMPS_DIR);
/* (comment here) */
#ifdef ENABLE_DBUS
+ attach_dbus_dispatcher_to_glib_main_context();
g_pCommLayer = new CCommLayerServerDBus();
#elif ENABLE_SOCKET
g_pCommLayer = new CCommLayerServerSocket();
@@ -616,9 +617,11 @@ int main(int argc, char** argv)
catch (...)
{
/* Initialization error. Clean up, in reverse order */
+ error_msg("error while initializing daemon");
unlink(VAR_RUN_PIDFILE);
unlink(VAR_RUN_LOCK_FILE);
- g_io_channel_unref(pGio);
+ if (pGio)
+ g_io_channel_unref(pGio);
delete g_pCommLayer;
/* This restores /proc/sys/kernel/core_pattern, among other things: */
g_pPluginManager->UnLoadPlugins();
@@ -631,8 +634,8 @@ int main(int argc, char** argv)
}
/* Inform parent that initialization failed */
if (daemonize)
- kill(getppid(), SIGINT);
- error_msg_and_die("error while initializing daemon, exiting");
+ kill(getppid(), SIGINT);
+ error_msg_and_die("exiting");
}
/* Inform parent that we initialized ok */