فهرست منبع

peer: wait a little before closing idle connections

It seems that it needs some time to set connections that just used
as idle.
Yicheng Qin 11 سال پیش
والد
کامیت
069a288a59
2فایلهای تغییر یافته به همراه5 افزوده شده و 1 حذف شده
  1. 1 1
      etcd/peer.go
  2. 4 0
      etcd/peer_hub.go

+ 1 - 1
etcd/peer.go

@@ -122,7 +122,7 @@ func (p *peer) post(d []byte) {
 	buf := bytes.NewBuffer(d)
 	resp, err := p.c.Post(p.url, "application/octet-stream", buf)
 	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
 	}
 	resp.Body.Close()

+ 4 - 0
etcd/peer_hub.go

@@ -25,6 +25,7 @@ import (
 	"net/url"
 	"path"
 	"sync"
+	"time"
 
 	"github.com/coreos/etcd/raft"
 )
@@ -77,6 +78,9 @@ func (h *peerHub) stop() {
 	for _, p := range h.peers {
 		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.CloseIdleConnections()
 }