Merge pull request #5326 from jwhonce/issues/5311

Remove 1 sec delay
This commit is contained in:
OpenShift Merge Robot
2020-02-25 21:32:28 +01:00
committed by GitHub
2 changed files with 22 additions and 28 deletions

View File

@ -143,7 +143,6 @@ func runREST(r *libpod.Runtime, uri string, timeout time.Duration) error {
if err != nil {
return errors.Wrapf(err, "unable to create socket %s", uri)
}
defer l.Close()
listener = &l
}
server, err := api.NewServerWithSettings(r, timeout, listener)

View File

@ -140,16 +140,14 @@ func newServer(runtime *libpod.Runtime, duration time.Duration, listener *net.Li
func (s *APIServer) Serve() error {
// stalker to count the connections. Should the timer expire it will shutdown the service.
go func() {
for {
select {
case delta := <-s.ConnectionCh:
// Always stop the current timer, things will change...
s.Timer.Stop()
for delta := range s.ConnectionCh {
switch delta {
case EnterHandler:
s.Timer.Stop()
s.ActiveConnections += 1
s.TotalConnections += 1
case ExitHandler:
s.Timer.Stop()
s.ActiveConnections -= 1
if s.ActiveConnections == 0 {
// Server will be shutdown iff the timer expires before being reset or stopped
@ -168,9 +166,6 @@ func (s *APIServer) Serve() error {
default:
logrus.Errorf("ConnectionCh received unsupported input %d", delta)
}
default:
time.Sleep(1 * time.Second)
}
}
}()
@ -212,7 +207,7 @@ func (s *APIServer) Shutdown() error {
go func() {
err := s.Server.Shutdown(ctx)
if err != nil && err != context.Canceled {
if err != nil && err != context.Canceled && err != http.ErrServerClosed {
logrus.Errorf("Failed to cleanly shutdown APIServer: %s", err.Error())
}
}()