From dbac8c8f4286d9bcf35157eef484f415c4ec5b7c Mon Sep 17 00:00:00 2001 From: Yicheng Qin Date: Tue, 25 Aug 2015 21:59:56 -0700 Subject: [PATCH] etcdmain: check error before assigning peer transport Or it may panic when new transport fails, e.g., TLS info is invalid. --- etcdmain/etcd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etcdmain/etcd.go b/etcdmain/etcd.go index e585570cdee..91efab5f78c 100644 --- a/etcdmain/etcd.go +++ b/etcdmain/etcd.go @@ -261,10 +261,10 @@ func startProxy(cfg *config) error { } pt, err := transport.NewTimeoutTransport(cfg.peerTLSInfo, time.Duration(cfg.proxyDialTimeoutMs)*time.Millisecond, time.Duration(cfg.proxyReadTimeoutMs)*time.Millisecond, time.Duration(cfg.proxyWriteTimeoutMs)*time.Millisecond) - pt.MaxIdleConnsPerHost = proxy.DefaultMaxIdleConnsPerHost if err != nil { return err } + pt.MaxIdleConnsPerHost = proxy.DefaultMaxIdleConnsPerHost tr, err := transport.NewTimeoutTransport(cfg.peerTLSInfo, time.Duration(cfg.proxyDialTimeoutMs)*time.Millisecond, time.Duration(cfg.proxyReadTimeoutMs)*time.Millisecond, time.Duration(cfg.proxyWriteTimeoutMs)*time.Millisecond) if err != nil {