From 25fc31b21eae2ae117180b72363f240d51008bee Mon Sep 17 00:00:00 2001 From: Keuin Date: Mon, 12 Sep 2022 03:39:49 +0800 Subject: Bugfix: occasionally the program won't start because of a racing condition. --- main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index bf3b10a..d6a433e 100644 --- a/main.go +++ b/main.go @@ -144,7 +144,7 @@ func main() { tasks[i] = recording.NewRunningTask( taskConfigs[i], ctxTasks, - func() { wg.Add(1) }, + func() {}, func() { wg.Done() }, logging.NewWrappedLogger(logger, fmt.Sprintf("room %v", task.RoomId)), ) @@ -155,9 +155,11 @@ func main() { logger.Printf("Starting tasks...") for i := range tasks { + wg.Add(1) err := tasks[i].StartTask() if err != nil { logger.Printf("Cannot start task %v (room %v): %v. Skip.", i, tasks[i].RoomId, err) + wg.Done() } } -- cgit v1.2.3