mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
rafthttp: do not create new connections after stopping transport
This commit is contained in:
parent
d814e9dc35
commit
8291110049
@ -202,11 +202,19 @@ func (t *Transport) Stop() {
|
||||
if tr, ok := t.pipelineRt.(*http.Transport); ok {
|
||||
tr.CloseIdleConnections()
|
||||
}
|
||||
t.peers = nil
|
||||
t.remotes = nil
|
||||
}
|
||||
|
||||
func (t *Transport) AddRemote(id types.ID, us []string) {
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
if t.remotes == nil {
|
||||
// there's no clean way to shutdown the golang http server
|
||||
// (see: https://github.com/golang/go/issues/4674) before
|
||||
// stopping the transport; ignore any new connections.
|
||||
return
|
||||
}
|
||||
if _, ok := t.peers[id]; ok {
|
||||
return
|
||||
}
|
||||
@ -223,6 +231,9 @@ func (t *Transport) AddRemote(id types.ID, us []string) {
|
||||
func (t *Transport) AddPeer(id types.ID, us []string) {
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
if t.peers == nil {
|
||||
panic("transport stopped")
|
||||
}
|
||||
if _, ok := t.peers[id]; ok {
|
||||
return
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user