From d6c32fa88ee7834377e8b23933aa2203eb047ce4 Mon Sep 17 00:00:00 2001 From: Antonio Murdaca Date: Fri, 16 Feb 2018 12:52:25 +0100 Subject: [PATCH] server|cmd: refactor monitors chan Signed-off-by: Antonio Murdaca --- cmd/crio/main.go | 8 ++++---- server/server.go | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/cmd/crio/main.go b/cmd/crio/main.go index a058f296..2ffbd9f2 100644 --- a/cmd/crio/main.go +++ b/cmd/crio/main.go @@ -167,7 +167,7 @@ func catchShutdown(gserver *grpc.Server, sserver *server.Server, hserver *http.S gserver.GracefulStop() hserver.Shutdown(context.Background()) sserver.StopStreamServer() - sserver.StopExitMonitor() + sserver.StopMonitors() if err := sserver.Shutdown(); err != nil { logrus.Warnf("error shutting down main service %v", err) } @@ -515,10 +515,10 @@ func main() { }() streamServerCloseCh := service.StreamingServerCloseChan() - serverExitMonitorCh := service.ExitMonitorCloseChan() + serverMonitorsCh := service.MonitorsCloseChan() select { case <-streamServerCloseCh: - case <-serverExitMonitorCh: + case <-serverMonitorsCh: case <-serverCloseCh: } @@ -526,7 +526,7 @@ func main() { <-streamServerCloseCh logrus.Debug("closed stream server") - <-serverExitMonitorCh + <-serverMonitorsCh logrus.Debug("closed exit monitor") <-serverCloseCh logrus.Debug("closed main server") diff --git a/server/server.go b/server/server.go index b42496c7..9d650266 100644 --- a/server/server.go +++ b/server/server.go @@ -66,9 +66,9 @@ type Server struct { appArmorEnabled bool appArmorProfile string - bindAddress string - stream streamService - exitMonitorChan chan struct{} + bindAddress string + stream streamService + monitorsChan chan struct{} } // StopStreamServer stops the stream server @@ -211,7 +211,7 @@ func New(config *Config) (*Server, error) { seccompEnabled: seccomp.IsEnabled(), appArmorEnabled: apparmor.IsEnabled(), appArmorProfile: config.ApparmorProfile, - exitMonitorChan: make(chan struct{}), + monitorsChan: make(chan struct{}), } if s.seccompEnabled { @@ -355,14 +355,14 @@ func (s *Server) CreateMetricsEndpoint() (*http.ServeMux, error) { return mux, nil } -// StopExitMonitor stops the exit monitor -func (s *Server) StopExitMonitor() { - close(s.exitMonitorChan) +// StopMonitors stops al the monitors +func (s *Server) StopMonitors() { + close(s.monitorsChan) } -// ExitMonitorCloseChan returns the close chan for the exit monitor -func (s *Server) ExitMonitorCloseChan() chan struct{} { - return s.exitMonitorChan +// MonitorsCloseChan returns the close chan for the exit monitor +func (s *Server) MonitorsCloseChan() chan struct{} { + return s.monitorsChan } // StartExitMonitor start a routine that monitors container exits @@ -410,7 +410,7 @@ func (s *Server) StartExitMonitor() { logrus.Debugf("watch error: %v", err) close(done) return - case <-s.exitMonitorChan: + case <-s.monitorsChan: logrus.Debug("closing exit monitor...") close(done) return