summaryrefslogtreecommitdiffstats
path: root/src/Daemon
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-01-27 16:26:01 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-01-27 16:26:01 +0100
commite742f63e9c56cc2c913fa8cfda7a9d583a2c2aa2 (patch)
treea08cc57de6544f3521ae7758f3746c6c515dc53f /src/Daemon
parent8448f22c260be4f6e7732a193f330fd6cd94d9b6 (diff)
downloadabrt-e742f63e9c56cc2c913fa8cfda7a9d583a2c2aa2.tar.gz
abrt-e742f63e9c56cc2c913fa8cfda7a9d583a2c2aa2.tar.xz
abrt-e742f63e9c56cc2c913fa8cfda7a9d583a2c2aa2.zip
abrtd: proper fix to autostart problem
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'src/Daemon')
-rw-r--r--src/Daemon/CommLayerServerDBus.cpp11
-rw-r--r--src/Daemon/Daemon.cpp21
2 files changed, 23 insertions, 9 deletions
diff --git a/src/Daemon/CommLayerServerDBus.cpp b/src/Daemon/CommLayerServerDBus.cpp
index f1f10e5..f247158 100644
--- a/src/Daemon/CommLayerServerDBus.cpp
+++ b/src/Daemon/CommLayerServerDBus.cpp
@@ -565,6 +565,17 @@ CCommLayerServerDBus::CCommLayerServerDBus()
//maybe check that r == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER instead?
handle_dbus_err(rc < 0, &err);
VERB3 log("dbus init done");
+
+ /* dbus_bus_request_name can already read some data. For example,
+ * if we were autostarted, the call which caused autostart arrives
+ * at this moment. Thus while dbus fd hasn't any data anymore,
+ * dbus library can buffer a message or two.
+ * If we don't do this, the data won't be processed
+ * until next dbus data arrives.
+ */
+ int cnt = 10;
+ while (dbus_connection_dispatch(conn) != DBUS_DISPATCH_COMPLETE && --cnt)
+ VERB3 log("processed initial buffered dbus message");
}
CCommLayerServerDBus::~CCommLayerServerDBus()
diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp
index 83b1cee..5bcbe23 100644
--- a/src/Daemon/Daemon.cpp
+++ b/src/Daemon/Daemon.cpp
@@ -797,15 +797,6 @@ int main(int argc, char** argv)
if (SetUpCron() != 0)
throw 1;
-#if 1 //def ENABLE_DBUS
- VERB1 log("Initializing dbus");
- g_pCommLayer = new CCommLayerServerDBus();
-#elif ENABLE_SOCKET
- g_pCommLayer = new CCommLayerServerSocket();
-#endif
- if (g_pCommLayer->m_init_error)
- throw 1;
-
VERB1 log("Adding inotify watch to glib main loop");
pGiochannel_inotify = g_io_channel_unix_new(inotify_fd);
g_io_add_watch(pGiochannel_inotify, G_IO_IN, handle_inotify_cb, NULL);
@@ -824,6 +815,18 @@ int main(int argc, char** argv)
if (CreatePidFile() != 0)
throw 1;
pidfile_created = true;
+
+ /* Note: this already may process a few dbus messages,
+ * therefore it should be the last thing to initialize.
+ */
+#if 1 //def ENABLE_DBUS
+ VERB1 log("Initializing dbus");
+ g_pCommLayer = new CCommLayerServerDBus();
+#elif ENABLE_SOCKET
+ g_pCommLayer = new CCommLayerServerSocket();
+#endif
+ if (g_pCommLayer->m_init_error)
+ throw 1;
}
catch (...)
{