summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Linke <christian.linke@bmw.de>2013-05-07 15:11:21 +0200
committerChristian Linke <christian.linke@bmw.de>2013-06-13 17:10:28 +0200
commit628d8539b3269f3a9d2aa399e7fc7cbdedb5bcc5 (patch)
treee0bfb135cde9e7893094e7491e8df06c191a2967
parent3f6c820340139d3bc293001b17d006957a5f20dd (diff)
downloadaudiomanager-628d8539b3269f3a9d2aa399e7fc7cbdedb5bcc5.tar.gz
* fix for bug [52]: Dbus wrapper sometimes does not deliver all messages
Signed-off-by: Christian Linke <christian.linke@bmw.de>
-rw-r--r--AudioManagerDaemon/src/CAmDbusWrapper.cpp16
-rw-r--r--include/shared/CAmDbusWrapper.h3
2 files changed, 18 insertions, 1 deletions
diff --git a/AudioManagerDaemon/src/CAmDbusWrapper.cpp b/AudioManagerDaemon/src/CAmDbusWrapper.cpp
index 89c6122..e3955c9 100644
--- a/AudioManagerDaemon/src/CAmDbusWrapper.cpp
+++ b/AudioManagerDaemon/src/CAmDbusWrapper.cpp
@@ -52,6 +52,7 @@ CAmDbusWrapper::CAmDbusWrapper(CAmSocketHandler* socketHandler, DBusBusType type
pDbusFireCallback(this, &CAmDbusWrapper::dbusFireCallback), //
pDbusCheckCallback(this, &CAmDbusWrapper::dbusCheckCallback), //
pDbusTimerCallback(this, &CAmDbusWrapper::dbusTimerCallback), //
+ pDbusPrepareCallback(this,&CAmDbusWrapper::dbusPrepareCallback), //
mpDbusConnection(0), //
mDBusError(), //
mListNodes(), //
@@ -241,7 +242,7 @@ dbus_bool_t CAmDbusWrapper::addWatchDelegate(DBusWatch * watch, void* userData)
}
logInfo("DBusWrapper::addWatchDelegate entered new watch, fd=", dbus_watch_get_unix_fd(watch), "event flag=", event);
- am_Error_e error = mpSocketHandler->addFDPoll(dbus_watch_get_unix_fd(watch), event, NULL, &pDbusFireCallback, &pDbusCheckCallback, &pDbusDispatchCallback, watch, handle);
+ am_Error_e error = mpSocketHandler->addFDPoll(dbus_watch_get_unix_fd(watch), event, &pDbusPrepareCallback, &pDbusFireCallback, &pDbusCheckCallback, &pDbusDispatchCallback, watch, handle);
//if everything is alright, add the watch and the handle to our map so we know this relationship
if (error == E_OK && handle != 0)
@@ -423,6 +424,19 @@ void am::CAmDbusWrapper::dbusFireCallback(const pollfd pollfd, const sh_pollHand
//logInfo("DBusWrapper::dbusFireCallback was called");
}
+void CAmDbusWrapper::dbusPrepareCallback(const sh_pollHandle_t handle, void* userData)
+{
+ (void) handle;
+ (void) userData;
+ dbus_connection_ref(mpDbusConnection);
+ while (dbus_connection_get_dispatch_status(mpDbusConnection) == DBUS_DISPATCH_DATA_REMAINS)
+ {
+ dbus_connection_dispatch(mpDbusConnection);
+ logInfo("prepare was neccessary!");
+ }
+ dbus_connection_unref(mpDbusConnection);
+}
+
void CAmDbusWrapper::toggleTimeoutDelegate(DBusTimeout *timeout, void* userData)
{
(void) userData;
diff --git a/include/shared/CAmDbusWrapper.h b/include/shared/CAmDbusWrapper.h
index 603cc00..35b5e77 100644
--- a/include/shared/CAmDbusWrapper.h
+++ b/include/shared/CAmDbusWrapper.h
@@ -53,6 +53,9 @@ public:
static void removeTimeout(DBusTimeout *timeout, void* userData);
static void toggleTimeout(DBusTimeout *timeout, void* userData);
+ void dbusPrepareCallback(const sh_pollHandle_t handle, void* userData);
+ TAmShPollPrepare<CAmDbusWrapper> pDbusPrepareCallback;
+
bool dbusDispatchCallback(const sh_pollHandle_t handle, void* userData);
TAmShPollDispatch<CAmDbusWrapper> pDbusDispatchCallback;