diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2021-12-08 14:42:21 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2021-12-08 19:23:43 +0900 |
commit | a5488007501c78afcbfaff5bb6e48fec85afebe8 (patch) | |
tree | faf8146bfeabeab5a6301317c65203f3387a1c38 | |
parent | fb8b28ec7dc78e2b8c6fc3e3c3e5f3d7a1984b06 (diff) | |
download | dbus-1-tqt-a5488007501c78afcbfaff5bb6e48fec85afebe8.tar.gz dbus-1-tqt-a5488007501c78afcbfaff5bb6e48fec85afebe8.zip |
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 96f7e609085b019989a3f7a613fbd05f629793bd)
-rw-r--r-- | tqdbusconnection.cpp | 5 | ||||
-rw-r--r-- | tqdbusconnection_p.h | 1 | ||||
-rw-r--r-- | tqdbusintegrator.cpp | 33 |
3 files changed, 31 insertions, 8 deletions
diff --git a/tqdbusconnection.cpp b/tqdbusconnection.cpp index 0360456..7ad47a6 100644 --- a/tqdbusconnection.cpp +++ b/tqdbusconnection.cpp @@ -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" diff --git a/tqdbusconnection_p.h b/tqdbusconnection_p.h index 6e4efd1..a27705a 100644 --- a/tqdbusconnection_p.h +++ b/tqdbusconnection_p.h @@ -85,6 +85,7 @@ public: bool handleSignal(DBusMessage *msg); bool handleObjectCall(DBusMessage *message); bool handleError(); + bool handleUnreadMessages(); void emitPendingCallReply(const TQT_DBusMessage& message); diff --git a/tqdbusintegrator.cpp b/tqdbusintegrator.cpp index c7129bd..5e50dd7 100644 --- a/tqdbusintegrator.cpp +++ b/tqdbusintegrator.cpp @@ -82,9 +82,9 @@ static void qDBusRemoveTimeout(DBusTimeout *timeout, void *data) TQT_DBusConnectionPrivate *d = static_cast<TQT_DBusConnectionPrivate *>(data); for (TQValueList<DBusTimeout*>::iterator it = d->pendingTimeouts.begin(); it != d->pendingTimeouts.end();) { - if ((*it) == timeout) { - it = d->pendingTimeouts.erase(it); - } + if ((*it) == timeout) { + it = d->pendingTimeouts.erase(it); + } else ++it; } @@ -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()) { |