Skip to content

Commit

Permalink
embed: associate peer serve() listener with corresponding peer
Browse files Browse the repository at this point in the history
Fixes #8383
  • Loading branch information
Anthony Romano authored and gyuho committed Aug 17, 2017
1 parent ce0a61f commit b97714b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions embed/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,16 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {

// configure peer handlers after rafthttp.Transport started
ph := etcdhttp.NewPeerHandler(e.Server)
for i := range e.Peers {
for _, p := range e.Peers {
srv := &http.Server{
Handler: ph,
ReadTimeout: 5 * time.Minute,
ErrorLog: defaultLog.New(ioutil.Discard, "", 0), // do not log user error
}
e.Peers[i].serve = func() error {
return srv.Serve(e.Peers[i].Listener)
}
e.Peers[i].close = func(ctx context.Context) error {

l := p.Listener
p.serve = func() error { return srv.Serve(l) }
p.close = func(ctx context.Context) error {
// gracefully shutdown http.Server
// close open listeners, idle connections
// until context cancel or time-out
Expand Down

0 comments on commit b97714b

Please sign in to comment.