| 391 | } |
| 392 | |
| 393 | func (s *List) Run(inch chan<- *baker.Data) error { |
| 394 | s.ci.SetOutputChannel(inch) |
| 395 | |
| 396 | for _, f := range s.Cfg.Files { |
| 397 | s.processFileOrList(f) |
| 398 | if ferr := s.fatalErr.Load(); ferr != nil { |
| 399 | // Even if we've got a fatal error, wait for |
| 400 | // completion of compressedStream so that we're sure |
| 401 | // all workers are exited. Otherwise, we might |
| 402 | // cauase race-conditions in callers because |
| 403 | // we haven't actually finished pushing things |
| 404 | // into the output channel. |
| 405 | break |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | // Now wait until we've finished processing all the files |
| 410 | s.ci.NoMoreFiles() |
| 411 | <-s.ci.Done |
| 412 | |
| 413 | log.WithFields(log.Fields{"f": "List.Run"}).Info("terminating") |
| 414 | if ferr := s.fatalErr.Load(); ferr != nil { |
| 415 | return ferr.(error) |
| 416 | } |
| 417 | return nil |
| 418 | } |
| 419 | |
| 420 | func (s *List) FreeMem(data *baker.Data) { |
| 421 | s.ci.FreeMem(data) |