summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-07-08 20:53:41 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-07-09 20:57:18 +1000
commitbf7726d130716fdcdeea316e8d8284bb51412454 (patch)
tree0772b442460ccff765759b47ae48186869a54e53 /pkg
parent6282d55919614ccb99a2221d5dd1065deb4d0b44 (diff)
Fix race condition
We had some test flakiness involving the index.lock file which is fixed by this commit. We shouldn't be accessing newTaskID without the mutex, although I'm surprised that this actually fixes the issue. Surely we don't have tasks (which typically render to the main view) which use index.lock?
Diffstat (limited to 'pkg')
-rw-r--r--pkg/tasks/tasks.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/pkg/tasks/tasks.go b/pkg/tasks/tasks.go
index 58784da5f..8edcbfea2 100644
--- a/pkg/tasks/tasks.go
+++ b/pkg/tasks/tasks.go
@@ -324,10 +324,13 @@ func (self *ViewBufferManager) NewTask(f func(TaskOpts) error, key string) error
self.waitingMutex.Lock()
+ self.taskIDMutex.Lock()
if taskID < self.newTaskID {
self.waitingMutex.Unlock()
+ self.taskIDMutex.Unlock()
return
}
+ self.taskIDMutex.Unlock()
if self.stopCurrentTask != nil {
self.stopCurrentTask()