Make sure to handle pending messages at start up if a dbus service

is invoked by the dbus daemon.
Prior to this fix, when a service was started by the dbus daemon,
the first dbus call sent to it was being held back till the next
dbus call was performed, resulting in a long timeout for the first
unhandled call and a delayed answer.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
(cherry picked from commit 96f7e60908)
r14.0.x
Michele Calgaro 3 years ago
parent fb8b28ec7d
commit a548800750
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -401,8 +401,9 @@ bool TQT_DBusConnection::requestName(const TQString &name, int modeFlags)
dbusFlags |= DBUS_NAME_FLAG_REPLACE_EXISTING;
dbus_bus_request_name(d->connection, name.utf8(), dbusFlags, &d->error);
return !d->handleError();
bool res = !d->handleError();
res &= d->handleUnreadMessages();
return res;
}
#include "tqdbusconnection.moc"

@ -85,6 +85,7 @@ public:
bool handleSignal(DBusMessage *msg);
bool handleObjectCall(DBusMessage *message);
bool handleError();
bool handleUnreadMessages();
void emitPendingCallReply(const TQT_DBusMessage& message);

@ -339,6 +339,29 @@ bool TQT_DBusConnectionPrivate::handleError()
return lastError.isValid();
}
bool TQT_DBusConnectionPrivate::handleUnreadMessages()
{
bool res = true;
WatcherHash::iterator it = watchers.begin();
while (it != watchers.end())
{
WatcherList &list = *it;
WatcherList::iterator listIt = list.begin();
while (listIt != list.end())
{
Watcher watcher = *listIt;
if (watcher.read)
{
socketRead(watcher.read->socket());
res &= (!handleError());
}
++listIt;
}
++it;
}
return res;
}
void TQT_DBusConnectionPrivate::emitPendingCallReply(const TQT_DBusMessage& message)
{
emit dbusPendingCallReply(message);
@ -565,8 +588,6 @@ void TQT_DBusConnectionPrivate::setConnection(DBusConnection *dbc)
qDBusToggleWatch, this, 0);
dbus_connection_set_timeout_functions(connection, qDBusAddTimeout, qDBusRemoveTimeout,
qDBusToggleTimeout, this, 0);
// dbus_bus_add_match(connection, "type='signal',interface='com.trolltech.dbus.Signal'", &error);
// dbus_bus_add_match(connection, "type='signal'", &error);
dbus_bus_add_match(connection, "type='signal'", &error);
if (handleError()) {
@ -579,7 +600,7 @@ void TQT_DBusConnectionPrivate::setConnection(DBusConnection *dbc)
TQCString filter;
filter += "destination='";
filter += service;
filter += "\'";
filter += "'";
dbus_bus_add_match(connection, filter.data(), &error);
if (handleError()) {

Loading…
Cancel
Save