From 98a48734278178e07468c4a87e8ff4ce6aa0d326 Mon Sep 17 00:00:00 2001 From: Marvin Blum Date: Sat, 4 Feb 2017 23:34:01 +0100 Subject: [PATCH] Fixed deadlock. --- CHANGELOG.md | 4 ++++ src/main/asl.go | 24 ++++++------------------ 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e6542a..e0c4a42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +**1.2.2** + +* bugfix: deadlock on compiling multile files at once + **1.2.1** * bugfix: new line after while for pretty printing diff --git a/src/main/asl.go b/src/main/asl.go index de48106..1a54d68 100644 --- a/src/main/asl.go +++ b/src/main/asl.go @@ -12,7 +12,7 @@ import ( ) const ( - version = "1.2.1" + version = "1.2.2" extension = ".asl" sqfextension = ".sqf" typeinfo = "types" @@ -104,17 +104,15 @@ func readAslFiles(path string) { } // Recovers and prints thrown error. -func recoverCompileError(file string, waiter chan bool) { +func recoverCompileError(file string) { if r := recover(); r != nil { fmt.Println("Compile error in file "+file+":", r) } - - waiter <- true // the show must go on } // Compiles a single ASL file. -func compileFile(path string, file ASLFile, waiter chan bool) { - defer recoverCompileError(file.in, waiter) +func compileFile(path string, file ASLFile) { + defer recoverCompileError(file.in) // read file out := filepath.FromSlash(path + PathSeparator + file.out + PathSeparator + file.newname + sqfextension) @@ -138,22 +136,12 @@ func compileFile(path string, file ASLFile, waiter chan bool) { fmt.Println("Error writing file: " + file.out) fmt.Println(err) } - - waiter <- true // done } -// Compiles ASL files concurrently. +// Compiles ASL files. func compile(path string) { - waiter := make(chan bool, len(aslFiles)) - - // fire compile for i := 0; i < len(aslFiles); i++ { - go compileFile(path, aslFiles[i], waiter) - } - - // wait until all files are compiled - for i := 0; i < len(aslFiles); i++ { - <-waiter + compileFile(path, aslFiles[i]) } }