mirror of https://github.com/docker/docs.git
Remove usage of listenbuffer package
It actually adds nothing to queuing requests. Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
parent
3422858653
commit
ca5795cef8
|
@ -39,7 +39,6 @@ type Config struct {
|
||||||
// Server contains instance details for the server
|
// Server contains instance details for the server
|
||||||
type Server struct {
|
type Server struct {
|
||||||
cfg *Config
|
cfg *Config
|
||||||
start chan struct{}
|
|
||||||
servers []*HTTPServer
|
servers []*HTTPServer
|
||||||
routers []router.Router
|
routers []router.Router
|
||||||
}
|
}
|
||||||
|
@ -55,7 +54,6 @@ type Addr struct {
|
||||||
func New(cfg *Config) (*Server, error) {
|
func New(cfg *Config) (*Server, error) {
|
||||||
s := &Server{
|
s := &Server{
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
start: make(chan struct{}),
|
|
||||||
}
|
}
|
||||||
for _, addr := range cfg.Addrs {
|
for _, addr := range cfg.Addrs {
|
||||||
srv, err := s.newServer(addr.Proto, addr.Addr)
|
srv, err := s.newServer(addr.Proto, addr.Addr)
|
||||||
|
@ -132,7 +130,7 @@ func (s *Server) initTCPSocket(addr string) (l net.Listener, err error) {
|
||||||
if s.cfg.TLSConfig == nil || s.cfg.TLSConfig.ClientAuth != tls.RequireAndVerifyClientCert {
|
if s.cfg.TLSConfig == nil || s.cfg.TLSConfig.ClientAuth != tls.RequireAndVerifyClientCert {
|
||||||
logrus.Warn("/!\\ DON'T BIND ON ANY IP ADDRESS WITHOUT setting -tlsverify IF YOU DON'T KNOW WHAT YOU'RE DOING /!\\")
|
logrus.Warn("/!\\ DON'T BIND ON ANY IP ADDRESS WITHOUT setting -tlsverify IF YOU DON'T KNOW WHAT YOU'RE DOING /!\\")
|
||||||
}
|
}
|
||||||
if l, err = sockets.NewTCPSocket(addr, s.cfg.TLSConfig, s.start); err != nil {
|
if l, err = sockets.NewTCPSocket(addr, s.cfg.TLSConfig); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err := allocateDaemonPort(addr); err != nil {
|
if err := allocateDaemonPort(addr); err != nil {
|
||||||
|
@ -202,15 +200,3 @@ func (s *Server) CreateMux() *mux.Router {
|
||||||
|
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
// AcceptConnections allows clients to connect to the API server.
|
|
||||||
// Referenced Daemon is notified about this server, and waits for the
|
|
||||||
// daemon acknowledgement before the incoming connections are accepted.
|
|
||||||
func (s *Server) AcceptConnections() {
|
|
||||||
// close the lock so the listeners start accepting connections
|
|
||||||
select {
|
|
||||||
case <-s.start:
|
|
||||||
default:
|
|
||||||
close(s.start)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ func (s *Server) newServer(proto, addr string) ([]*HTTPServer, error) {
|
||||||
}
|
}
|
||||||
ls = append(ls, l)
|
ls = append(ls, l)
|
||||||
case "unix":
|
case "unix":
|
||||||
l, err := sockets.NewUnixSocket(addr, s.cfg.SocketGroup, s.start)
|
l, err := sockets.NewUnixSocket(addr, s.cfg.SocketGroup)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,10 +268,8 @@ func (cli *DaemonCli) CmdDaemon(args ...string) error {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// after the daemon is done setting up we can tell the api to start
|
// after the daemon is done setting up we can notify systemd api
|
||||||
// accepting connections with specified daemon
|
|
||||||
notifySystem()
|
notifySystem()
|
||||||
api.AcceptConnections()
|
|
||||||
|
|
||||||
// Daemon is fully initialized and handling API traffic
|
// Daemon is fully initialized and handling API traffic
|
||||||
// Wait for serve API to complete
|
// Wait for serve API to complete
|
||||||
|
|
|
@ -7,17 +7,13 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/listenbuffer"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewTCPSocket creates a TCP socket listener with the specified address and
|
// NewTCPSocket creates a TCP socket listener with the specified address and
|
||||||
// and the specified tls configuration. If TLSConfig is set, will encapsulate the
|
// and the specified tls configuration. If TLSConfig is set, will encapsulate the
|
||||||
// TCP listener inside a TLS one.
|
// TCP listener inside a TLS one.
|
||||||
// The channel passed is used to activate the listenbuffer when the caller is ready
|
func NewTCPSocket(addr string, tlsConfig *tls.Config) (net.Listener, error) {
|
||||||
// to accept connections.
|
l, err := net.Listen("tcp", addr)
|
||||||
func NewTCPSocket(addr string, tlsConfig *tls.Config, activate <-chan struct{}) (net.Listener, error) {
|
|
||||||
l, err := listenbuffer.NewListenBuffer("tcp", addr, activate)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,20 +10,17 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/docker/docker/pkg/listenbuffer"
|
|
||||||
"github.com/opencontainers/runc/libcontainer/user"
|
"github.com/opencontainers/runc/libcontainer/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewUnixSocket creates a unix socket with the specified path and group.
|
// NewUnixSocket creates a unix socket with the specified path and group.
|
||||||
// The channel passed is used to activate the listenbuffer when the caller is ready
|
func NewUnixSocket(path, group string) (net.Listener, error) {
|
||||||
// to accept connections.
|
|
||||||
func NewUnixSocket(path, group string, activate <-chan struct{}) (net.Listener, error) {
|
|
||||||
if err := syscall.Unlink(path); err != nil && !os.IsNotExist(err) {
|
if err := syscall.Unlink(path); err != nil && !os.IsNotExist(err) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
mask := syscall.Umask(0777)
|
mask := syscall.Umask(0777)
|
||||||
defer syscall.Umask(mask)
|
defer syscall.Umask(mask)
|
||||||
l, err := listenbuffer.NewListenBuffer("unix", path, activate)
|
l, err := net.Listen("unix", path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue