diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2022-01-29 11:22:35 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-03-17 19:13:40 +1100 |
commit | 1a74ed32143f826104e1d60f4392d2d8ba53cd80 (patch) | |
tree | ef37da1cef7121ab945407fe2aa0ee135e19942c /pkg | |
parent | cb0d3a480afc0a886e01b3fc12d09a84226fc014 (diff) |
avoid deadlock
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/gui/controllers/remotes_controller.go | 8 | ||||
-rw-r--r-- | pkg/gui/gui.go | 7 | ||||
-rw-r--r-- | pkg/gui/recent_repos_panel.go | 6 |
3 files changed, 6 insertions, 15 deletions
diff --git a/pkg/gui/controllers/remotes_controller.go b/pkg/gui/controllers/remotes_controller.go index 262217a11..c14f3e5ba 100644 --- a/pkg/gui/controllers/remotes_controller.go +++ b/pkg/gui/controllers/remotes_controller.go @@ -1,8 +1,6 @@ package controllers import ( - "sync" - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands" "github.com/jesseduffield/lazygit/pkg/commands/models" @@ -21,7 +19,6 @@ type RemotesController struct { getSelectedRemote func() *models.Remote setRemoteBranches func([]*models.RemoteBranch) getContexts func() context.ContextTree - fetchMutex *sync.Mutex } var _ types.IController = &RemotesController{} @@ -33,7 +30,6 @@ func NewRemotesController( getContexts func() context.ContextTree, getSelectedRemote func() *models.Remote, setRemoteBranches func([]*models.RemoteBranch), - fetchMutex *sync.Mutex, ) *RemotesController { return &RemotesController{ c: c, @@ -42,7 +38,6 @@ func NewRemotesController( getContext: getContext, getSelectedRemote: getSelectedRemote, setRemoteBranches: setRemoteBranches, - fetchMutex: fetchMutex, } } @@ -176,9 +171,6 @@ func (self *RemotesController) edit(remote *models.Remote) error { func (self *RemotesController) fetch(remote *models.Remote) error { return self.c.WithWaitingStatus(self.c.Tr.FetchingRemoteStatus, func() error { - self.fetchMutex.Lock() - defer self.fetchMutex.Unlock() - err := self.git.Sync.FetchRemote(remote.Name) if err != nil { _ = self.c.Error(err) diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 6f1042b80..fa2b3e256 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -397,7 +397,7 @@ type Modes struct { type guiMutexes struct { RefreshingFilesMutex *sync.Mutex RefreshingStatusMutex *sync.Mutex - FetchMutex *sync.Mutex + SyncMutex *sync.Mutex BranchCommitsMutex *sync.Mutex LineByLinePanelMutex *sync.Mutex SubprocessMutex *sync.Mutex @@ -514,7 +514,7 @@ func NewGui( Mutexes: guiMutexes{ RefreshingFilesMutex: &sync.Mutex{}, RefreshingStatusMutex: &sync.Mutex{}, - FetchMutex: &sync.Mutex{}, + SyncMutex: &sync.Mutex{}, BranchCommitsMutex: &sync.Mutex{}, LineByLinePanelMutex: &sync.Mutex{}, SubprocessMutex: &sync.Mutex{}, @@ -537,7 +537,7 @@ func NewGui( cmn, osCommand, gitConfig, - gui.Mutexes.FetchMutex, + gui.Mutexes.SyncMutex, ) if err != nil { return nil, err @@ -666,7 +666,6 @@ func (gui *Gui) setControllers() { getContexts, gui.getSelectedRemote, func(branches []*models.RemoteBranch) { gui.State.RemoteBranches = branches }, - gui.Mutexes.FetchMutex, ), Menu: controllers.NewMenuController( controllerCommon, diff --git a/pkg/gui/recent_repos_panel.go b/pkg/gui/recent_repos_panel.go index 428faa9c9..337be3600 100644 --- a/pkg/gui/recent_repos_panel.go +++ b/pkg/gui/recent_repos_panel.go @@ -75,7 +75,7 @@ func (gui *Gui) dispatchSwitchToRepo(path string, reuse bool) error { gui.Common, gui.OSCommand, git_config.NewStdCachedGitConfig(gui.Log), - gui.Mutexes.FetchMutex, + gui.Mutexes.SyncMutex, ) if err != nil { return err @@ -84,8 +84,8 @@ func (gui *Gui) dispatchSwitchToRepo(path string, reuse bool) error { // these two mutexes are used by our background goroutines (triggered via `gui.goEvery`. We don't want to // switch to a repo while one of these goroutines is in the process of updating something - gui.Mutexes.FetchMutex.Lock() - defer gui.Mutexes.FetchMutex.Unlock() + gui.Mutexes.SyncMutex.Lock() + defer gui.Mutexes.SyncMutex.Unlock() gui.Mutexes.RefreshingFilesMutex.Lock() defer gui.Mutexes.RefreshingFilesMutex.Unlock() |