diff options
author | Andreas Hartmetz <ahartmetz@gmail.com> | 2017-11-05 11:16:00 +0100 |
---|---|---|
committer | Andreas Hartmetz <ahartmetz@gmail.com> | 2017-11-08 05:38:39 +0000 |
commit | eeca8895fc7e585f497e908368b8cc1a509847d3 (patch) | |
tree | 6e900fa4259be090ec8a6c486b83d7b34d346293 /src/dbus/qdbusintegrator.cpp | |
parent | bfcad18526dc064ac7dd1a08781c60d1d1673a0b (diff) |
Remove obsolete DBus dispatch lock
In c2049f67e4cfe5f09e1b033b910cb37d043a287e, all DBus I/O was
moved into a service thread. The dispatch lock used to protect
DBus I/O in the threading setup before that commit. It is not
needed anymore.
No discernible difference in QtDBus benchmarks, roughly 500
bytes code size reduction on AMD64. The main point is to reduce
confusion from unnecessary code.
Change-Id: Idcbdd2b7e2b317cf6da0b5bfc5ec70afed1f1b48
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/dbus/qdbusintegrator.cpp')
-rw-r--r-- | src/dbus/qdbusintegrator.cpp | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index c74c63fdc6..03de5b0091 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -150,7 +150,6 @@ static dbus_bool_t qDBusAddTimeout(DBusTimeout *timeout, void *data) if (Q_UNLIKELY(!q_dbus_timeout_get_enabled(timeout))) return false; - QDBusDispatchLocker locker(AddTimeoutAction, d); Q_ASSERT(d->timeouts.key(timeout, 0) == 0); int timerId = d->startTimer(q_dbus_timeout_get_interval(timeout)); @@ -172,8 +171,6 @@ static void qDBusRemoveTimeout(DBusTimeout *timeout, void *data) QDBusConnectionPrivate *d = static_cast<QDBusConnectionPrivate *>(data); Q_ASSERT(QThread::currentThread() == d->thread()); - QDBusDispatchLocker locker(RemoveTimeoutAction, d); - QDBusConnectionPrivate::TimeoutHash::iterator it = d->timeouts.begin(); while (it != d->timeouts.end()) { if (it.value() == timeout) { @@ -210,7 +207,6 @@ static dbus_bool_t qDBusAddWatch(DBusWatch *watch, void *data) QDBusConnectionPrivate::Watcher watcher; - QDBusDispatchLocker locker(AddWatchAction, d); if (flags & DBUS_WATCH_READABLE) { //qDebug("addReadWatch %d", fd); watcher.watch = watch; @@ -241,7 +237,6 @@ static void qDBusRemoveWatch(DBusWatch *watch, void *data) Q_ASSERT(QThread::currentThread() == d->thread()); int fd = q_dbus_watch_get_unix_fd(watch); - QDBusDispatchLocker locker(RemoveWatchAction, d); QDBusConnectionPrivate::WatcherHash::iterator i = d->watchers.find(fd); while (i != d->watchers.end() && i.key() == fd) { if (i.value().watch == watch) { @@ -263,8 +258,6 @@ static void qDBusToggleWatch(DBusWatch *watch, void *data) Q_ASSERT(QThread::currentThread() == d->thread()); int fd = q_dbus_watch_get_unix_fd(watch); - QDBusDispatchLocker locker(ToggleWatchAction, d); - QDBusConnectionPrivate::WatcherHash::iterator i = d->watchers.find(fd); while (i != d->watchers.end() && i.key() == fd) { if (i.value().watch == watch) { @@ -766,7 +759,7 @@ static int findSlot(const QMetaObject *mo, const QByteArray &name, int flags, */ void QDBusConnectionPrivate::setDispatchEnabled(bool enable) { - QDBusDispatchLocker locker(SetDispatchEnabledAction, this); + checkThread(); dispatchEnabled = enable; if (enable) emit dispatchStatusChanged(); @@ -1024,7 +1017,7 @@ extern bool qDBusInitThreads(); QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p) : QObject(p), ref(1), capabilities(0), mode(InvalidMode), busService(0), - dispatchLock(QMutex::Recursive), connection(0), + connection(0), rootNode(QString(QLatin1Char('/'))), anonymousAuthenticationAllowed(false), dispatchEnabled(true) @@ -1176,7 +1169,6 @@ bool QDBusConnectionPrivate::handleError(const QDBusErrorInternal &error) void QDBusConnectionPrivate::timerEvent(QTimerEvent *e) { { - QDBusDispatchLocker locker(TimerEventAction, this); DBusTimeout *timeout = timeouts.value(e->timerId(), 0); if (timeout) q_dbus_timeout_handle(timeout); @@ -1187,7 +1179,6 @@ void QDBusConnectionPrivate::timerEvent(QTimerEvent *e) void QDBusConnectionPrivate::doDispatch() { - QDBusDispatchLocker locker(DoDispatchAction, this); if (mode == ClientMode || mode == PeerMode) { while (q_dbus_connection_dispatch(connection) == DBUS_DISPATCH_DATA_REMAINS) ; if (dispatchEnabled && !pendingMessages.isEmpty()) { @@ -1205,7 +1196,6 @@ void QDBusConnectionPrivate::doDispatch() void QDBusConnectionPrivate::socketRead(int fd) { - QDBusDispatchLocker locker(SocketReadAction, this); WatcherHash::ConstIterator it = watchers.constFind(fd); while (it != watchers.constEnd() && it.key() == fd) { if (it->watch && it->read && it->read->isEnabled()) { @@ -1220,7 +1210,6 @@ void QDBusConnectionPrivate::socketRead(int fd) void QDBusConnectionPrivate::socketWrite(int fd) { - QDBusDispatchLocker locker(SocketWriteAction, this); WatcherHash::ConstIterator it = watchers.constFind(fd); while (it != watchers.constEnd() && it.key() == fd) { if (it->watch && it->write && it->write->isEnabled()) { @@ -1283,10 +1272,7 @@ void QDBusConnectionPrivate::relaySignal(QObject *obj, const QMetaObject *mo, in //qDBusDebug() << "Emitting signal" << message; //qDBusDebug() << "for paths:"; q_dbus_message_set_no_reply(msg, true); // the reply would not be delivered to anything - { - QDBusDispatchLocker locker(HuntAndEmitAction, this); - huntAndEmit(connection, msg, obj, rootNode, isScriptable, isAdaptor); - } + huntAndEmit(connection, msg, obj, rootNode, isScriptable, isAdaptor); q_dbus_message_unref(msg); } @@ -2164,7 +2150,6 @@ void QDBusConnectionPrivate::sendInternal(QDBusPendingCallPrivate *pcall, void * Q_ASSERT(isNoReply == !!q_dbus_message_get_no_reply(msg)); checkThread(); - QDBusDispatchLocker locker(SendMessageAction, this); if (isNoReply && q_dbus_connection_send(connection, msg, nullptr)) { // success |