Fix deadlock on error.
authorTom Clegg <tom@tomclegg.ca>
Wed, 2 Dec 2020 20:47:48 +0000 (15:47 -0500)
committerTom Clegg <tom@tomclegg.ca>
Wed, 2 Dec 2020 20:50:19 +0000 (15:50 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@tomclegg.ca>

import.go

index f4e0cd0008c218cf23553e12be9d174031e06d2c..f9d3a1a0bafb95cdcd1932c1ceeb2ce9a6c952aa 100644 (file)
--- a/import.go
+++ b/import.go
@@ -452,6 +452,13 @@ func (cmd *importer) tileInputs(tilelib *tileLibrary, infiles []string) error {
                }()
        }
        tileJobs.Wait()
+       if len(errs) > 0 {
+               // Must not wait on encodeJobs in this case. If the
+               // tileJobs goroutines exited early, some funcs in
+               // todo haven't been called, so the corresponding
+               // encodeJobs will wait forever.
+               return <-errs
+       }
        encodeJobs.Wait()
 
        go close(errs)