Skip to content

Commit

Permalink
fix: server data race issue (#1644)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaost authored Dec 19, 2024
1 parent 85e3c72 commit e15b7a1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,13 @@ func (s *server) Run() (err error) {
if err != nil {
return err
}
s.Lock()
s.svr, err = remotesvr.NewServer(s.opt.RemoteOpt, transHdlr)
s.Unlock()
svr, err := remotesvr.NewServer(s.opt.RemoteOpt, transHdlr)
if err != nil {
return err
}
s.Lock()
s.svr = svr
s.Unlock()

// start profiler
if s.opt.RemoteOpt.Profiler != nil {
Expand All @@ -268,7 +269,7 @@ func (s *server) Run() (err error) {
})
}

errCh := s.svr.Start()
errCh := svr.Start()
select {
case err = <-errCh:
klog.Errorf("KITEX: server start error: error=%s", err.Error())
Expand All @@ -281,7 +282,7 @@ func (s *server) Run() (err error) {
}
muStartHooks.Unlock()
s.Lock()
s.buildRegistryInfo(s.svr.Address())
s.buildRegistryInfo(svr.Address())
s.Unlock()

if err = s.waitExit(errCh); err != nil {
Expand Down

0 comments on commit e15b7a1

Please sign in to comment.