From 1bf07a3f042155b7bcda460d95e0ff3667ad8389 Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Wed, 7 Feb 2018 22:56:50 +0100 Subject: [PATCH] Fix possible deadlock (fixes issue #3158) Signed-off-by: Sven Strickroth --- src/Changelog.txt | 1 + src/Git/GitStatusListCtrl.h | 1 + src/TortoiseProc/CommitDlg.cpp | 7 ++++++- src/TortoiseProc/LogDlg.cpp | 9 +++++++-- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Changelog.txt b/src/Changelog.txt index c047ae9b1..72c7ba7d7 100644 --- a/src/Changelog.txt +++ b/src/Changelog.txt @@ -50,6 +50,7 @@ Released: unreleased * Fixed issue #3139: Git SSH operations do not work after git update to version 2.16.0 if ssh URL contains a port * Fixed issue #3143: Remember last selection of "Show nested refs" when browsing references * Fixed issue #3152: TortoiseGitMerge: Single pane view as default + * Fixed issue #3158: TortoiseGitProc.exe hangs with 100% CPU when displaying commit window == Known issues == * Issue #3087: Due to changes in Win 10 TortoiseGit(Merge) might start up slowly or gets slower over time. diff --git a/src/Git/GitStatusListCtrl.h b/src/Git/GitStatusListCtrl.h index 05bce9431..10a024cd0 100644 --- a/src/Git/GitStatusListCtrl.h +++ b/src/Git/GitStatusListCtrl.h @@ -618,6 +618,7 @@ public: LONG GetSubmoduleCount() { return m_nShownSubmodules; } CAutoReadLock AcquireReadLock() { return CAutoReadLock(m_guard); } + CAutoReadWeakLock AcquireReadWeakLock(DWORD timeout) { return CAutoReadWeakLock(m_guard, timeout); } LONG m_nTargetCount; ///< number of targets in the file passed to GetStatus() diff --git a/src/TortoiseProc/CommitDlg.cpp b/src/TortoiseProc/CommitDlg.cpp index 68808e564..832448a2f 100644 --- a/src/TortoiseProc/CommitDlg.cpp +++ b/src/TortoiseProc/CommitDlg.cpp @@ -2292,7 +2292,12 @@ void CCommitDlg::FillPatchView(bool onlySetTimer) return; } - auto locker(m_ListCtrl.AcquireReadLock()); + auto locker(m_ListCtrl.AcquireReadWeakLock(50)); + if (!locker.IsAcquired()) + { + SetTimer(FILLPATCHVTIMER, 100, nullptr); + return; + } POSITION pos=m_ListCtrl.GetFirstSelectedItemPosition(); CString cmd,out; diff --git a/src/TortoiseProc/LogDlg.cpp b/src/TortoiseProc/LogDlg.cpp index 8f2666c52..01ae1c049 100644 --- a/src/TortoiseProc/LogDlg.cpp +++ b/src/TortoiseProc/LogDlg.cpp @@ -1,7 +1,7 @@ // TortoiseGit - a Windows shell extension for easy version control // Copyright (C) 2003-2009, 2015 - TortoiseSVN -// Copyright (C) 2008-2017 - TortoiseGit +// Copyright (C) 2008-2018 - TortoiseGit // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -1034,7 +1034,12 @@ void CLogDlg::FillPatchView(bool onlySetTimer) return; } - auto locker(m_ChangedFileListCtrl.AcquireReadLock()); + auto locker(m_ChangedFileListCtrl.AcquireReadWeakLock(50)); + if (!locker.IsAcquired()) + { + SetTimer(LOG_FILLPATCHVTIMER, 100, nullptr); + return; + } POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition(); CString out; -- 2.11.4.GIT