summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 */