From 6b147523f1cdb026f13752be0ad300c8a845bf7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sun, 26 Oct 2014 00:02:57 +0200 Subject: [PATCH] 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(). --- src/apps/haikudepot/model/Model.cpp | 1 - src/apps/haikudepot/ui/MainWindow.cpp | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/apps/haikudepot/model/Model.cpp b/src/apps/haikudepot/model/Model.cpp index d07515438d..dc75960b93 100644 --- a/src/apps/haikudepot/model/Model.cpp +++ b/src/apps/haikudepot/model/Model.cpp @@ -421,7 +421,6 @@ Model::AddDepot(const DepotInfo& depot) void Model::Clear() { - StopPopulatingAllPackages(); fDepots.Clear(); } diff --git a/src/apps/haikudepot/ui/MainWindow.cpp b/src/apps/haikudepot/ui/MainWindow.cpp index 71a33f5950..e0fb6ffe52 100644 --- a/src/apps/haikudepot/ui/MainWindow.cpp +++ b/src/apps/haikudepot/ui/MainWindow.cpp @@ -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