Skip to content

Commit

Permalink
fix: guard less, otherwise Close cannot quit.
Browse files Browse the repository at this point in the history
because the `closing` channel handling in `scrape` also wants the mutex lock.
  • Loading branch information
flisky committed Jul 11, 2018
1 parent 84c6efc commit 219027b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions services/scraper/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,14 @@ func (s *Service) Open() error {
// Close stops the scraper service
func (s *Service) Close() error {
s.mu.Lock()
defer s.mu.Unlock()

if !s.open {
if s.open {
s.open = false
s.mu.Unlock()
} else {
s.mu.Unlock()
return nil
}

s.open = false
close(s.closing)

s.wg.Wait()
Expand Down

0 comments on commit 219027b

Please sign in to comment.