Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit d73611c

Browse files
Merge component 'engine' from [email protected]:docker/engine master
2 parents 280612b + 4e23ee6 commit d73611c

File tree

3 files changed

+9
-44
lines changed

3 files changed

+9
-44
lines changed

components/engine/api/server/router_swapper.go

-30
This file was deleted.

components/engine/api/server/server.go

+5-11
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,10 @@ type Config struct {
3232

3333
// Server contains instance details for the server
3434
type Server struct {
35-
cfg *Config
36-
servers []*HTTPServer
37-
routers []router.Router
38-
routerSwapper *routerSwapper
39-
middlewares []middleware.Middleware
35+
cfg *Config
36+
servers []*HTTPServer
37+
routers []router.Router
38+
middlewares []middleware.Middleware
4039
}
4140

4241
// New returns a new instance of the server based on the specified configuration.
@@ -80,7 +79,7 @@ func (s *Server) Close() {
8079
func (s *Server) serveAPI() error {
8180
var chErrors = make(chan error, len(s.servers))
8281
for _, srv := range s.servers {
83-
srv.srv.Handler = s.routerSwapper
82+
srv.srv.Handler = s.createMux()
8483
go func(srv *HTTPServer) {
8584
var err error
8685
logrus.Infof("API listen on %s", srv.l.Addr())
@@ -153,11 +152,6 @@ func (s *Server) makeHTTPHandler(handler httputils.APIFunc) http.HandlerFunc {
153152
// This method also enables the Go profiler.
154153
func (s *Server) InitRouter(routers ...router.Router) {
155154
s.routers = append(s.routers, routers...)
156-
157-
m := s.createMux()
158-
s.routerSwapper = &routerSwapper{
159-
router: m,
160-
}
161155
}
162156

163157
type pageNotFoundError struct{}

components/engine/daemon/monitor.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei
5454
if err != nil {
5555
logrus.WithError(err).Warnf("failed to delete container %s from containerd", c.ID)
5656
}
57-
ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
58-
57+
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
5958
c.StreamConfig.Wait(ctx)
59+
cancel()
6060
c.Reset(false)
6161

6262
exitStatus := container.ExitStatus{
@@ -125,8 +125,9 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei
125125
execConfig.ExitCode = &ec
126126
execConfig.Running = false
127127

128-
ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
128+
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
129129
execConfig.StreamConfig.Wait(ctx)
130+
cancel()
130131

131132
if err := execConfig.CloseStreams(); err != nil {
132133
logrus.Errorf("failed to cleanup exec %s streams: %s", c.ID, err)

0 commit comments

Comments
 (0)