mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #4710 from jimenez/4680-timeout_flag-fix
Disable timeout
This commit is contained in:
commit
fb503da34e
2 changed files with 8 additions and 24 deletions
|
@ -26,7 +26,6 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -1135,7 +1134,7 @@ func changeGroup(addr string, nameOrGid string) error {
|
||||||
|
|
||||||
// ListenAndServe sets up the required http.Server and gets it listening for
|
// ListenAndServe sets up the required http.Server and gets it listening for
|
||||||
// each addr passed in and does protocol specific checking.
|
// each addr passed in and does protocol specific checking.
|
||||||
func ListenAndServe(proto, addr string, eng *engine.Engine, logging, enableCors bool, dockerVersion string, socketGroup string) error {
|
func ListenAndServe(proto, addr string, eng *engine.Engine, logging, enableCors bool, dockerVersion, socketGroup string) error {
|
||||||
r, err := createRouter(eng, logging, enableCors, dockerVersion)
|
r, err := createRouter(eng, logging, enableCors, dockerVersion)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1152,7 +1151,7 @@ func ListenAndServe(proto, addr string, eng *engine.Engine, logging, enableCors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
l, err := listenbuffer.NewListenBuffer(proto, addr, activationLock, 15*time.Minute)
|
l, err := listenbuffer.NewListenBuffer(proto, addr, activationLock)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,15 +5,10 @@
|
||||||
*/
|
*/
|
||||||
package listenbuffer
|
package listenbuffer
|
||||||
|
|
||||||
import (
|
import "net"
|
||||||
"fmt"
|
|
||||||
"net"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NewListenBuffer returns a listener listening on addr with the protocol. It sets the
|
// NewListenBuffer returns a listener listening on addr with the protocol.
|
||||||
// timeout to wait on first connection before an error is returned
|
func NewListenBuffer(proto, addr string, activate chan struct{}) (net.Listener, error) {
|
||||||
func NewListenBuffer(proto, addr string, activate chan struct{}, timeout time.Duration) (net.Listener, error) {
|
|
||||||
wrapped, err := net.Listen(proto, addr)
|
wrapped, err := net.Listen(proto, addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -22,7 +17,6 @@ func NewListenBuffer(proto, addr string, activate chan struct{}, timeout time.Du
|
||||||
return &defaultListener{
|
return &defaultListener{
|
||||||
wrapped: wrapped,
|
wrapped: wrapped,
|
||||||
activate: activate,
|
activate: activate,
|
||||||
timeout: timeout,
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +24,6 @@ type defaultListener struct {
|
||||||
wrapped net.Listener // the real listener to wrap
|
wrapped net.Listener // the real listener to wrap
|
||||||
ready bool // is the listner ready to start accpeting connections
|
ready bool // is the listner ready to start accpeting connections
|
||||||
activate chan struct{}
|
activate chan struct{}
|
||||||
timeout time.Duration // how long to wait before we consider this an error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *defaultListener) Close() error {
|
func (l *defaultListener) Close() error {
|
||||||
|
@ -47,15 +40,7 @@ func (l *defaultListener) Accept() (net.Conn, error) {
|
||||||
if l.ready {
|
if l.ready {
|
||||||
return l.wrapped.Accept()
|
return l.wrapped.Accept()
|
||||||
}
|
}
|
||||||
|
<-l.activate
|
||||||
select {
|
|
||||||
case <-time.After(l.timeout):
|
|
||||||
// close the connection so any clients are disconnected
|
|
||||||
l.Close()
|
|
||||||
return nil, fmt.Errorf("timeout (%s) reached waiting for listener to become ready", l.timeout.String())
|
|
||||||
case <-l.activate:
|
|
||||||
l.ready = true
|
l.ready = true
|
||||||
return l.Accept()
|
return l.Accept()
|
||||||
}
|
|
||||||
panic("unreachable")
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue