Commit 4bdf134c authored by Simeon Bird's avatar Simeon Bird

Fix race condition and deadlock in the version plugin

when listing directories is slow.

BUG: 302264
FIXED-IN: 4.9.3
parent 04c8abf5
......@@ -45,10 +45,12 @@ UpdateItemStatesThread::~UpdateItemStatesThread()
void UpdateItemStatesThread::setData(KVersionControlPlugin* plugin,
const QList<VersionControlObserver::ItemState>& itemStates)
{
// The locks are taken in the same order as in run()
// to avoid potential deadlock.
QMutexLocker pluginLocker(m_globalPluginMutex);
QMutexLocker itemLocker(&m_itemMutex);
m_itemStates = itemStates;
QMutexLocker pluginLocker(m_globalPluginMutex);
m_itemStates = itemStates;
m_plugin = plugin;
}
......@@ -58,11 +60,12 @@ void UpdateItemStatesThread::run()
Q_ASSERT(m_plugin);
QMutexLocker itemLocker(&m_itemMutex);
const QString directory = m_itemStates.first().item.url().directory(KUrl::AppendTrailingSlash);
m_retrievedItems = false;
itemLocker.unlock();
QMutexLocker pluginLocker(m_globalPluginMutex);
m_retrievedItems = false;
if (m_plugin->beginRetrieval(directory)) {
itemLocker.relock();
const int count = m_itemStates.count();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment