Skip to content

Commit

Permalink
Move wgTrackers
Browse files Browse the repository at this point in the history
This commit moves the wgTrackers Add() and Done() funcs of the waitgroup close to the NewDmsgTrackerManager usage and also the Wait() func before the usage of v.trackers in Summary() to spped up the start of hypervisor.
  • Loading branch information
ersonp committed Dec 16, 2021
1 parent 928953c commit 2a1a564
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions pkg/visor/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@ var BuildTag string

// Summary implements API.
func (v *Visor) Summary() (*Summary, error) {
v.wgTrackers.Wait()

overview, err := v.Overview()
if err != nil {
return nil, fmt.Errorf("overview")
Expand Down Expand Up @@ -218,6 +216,7 @@ func (v *Visor) Summary() (*Summary, error) {
}

dmsgStatValue := &dmsgtracker.DmsgClientSummary{}
v.wgTrackers.Wait()
if v.trackers != nil {
if dmsgTracker := v.trackers.GetBulk([]cipher.PubKey{v.conf.PK}); len(dmsgTracker) > 0 {
dmsgStatValue = &dmsgTracker[0]
Expand Down
4 changes: 2 additions & 2 deletions pkg/visor/visor.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ func NewVisor(conf *visorconfig.V1, restartCtx *restart.Context) (*Visor, bool)
wgStunClient: new(sync.WaitGroup),
transportCacheMu: new(sync.Mutex),
}
v.wgTrackers.Add(1)
defer v.wgTrackers.Done()

v.isServicesHealthy.init()

Expand Down Expand Up @@ -157,6 +155,8 @@ func NewVisor(conf *visorconfig.V1, restartCtx *restart.Context) (*Visor, bool)
if !v.processRuntimeErrs() {
return nil, false
}
v.wgTrackers.Add(1)
defer v.wgTrackers.Done()
v.trackers = dmsgtracker.NewDmsgTrackerManager(v.MasterLogger(), v.dmsgC, 0, 0)
return v, true
}
Expand Down

0 comments on commit 2a1a564

Please sign in to comment.