mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver: init server stats before passing it as argument
It is more reasonable to init the variable before passing it as an argument. It fixes a bug that etcdserver may panic on server stats when processing a message from rafthttp streamReader before server stats is initialized in server.Start().
This commit is contained in:
parent
58f035844c
commit
8069d08b96
@ -239,6 +239,7 @@ func NewServer(cfg *ServerConfig) (*EtcdServer, error) {
|
|||||||
Name: cfg.Name,
|
Name: cfg.Name,
|
||||||
ID: id.String(),
|
ID: id.String(),
|
||||||
}
|
}
|
||||||
|
sstats.Initialize()
|
||||||
lstats := stats.NewLeaderStats(id.String())
|
lstats := stats.NewLeaderStats(id.String())
|
||||||
|
|
||||||
srv := &EtcdServer{
|
srv := &EtcdServer{
|
||||||
@ -299,7 +300,6 @@ func (s *EtcdServer) start() {
|
|||||||
s.w = wait.New()
|
s.w = wait.New()
|
||||||
s.done = make(chan struct{})
|
s.done = make(chan struct{})
|
||||||
s.stop = make(chan struct{})
|
s.stop = make(chan struct{})
|
||||||
s.stats.Initialize()
|
|
||||||
// TODO: if this is an empty log, writes all peer infos
|
// TODO: if this is an empty log, writes all peer infos
|
||||||
// into the first entry
|
// into the first entry
|
||||||
go s.run()
|
go s.run()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user