Skip to content

Commit

Permalink
openTSDB Open should complete before Close runs
Browse files Browse the repository at this point in the history
  • Loading branch information
otoolep committed Oct 14, 2015
1 parent 7f5b486 commit 48ef04c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion services/opentsdb/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type Service struct {
ln net.Listener // main listener
httpln *chanListener // http channel-based listener

mu sync.Mutex
wg sync.WaitGroup
done chan struct{}
err chan error
Expand Down Expand Up @@ -104,6 +105,9 @@ func NewService(c Config) (*Service, error) {

// Open starts the service
func (s *Service) Open() error {
s.mu.Lock()
defer s.mu.Unlock()

s.Logger.Println("Starting OpenTSDB service")

// Configure expvar monitoring. It's OK to do this even if the service fails to open and
Expand Down Expand Up @@ -164,8 +168,11 @@ func (s *Service) Open() error {
return nil
}

// Close closes the underlying listener.
// Close closes the openTSDB service
func (s *Service) Close() error {
s.mu.Lock()
defer s.mu.Unlock()

if s.ln != nil {
return s.ln.Close()
}
Expand Down

0 comments on commit 48ef04c

Please sign in to comment.