1
0
mirror of https://github.com/moby/moby.git synced 2025-08-01 05:47:11 +03:00

Merge pull request #5571 from vieux/fix_race_docker_daemon

Fix race docker daemon
This commit is contained in:
Victor Vieux
2014-05-16 13:57:43 -07:00
3 changed files with 14 additions and 7 deletions

View File

@ -1189,6 +1189,7 @@ func changeGroup(addr string, nameOrGid string) error {
// ListenAndServe sets up the required http.Server and gets it listening for
// each addr passed in and does protocol specific checking.
func ListenAndServe(proto, addr string, job *engine.Job) error {
var l net.Listener
r, err := createRouter(job.Eng, job.GetenvBool("Logging"), job.GetenvBool("EnableCors"), job.Getenv("Version"))
if err != nil {
return err
@ -1204,7 +1205,11 @@ func ListenAndServe(proto, addr string, job *engine.Job) error {
}
}
l, err := listenbuffer.NewListenBuffer(proto, addr, activationLock)
if job.GetenvBool("BufferRequests") {
l, err = listenbuffer.NewListenBuffer(proto, addr, activationLock)
} else {
l, err = net.Listen(proto, addr)
}
if err != nil {
return err
}
@ -1276,10 +1281,6 @@ func ServeApi(job *engine.Job) engine.Status {
)
activationLock = make(chan struct{})
if err := job.Eng.Register("acceptconnections", AcceptConnections); err != nil {
return job.Error(err)
}
for _, protoAddr := range protoAddrs {
protoAddrParts := strings.SplitN(protoAddr, "://", 2)
if len(protoAddrParts) != 2 {
@ -1306,7 +1307,9 @@ func AcceptConnections(job *engine.Job) engine.Status {
go systemd.SdNotify("READY=1")
// close the lock so the listeners start accepting connections
close(activationLock)
if activationLock != nil {
close(activationLock)
}
return engine.StatusOK
}