commit ca7f9a9ae01a82c04f93c14b4cbd374441713001 Author: David Fifield david@bamsoftware.com Date: Tue Apr 30 12:40:17 2019 -0600
Consolidate wg.Add and wg.Done under the same if block.
Suggested by cohosh in https://bugs.torproject.org/15125#comment:14. --- meek-client-torbrowser/meek-client-torbrowser.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/meek-client-torbrowser/meek-client-torbrowser.go b/meek-client-torbrowser/meek-client-torbrowser.go index eb6ab32..38a9fc3 100644 --- a/meek-client-torbrowser/meek-client-torbrowser.go +++ b/meek-client-torbrowser/meek-client-torbrowser.go @@ -417,12 +417,8 @@ func main() { var wg sync.WaitGroup if firefoxCmd != nil { wg.Add(1) - } - if meekClientCmd != nil { - wg.Add(1) - } - if firefoxCmd != nil { go func() { + defer wg.Done() err := terminateCmd(firefoxCmd) // We terminate Firefox with SIGTERM, so don't log an // error if the exit status is "terminated by SIGTERM." @@ -436,16 +432,16 @@ func main() { if err != nil { log.Printf("error terminating firefox: %v", err) } - wg.Done() }() } if meekClientCmd != nil { + wg.Add(1) go func() { + defer wg.Done() err := terminatePTCmd(meekClientCmd) if err != nil { log.Printf("error terminating meek-client: %v", err) } - wg.Done() }() } wg.Wait()
tor-commits@lists.torproject.org