Skip to content

Commit

Permalink
Merge pull request #505 from TarsCloud/fix/initreport
Browse files Browse the repository at this point in the history
fixbug: fix occasional RPC blocking issue due to coroutine scheduling…
  • Loading branch information
lbbniu authored Jan 11, 2024
2 parents 359dd3f + dd26961 commit 516efe0
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions tars/statf.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,21 @@ type StatFHelper struct {
mStatCountFromServer map[statf.StatMicMsgHead]int
}

func newStatFHelper(app *application) *StatFHelper {
return &StatFHelper{
chStatInfo: make(chan StatInfo, app.ServerConfig().StatReportChannelBufLen),
mStatInfo: make(map[statf.StatMicMsgHead]statf.StatMicMsgBody),
mStatCount: make(map[statf.StatMicMsgHead]int),
app: app,
chStatInfoFromServer: make(chan StatInfo, app.ServerConfig().StatReportChannelBufLen),
mStatInfoFromServer: make(map[statf.StatMicMsgHead]statf.StatMicMsgBody),
mStatCountFromServer: make(map[statf.StatMicMsgHead]int),
}
}

// Init the StatFHelper
func (s *StatFHelper) Init(comm *Communicator, servant string) {
s.servant = servant
s.app = comm.app
s.chStatInfo = make(chan StatInfo, s.app.ServerConfig().StatReportChannelBufLen)
s.chStatInfoFromServer = make(chan StatInfo, s.app.ServerConfig().StatReportChannelBufLen)
s.mStatInfo = make(map[statf.StatMicMsgHead]statf.StatMicMsgBody)
s.mStatCount = make(map[statf.StatMicMsgHead]int)
s.mStatInfoFromServer = make(map[statf.StatMicMsgHead]statf.StatMicMsgBody)
s.mStatCountFromServer = make(map[statf.StatMicMsgHead]int)
s.comm = comm
s.sf = new(statf.StatF)
s.comm.StringToProxy(s.servant, s.sf)
Expand Down Expand Up @@ -175,7 +180,7 @@ func initReport(app *application) error {
return fmt.Errorf("stat init error")
}
comm := app.Communicator()
StatReport = new(StatFHelper)
StatReport = newStatFHelper(app)
StatReport.Init(comm, cfg.Stat)
statInited <- struct{}{}
go StatReport.Run()
Expand Down

0 comments on commit 516efe0

Please sign in to comment.