Avoid creating a global context object that will be used while the daemon is running. Not only this object won't ever be garbage collected, but it won't ever be used for anything else than creating other contexts in each request. I think it's a bad practive to have something like this sprawling aroud the code. This change removes that global object and initializes a context in the cases we don't have already one, like shutting down the server. This also removes a bunch of context arguments from functions that did nothing with it. Signed-off-by: David Calavera <david.calavera@gmail.com> Upstream-commit: 27c76522dea91ec585f0b5f0ae1fec8c255b7b22 Component: engine
59 lines
1.0 KiB
Go
59 lines
1.0 KiB
Go
// +build windows
|
|
|
|
package server
|
|
|
|
import (
|
|
"errors"
|
|
"net"
|
|
"net/http"
|
|
|
|
"github.com/docker/docker/daemon"
|
|
)
|
|
|
|
// NewServer sets up the required Server and does protocol specific checking.
|
|
func (s *Server) newServer(proto, addr string) ([]serverCloser, error) {
|
|
var (
|
|
ls []net.Listener
|
|
)
|
|
switch proto {
|
|
case "tcp":
|
|
l, err := s.initTCPSocket(addr)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ls = append(ls, l)
|
|
|
|
default:
|
|
return nil, errors.New("Invalid protocol format. Windows only supports tcp.")
|
|
}
|
|
|
|
var res []serverCloser
|
|
for _, l := range ls {
|
|
res = append(res, &HTTPServer{
|
|
&http.Server{
|
|
Addr: addr,
|
|
Handler: s.router,
|
|
},
|
|
l,
|
|
})
|
|
}
|
|
return res, nil
|
|
|
|
}
|
|
|
|
// AcceptConnections allows router to start listening for the incoming requests.
|
|
func (s *Server) AcceptConnections(d *daemon.Daemon) {
|
|
s.daemon = d
|
|
s.registerSubRouter()
|
|
// close the lock so the listeners start accepting connections
|
|
select {
|
|
case <-s.start:
|
|
default:
|
|
close(s.start)
|
|
}
|
|
}
|
|
|
|
func allocateDaemonPort(addr string) error {
|
|
return nil
|
|
}
|