tasks: fix race conditions

* show resources in task details
* fix task state locking
* return task object consistently

Race condition iexisted where task State, err, and processReturnValue fields
were written by consumer goroutine and read by concurrent accessors without
proper synchronization, causing torn reads and data races.
This commit is contained in:
André Roth
2026-05-25 15:39:48 +00:00
parent ab7e5710ee
commit 2a99fdfcf1
2 changed files with 41 additions and 27 deletions
+3 -2
View File
@@ -42,6 +42,7 @@ const (
)
// Task represents as task in a queue encapsulates process code
// All fields are protected by List.Mutex - access task fields only while holding list.Lock()
type Task struct {
output *Output
detail *Detail
@@ -51,7 +52,7 @@ type Task struct {
Name string
ID int
State State
resources []string
Resources []string
wgTask *sync.WaitGroup
}
@@ -64,7 +65,7 @@ func NewTask(process Process, name string, ID int, resources []string, wgTask *s
Name: name,
ID: ID,
State: IDLE,
resources: resources,
Resources: resources,
wgTask: wgTask,
}
return task