Fix data race in accessing QDBusConnectionPrivate::serviceNames
The trick of creating a copy is not thread-safe. I'd known this since the moment I wrote that code, but thought "what could go wrong?". Task-number: QTBUG-39285 Change-Id: If521d4a649c06e6a34926687e85623aa25cb4c35 Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
parent
66bd87e5c6
commit
acd0dae3f4
@ -256,7 +256,7 @@ private:
|
|||||||
void deliverCall(QObject *object, int flags, const QDBusMessage &msg,
|
void deliverCall(QObject *object, int flags, const QDBusMessage &msg,
|
||||||
const QVector<int> &metaTypes, int slotIdx);
|
const QVector<int> &metaTypes, int slotIdx);
|
||||||
|
|
||||||
bool isServiceRegisteredByThread(const QString &serviceName) const;
|
bool isServiceRegisteredByThread(const QString &serviceName);
|
||||||
|
|
||||||
QString getNameOwnerNoCache(const QString &service);
|
QString getNameOwnerNoCache(const QString &service);
|
||||||
|
|
||||||
|
@ -2488,12 +2488,15 @@ void QDBusConnectionPrivate::unregisterServiceNoLock(const QString &serviceName)
|
|||||||
serviceNames.removeAll(serviceName);
|
serviceNames.removeAll(serviceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QDBusConnectionPrivate::isServiceRegisteredByThread(const QString &serviceName) const
|
bool QDBusConnectionPrivate::isServiceRegisteredByThread(const QString &serviceName)
|
||||||
{
|
{
|
||||||
if (!serviceName.isEmpty() && serviceName == baseService)
|
if (!serviceName.isEmpty() && serviceName == baseService)
|
||||||
return true;
|
return true;
|
||||||
QStringList copy = serviceNames;
|
if (serviceName == dbusServiceString())
|
||||||
return copy.contains(serviceName);
|
return false;
|
||||||
|
|
||||||
|
QDBusReadLocker locker(UnregisterServiceAction, this);
|
||||||
|
return serviceNames.contains(serviceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QDBusConnectionPrivate::postEventToThread(int action, QObject *object, QEvent *ev)
|
void QDBusConnectionPrivate::postEventToThread(int action, QObject *object, QEvent *ev)
|
||||||
|
Loading…
Reference in New Issue
Block a user