Merge pull request #7165 from zouyee/nit
prevent Server reuse after a Shutdown
This commit is contained in:
commit
b3b79813f3
@ -287,24 +287,10 @@ func (c *criService) Run() error {
|
|||||||
eventMonitorErr = err
|
eventMonitorErr = err
|
||||||
}
|
}
|
||||||
logrus.Info("Event monitor stopped")
|
logrus.Info("Event monitor stopped")
|
||||||
// There is a race condition with http.Server.Serve.
|
if err := <-streamServerErrCh; err != nil {
|
||||||
// When `Close` is called at the same time with `Serve`, `Close`
|
streamServerErr = err
|
||||||
// may finish first, and `Serve` may still block.
|
|
||||||
// See https://github.com/golang/go/issues/20239.
|
|
||||||
// Here we set a 2 second timeout for the stream server wait,
|
|
||||||
// if it timeout, an error log is generated.
|
|
||||||
// TODO(random-liu): Get rid of this after https://github.com/golang/go/issues/20239
|
|
||||||
// is fixed.
|
|
||||||
const streamServerStopTimeout = 2 * time.Second
|
|
||||||
select {
|
|
||||||
case err := <-streamServerErrCh:
|
|
||||||
if err != nil {
|
|
||||||
streamServerErr = err
|
|
||||||
}
|
|
||||||
logrus.Info("Stream server stopped")
|
|
||||||
case <-time.After(streamServerStopTimeout):
|
|
||||||
logrus.Errorf("Stream server is not stopped in %q", streamServerStopTimeout)
|
|
||||||
}
|
}
|
||||||
|
logrus.Info("Stream server stopped")
|
||||||
if eventMonitorErr != nil {
|
if eventMonitorErr != nil {
|
||||||
return fmt.Errorf("event monitor error: %w", eventMonitorErr)
|
return fmt.Errorf("event monitor error: %w", eventMonitorErr)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user