Skip to content

Commit

Permalink
Shutdown correctly if the extension is short lived (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-cognet committed Nov 30, 2023
1 parent e3cde12 commit 61ac792
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ func (s *ExtensionManagerServer) Start() error {
err := func() error {
s.mutex.Lock()
defer s.mutex.Unlock()
// check after the lock the serverClient is present. It could have gone away on very short restart loops
if s.serverClient == nil {
return errors.New("cannot start, shutdown in progress")
}
registry := s.genRegistry()

stat, err := s.serverClient.RegisterExtension(
Expand Down Expand Up @@ -278,9 +282,7 @@ func (s *ExtensionManagerServer) Run() error {
}()

err := <-errc
if err := s.Shutdown(context.Background()); err != nil {
return err
}
_ = s.Shutdown(context.Background())
return err
}

Expand Down

0 comments on commit 61ac792

Please sign in to comment.