aboutsummaryrefslogtreecommitdiffstats
path: root/syz-ci/jobs.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2023-01-12 12:14:15 +0100
committerAleksandr Nogikh <wp32pw@gmail.com>2023-01-19 11:26:54 +0100
commitc1c804b7d96215f84085920474ef14af2981bdf1 (patch)
tree13c421fb42a8d4ebccacd53d59177739a64aaecd /syz-ci/jobs.go
parent7338ad6e0b83c4ba1607090846e0b663861929a1 (diff)
syz-ci: explicitly stop all running jobs on update
Otherwise we might end up in a situation when we have stopped all fuzzing, but wait for the job processor to report Done to the waitgroup object.
Diffstat (limited to 'syz-ci/jobs.go')
-rw-r--r--syz-ci/jobs.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/syz-ci/jobs.go b/syz-ci/jobs.go
index fcdca9ada..04c241ab2 100644
--- a/syz-ci/jobs.go
+++ b/syz-ci/jobs.go
@@ -58,6 +58,23 @@ func newJobManager(cfg *Config, managers []*Manager, shutdownPending chan struct
}, nil
}
+// startLoop starts a job loop in parallel and returns a blocking function
+// to gracefully stop job processing.
+func (jm *JobManager) startLoop(wg *sync.WaitGroup) func() {
+ stop := make(chan struct{})
+ done := make(chan struct{}, 1)
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ jm.loop(stop)
+ done <- struct{}{}
+ }()
+ return func() {
+ stop <- struct{}{}
+ <-done
+ }
+}
+
func (jm *JobManager) loop(stop chan struct{}) {
if err := jm.resetJobs(); err != nil {
if jm.dash != nil {