Use Timeout Conn wrapper to set read deadline for downloading layer

Docker-DCO-1.1-Signed-off-by: Derek <crq@kernel.org> (github: crquan)
This commit is contained in:
Derek 2014-05-22 23:58:56 -07:00
parent 4d6eca99dc
commit 3a21f339f1

View File

@ -726,7 +726,17 @@ type Registry struct {
}
func NewRegistry(authConfig *AuthConfig, factory *utils.HTTPRequestFactory, indexEndpoint string) (r *Registry, err error) {
httpDial := func(proto string, addr string) (net.Conn, error) {
conn, err := net.Dial(proto, addr)
if err != nil {
return nil, err
}
conn = utils.NewTimeoutConn(conn, time.Duration(1)*time.Minute)
return conn, nil
}
httpTransport := &http.Transport{
Dial: httpDial,
DisableKeepAlives: true,
Proxy: http.ProxyFromEnvironment,
}
@ -738,6 +748,7 @@ func NewRegistry(authConfig *AuthConfig, factory *utils.HTTPRequestFactory, inde
},
indexEndpoint: indexEndpoint,
}
r.client.Jar, err = cookiejar.New(nil)
if err != nil {
return nil, err