From ffb9d48d975cab3683bbbf9f94e0eacefcf4ce5b Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 24 Aug 2009 18:08:21 +0200 Subject: 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 --- src/Daemon/Daemon.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/Daemon/Daemon.cpp') 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 */ -- cgit