mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
peer: wait a little before closing idle connections
It seems that it needs some time to set connections that just used as idle.
This commit is contained in:
parent
611d564865
commit
069a288a59
@ -122,7 +122,7 @@ func (p *peer) post(d []byte) {
|
|||||||
buf := bytes.NewBuffer(d)
|
buf := bytes.NewBuffer(d)
|
||||||
resp, err := p.c.Post(p.url, "application/octet-stream", buf)
|
resp, err := p.c.Post(p.url, "application/octet-stream", buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("peer.post url=%s err=\"%v\"", p.url, err)
|
log.Printf("peer.post url=%s err=\"%v\"", p.url, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
|
@ -25,6 +25,7 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/coreos/etcd/raft"
|
"github.com/coreos/etcd/raft"
|
||||||
)
|
)
|
||||||
@ -77,6 +78,9 @@ func (h *peerHub) stop() {
|
|||||||
for _, p := range h.peers {
|
for _, p := range h.peers {
|
||||||
p.stop()
|
p.stop()
|
||||||
}
|
}
|
||||||
|
// http.Transport needs some time to put used connections
|
||||||
|
// into idle queues.
|
||||||
|
time.Sleep(time.Millisecond)
|
||||||
tr := h.c.Transport.(*http.Transport)
|
tr := h.c.Transport.(*http.Transport)
|
||||||
tr.CloseIdleConnections()
|
tr.CloseIdleConnections()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user