HaikuDepot: Fixed potential dead-lock in package list refresh.

When the package list was refreshed while package info was still being
pulled from the web app, calling Model::Clear() with the model lock already
held could lead to a dead-lock: The package populator could block on the
model lock to update information, while StopPopulatingAllPackages() waited
for the thread to exit, but held the lock that the thread was blocking on.
So call StopPopulatingAllPackages() before grabbing the lock and calling
Clear() in MainWindow::_RefreshPackageList().
This commit is contained in:
Stephan Aßmus 2014-10-26 00:02:57 +02:00
parent 9c71c67140
commit 6b147523f1
2 changed files with 2 additions and 2 deletions

View File

@ -421,7 +421,6 @@ Model::AddDepot(const DepotInfo& depot)
void
Model::Clear()
{
StopPopulatingAllPackages();
fDepots.Clear();
}

View File

@ -743,8 +743,9 @@ MainWindow::_RefreshPackageList()
systemFlaggedPackages.Add(repoPackageInfo.FileName());
}
BAutolock lock(fModel.Lock());
fModel.StopPopulatingAllPackages();
BAutolock lock(fModel.Lock());
fModel.Clear();
// filter remote packages from the found list